QStorageInfo::isReadOnly() returns wrong state?
-
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(); }
-
Hi,
What is your issue exactly ?
An encrypted storage does not equal read only. -
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.
-
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.
@Kevin-Hoang you're likely correct. Some more information about @itorin setup, steps to reproduce will make things clearer.
-
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.
-
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.
@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. -
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? -
@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!
-