| Author |
Message |
|
|
Post subject: Read-only file system ,ST_RDONLY not shows up on statvfs ?
Posted: May 06, 2008 - 06:47 AM
|
|
New Member
Joined: Apr 16, 2008
Posts: 4
|
|
Hello,
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? |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Read-only file system ,ST_RDONLY not shows up on statvfs
Posted: May 06, 2008 - 11:07 AM
|
|
Senior Member
Joined: Jul 22, 2004
Posts: 315
|
|
Actually statvfs should tell you that for your Filesystem.
Other thing you would have to check is if you have write access to the directory you want to write to: |
|
|
| |
|
|
|
 |
|
|
Post subject: Re: Read-only file system ,ST_RDONLY not shows up on statvfs
Posted: May 06, 2008 - 05:41 PM
|
|
QNX Master
Joined: Jul 11, 2002
Posts: 557
|
|
|
jeongheum wrote:
Hello,
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
(testProgram /ram should show 0x101 for the filesystem) |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Re: Read-only file system ,ST_RDONLY not shows up on sta
Posted: May 07, 2008 - 12:40 AM
|
|
New Member
Joined: Apr 16, 2008
Posts: 4
|
|
| For your info. the filesystem type is "dos(fat32)" and the device is usb memory stick. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: Re: Read-only file system ,ST_RDONLY not shows up on sta
Posted: May 07, 2008 - 03:07 AM
|
|
QNX Master
Joined: Sep 01, 2002
Posts: 2667
|
|
It's quite possible the fat file system component doesn't fill that info properly.
However if you try the create a file with fopen with the write flag it should fail and set errno to the error that matches READ ONLY filesystem. |
|
|
| |
|
|
|
 |
|
|