OpenQNX :: The QNX Community Portal

May 13, 2008 - 12:43 PM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 55 unlogged users and 3 registered users online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
jeongheum
Post subject: Read-only file system ,ST_RDONLY not shows up on statvfs ?  PostPosted: 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?
 
 View user's profile Send private message  
Reply with quote Back to top
micro
Post subject: RE: Read-only file system ,ST_RDONLY not shows up on statvfs  PostPosted: 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:
 
 View user's profile Send private message  
Reply with quote Back to top
rgallen
Post subject: Re: Read-only file system ,ST_RDONLY not shows up on statvfs  PostPosted: 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)
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
jeongheum
Post subject: RE: Re: Read-only file system ,ST_RDONLY not shows up on sta  PostPosted: 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.
 
 View user's profile Send private message  
Reply with quote Back to top
mario
Post subject: RE: Re: Read-only file system ,ST_RDONLY not shows up on sta  PostPosted: 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.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.