首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >QStorageInfo不支持只读根文件系统

QStorageInfo不支持只读根文件系统
EN

Stack Overflow用户
提问于 2020-10-26 19:30:31
回答 1查看 163关注 0票数 2

我在我的debian strech系统上使用qt版本5.7.1。我已经使用overlayfs将我的根文件系统挂载为只读,我已经使用QStorageInfo检查我的SD卡大小。

将rootfs挂载为只读后,我在QStorageInfo挂载的卷中只能获得根目录。

以下是获取存储列表的源码:

代码语言:javascript
复制
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();
    }
}

上述信号源的输出:

代码语言:javascript
复制
storage path "/"
        storage name ""
        storage readonly true
        storage filesystem type  ""
        storage device  ""

我的/etc/fstab文件包含:

代码语言:javascript
复制
/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的输出:

代码语言:javascript
复制
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设置为读/写权限时,工作正常。当设置为只读时,它不能正常工作

请帮助我理解只读根文件系统的QStorageInfo问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-27 15:58:07

QStorageInfo正在尝试读取/etc/mtab以获取已装载的卷。/etc/mtab无法生成,因为存在只读的rootfs。

/etc/mtab是“../proc/self/mount”的符号链接。

因此在创建只读系统之前,需要生成从“../proc/self/mount”到/etc/mtab的smbolink链接。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64536279

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档