QStorageInfo is not working with read only rootfs

Viewed 290

I am using qt revision 5.7.1 on my debian strech system. I have mounted my rootfs as read only using overlayfs ,I have used QStorageInfo to check my SD card size.

After mounting rootfs as read only i am getting only root directory in QStorageInfo mountedvolumes.

Below is the source code to get storage list:

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();
    }
}

output of above source :

storage path "/"
        storage name ""
        storage readonly true
        storage filesystem type  ""
        storage device  ""

my /etc/fstab file contain:

/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

If I mount rootfs as "rw" QStorageInfo works fine. Following is the output in "rw" option as 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"

when set rootfs as read/write permission working fine. It doesn't work as excepted when set as read only

Please help me understand issue QStorageInfo with readonly rootfs.

1 Answers

QStorageInfo is trying to read /etc/mtab to get the mountedvolumes. /etc/mtab can not generate because of readonly rootfs.

/etc/mtab is symbolic link of "../proc/self/mounts".

so it is required to generate smbolink link from "../proc/self/mounts" to /etc/mtab before creating read only system.

Related