Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QStorageInfo::isReadOnly() returns wrong state?
Forum Updated to NodeBB v4.3 + New Features

QStorageInfo::isReadOnly() returns wrong state?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 5 Posters 549 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    itorin
    wrote on last edited by itorin
    #1

    Hi, I'm using Qt 6.9.0 for macOS.
    Below console app code returns true for my writable SSD, for example, true for "Macintosh HD", OS installed storage.
    File system of the storage is encrypted APFS.
    What is wrong?

    #include <QCoreApplication>
    #include <QStorageInfo>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes())
        {
            if (storage.isValid() && storage.isReady())
            {
                qDebug() << storage.displayName() << storage.isReadOnly();
            }
        }
        return a.exec();
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What is your issue exactly ?
      An encrypted storage does not equal read only.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kevin Hoang
        wrote on last edited by
        #3

        I think what he meant is: If the user enables Encrypted APFS, once macOS unlocks and mounts the drive, the volume behaves like a normal disk, regardless of whether it is encrypted. At that point, QStorageInfo::isReadOnly() should return false, since QStorageInfo only lists volumes that are already mounted.

        However, on macOS, there are also volumes that are intentionally mounted as read-only, such as the System Volume, or due to policies, MDM settings, etc. So I'm not sure if he might have confused these cases.

        That said, I don't use Encrypted APFS, so I might not be able to provide much further help on this.

        SGaistS 1 Reply Last reply
        0
        • K Kevin Hoang

          I think what he meant is: If the user enables Encrypted APFS, once macOS unlocks and mounts the drive, the volume behaves like a normal disk, regardless of whether it is encrypted. At that point, QStorageInfo::isReadOnly() should return false, since QStorageInfo only lists volumes that are already mounted.

          However, on macOS, there are also volumes that are intentionally mounted as read-only, such as the System Volume, or due to policies, MDM settings, etc. So I'm not sure if he might have confused these cases.

          That said, I don't use Encrypted APFS, so I might not be able to provide much further help on this.

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Kevin-Hoang you're likely correct. Some more information about @itorin setup, steps to reproduce will make things clearer.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rajan
            wrote on last edited by
            #5

            Hi @kevin-Hoang, @itorin, @SGaist —

            I'm new to Qt and exploring the feasibility of developing a high-performance desktop application with the following features. I would appreciate clarification on whether Qt (using C++ and/or Qt Widgets/Quick) is suitable for implementing these features entirely, or if some parts require integration with Python, MATLAB, or other third-party libraries.

            JonBJ 1 Reply Last reply
            0
            • R rajan

              Hi @kevin-Hoang, @itorin, @SGaist —

              I'm new to Qt and exploring the feasibility of developing a high-performance desktop application with the following features. I would appreciate clarification on whether Qt (using C++ and/or Qt Widgets/Quick) is suitable for implementing these features entirely, or if some parts require integration with Python, MATLAB, or other third-party libraries.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @rajan
              You made your own topic for this at https://forum.qt.io/topic/161764/can-all-these-features-be-implemented-in-a-qt-based-windows-desktop-application
              Please do not hijack an unrelated topic like this as well.
              And no need to call out individuals, post your questions and those who can help will reply.

              1 Reply Last reply
              1
              • I Offline
                I Offline
                itorin
                wrote on last edited by
                #7

                Thanks to everyone. I apologize for explaining my problem ambiguously.
                My sample code returns always true; nevertheless, my "Macintosh HD" is a writable disk. This is a system volume of macOS.
                I tested additional volumes after my post.
                In the case of an exFAT formatted (writable) USB memory, my code returns false.
                An encrypted APFS (writable) USB memory also returns false.
                Does this relate to a macOS system protection?

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  Kevin Hoang
                  wrote on last edited by
                  #8

                  @itorin I see what you mean now!

                  By default, the system volume (Macintosh HD) is read-write for the system user only, and read-only for everyone else. You can check this by opening Finder → going to the Go menu → selecting Computer (Shift + Command + C), selecting your drive, and clicking "Get Info" to see the permissions.

                  For folders like Documents, Desktop, Downloads, removable drives (USB), and network drives, your app needs to request access permission in order to write files. Otherwise, they are also read-only by default. So your USB memory disk would fall into this category too.

                  Hope this clears things up for you!

                  1 Reply Last reply
                  1
                  • I Offline
                    I Offline
                    itorin
                    wrote on last edited by
                    #9

                    @Kevin-Hoang , @SGaist
                    I appreciate your reply.
                    It is a clear understanding of my problem.
                    Thanks again!

                    1 Reply Last reply
                    0
                    • I itorin has marked this topic as solved on

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved