QStorageInfo 不适用于只读 rootfs
QStorageInfo is not working with read only rootfs
我在我的 debian strech 系统上使用 qt 修订版 5.7.1。我使用 overlayfs 将我的 rootfs 安装为只读,我使用 QStorageInfo 检查我的 SD 卡大小。
将 rootfs 安装为只读后,我在 QStorageInfo mountedvolumes 中只获得根目录。
下面是获取存储列表的源码:
foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes()) {
if (storage.isValid() && storage.isReady())
{
qDebug() << "storage path" << storage.rootPath();
qDebug() << "storage name" << storage.name();
qDebug() << "storage readonly" << storage.isReadOnly();
qDebug() << "storage filesystem type " << storage.fileSystemType();
qDebug() << "storage device " << storage.device();
}
}
以上来源的输出:
storage path "/"
storage name ""
storage readonly true
storage filesystem type ""
storage device ""
我的 /etc/fstab 文件包含:
/dev/mmcblk0p1 / ext4 ro,noatime 0 1
mount_overlay /var fuse nofail,defaults 0 0
mount_overlay /home fuse nofail,defaults 0 0
mount_overlay /etc fuse nofail,defaults 0 0
none /tmp tmpfs defaults 0 0
如果我将 rootfs 挂载为“rw”QStorageInfo 工作正常。
以下是“rw”选项作为 rootfs 的输出:
storage path "/"
storage name ""
storage readonly false
storage filesystem type "ext4"
storage device "/dev/root"
storage path "/run"
storage name ""
storage readonly false
storage filesystem type "tmpfs"
storage device "tmpfs"
storage path "/run/lock"
storage name ""
storage readonly false
storage filesystem type "tmpfs"
storage device "tmpfs"
storage path "/tmp"
storage name ""
storage readonly false
storage filesystem type "tmpfs"
storage device "none"
storage path "/home"
storage name ""
storage readonly false
storage filesystem type "ext4"
storage device "/dev/root"
storage path "/var"
storage name ""
storage readonly false
storage filesystem type "ext4"
storage device "/dev/root"
storage path "/media/data"
storage name "Data"
storage readonly false
storage filesystem type "ext4"
storage device "/dev/mmcblk0p3"
storage path "/run/user/0"
storage name ""
storage readonly false
storage filesystem type "tmpfs"
storage device "tmpfs"
storage path "/home/user/SdCard"
storage name "SDCard"
storage readonly false
storage filesystem type "ext4"
storage device "/dev/mmcblk1p1"
storage path "/home_org/user/SdCard"
storage name "SDCard"
storage readonly false
storage filesystem type "ext4"
storage device "/dev/mmcblk1p1"
当将 rootfs 设置为 read/write 权限时工作正常。当设置为只读时它不能正常工作
请帮助我理解问题 QStorageInfo with readonly rootfs。
QStorageInfo 正在尝试读取 /etc/mtab 以获取已安装的卷。
/etc/mtab 由于 readonly rootfs 无法生成。
/etc/mtab 是“../proc/self/mounts”的符号 link。
所以在创建只读系统之前需要生成smbolink link从“../proc/self/mounts”到/etc/mtab。
我在我的 debian strech 系统上使用 qt 修订版 5.7.1。我使用 overlayfs 将我的 rootfs 安装为只读,我使用 QStorageInfo 检查我的 SD 卡大小。
将 rootfs 安装为只读后,我在 QStorageInfo mountedvolumes 中只获得根目录。
下面是获取存储列表的源码:
foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes()) {
if (storage.isValid() && storage.isReady())
{
qDebug() << "storage path" << storage.rootPath();
qDebug() << "storage name" << storage.name();
qDebug() << "storage readonly" << storage.isReadOnly();
qDebug() << "storage filesystem type " << storage.fileSystemType();
qDebug() << "storage device " << storage.device();
}
}
以上来源的输出:
storage path "/"
storage name ""
storage readonly true
storage filesystem type ""
storage device ""
我的 /etc/fstab 文件包含:
/dev/mmcblk0p1 / ext4 ro,noatime 0 1
mount_overlay /var fuse nofail,defaults 0 0
mount_overlay /home fuse nofail,defaults 0 0
mount_overlay /etc fuse nofail,defaults 0 0
none /tmp tmpfs defaults 0 0
如果我将 rootfs 挂载为“rw”QStorageInfo 工作正常。 以下是“rw”选项作为 rootfs 的输出:
storage path "/"
storage name ""
storage readonly false
storage filesystem type "ext4"
storage device "/dev/root"
storage path "/run"
storage name ""
storage readonly false
storage filesystem type "tmpfs"
storage device "tmpfs"
storage path "/run/lock"
storage name ""
storage readonly false
storage filesystem type "tmpfs"
storage device "tmpfs"
storage path "/tmp"
storage name ""
storage readonly false
storage filesystem type "tmpfs"
storage device "none"
storage path "/home"
storage name ""
storage readonly false
storage filesystem type "ext4"
storage device "/dev/root"
storage path "/var"
storage name ""
storage readonly false
storage filesystem type "ext4"
storage device "/dev/root"
storage path "/media/data"
storage name "Data"
storage readonly false
storage filesystem type "ext4"
storage device "/dev/mmcblk0p3"
storage path "/run/user/0"
storage name ""
storage readonly false
storage filesystem type "tmpfs"
storage device "tmpfs"
storage path "/home/user/SdCard"
storage name "SDCard"
storage readonly false
storage filesystem type "ext4"
storage device "/dev/mmcblk1p1"
storage path "/home_org/user/SdCard"
storage name "SDCard"
storage readonly false
storage filesystem type "ext4"
storage device "/dev/mmcblk1p1"
当将 rootfs 设置为 read/write 权限时工作正常。当设置为只读时它不能正常工作
请帮助我理解问题 QStorageInfo with readonly rootfs。
QStorageInfo 正在尝试读取 /etc/mtab 以获取已安装的卷。 /etc/mtab 由于 readonly rootfs 无法生成。
/etc/mtab 是“../proc/self/mounts”的符号 link。
所以在创建只读系统之前需要生成smbolink link从“../proc/self/mounts”到/etc/mtab。