I would like to know any api or method to check the status of a file system whether it is readonly protected or not.
On my x86 qnx6.3 PC, I inserted a usb which has been readonly-protected.
Then mounted it on /fs/usb/.
If I try to copy or create any file on the file system(/fs/usb), I only get error message saying “Read-only file system”.
It’s ok. Now I need to be able to check whether the file system is read-only file system or not in my program.
I thought statvfs could work. But it doesn’t!!!
The flag, ‘struct statvfs::f_flag’ retireved by statvfs is only 0x100.
0x100 is not the read-only because other file system like ‘/’ retrieves same value 0x100 and I can copy files on ‘/’.
Now I found statvfs doesn’t work for my case.
Can anyone help me?
I just tried it here, and I get 0x100 for “/” and 0x101 for a filesystem I mount as readonly. I suspect that your device contains a corrupt filesystem, and the first time you try to write to it, the filesystem driver detects this, and remounts itself as readonly (that is what the filesystem does to prevent further damage to the filesystem).
To check that your code is correct, you can just:
devb-ram ram capacity=8192 &
mount -r /dev/hdXt77 /ram
(testProgram /ram should show 0x101 for the filesystem)