unmounted file system

unmounted file system

Post by Serg » Wed, 05 Jun 2002 21:35:58



Hi,
I am looking for a C function which can return statistics from unmounted
file systems. For now I  have found a function called statfs which give me
what I want; but in the file statfs.h we can see that this function is
obsolete and will be remove soon, and they to use the new function statvfs.
Unfortunately, this last function works only for mounted file system. Does
anybody know a workaround for this and way to obtain these data (especially
the whole size and the free space) for an unmounted file system?
Sure I can use statfs for the moment but statfs may be already removed on
Solaris9. That's why I'd like to find another way.
Thanks in advance.

Serge

 
 
 

unmounted file system

Post by Andrew Gabri » Fri, 07 Jun 2002 02:05:31




Quote:> Hi,
> I am looking for a C function which can return statistics from unmounted
> file systems. For now I  have found a function called statfs which give me
> what I want; but in the file statfs.h we can see that this function is
> obsolete and will be remove soon, and they to use the new function statvfs.

That comment has been there back at least to 1992, maybe earlier;-)
I doubt statfs(2) will go, but it is a dated interface which goes
back to SVR3 (if not earlier), and has smaller field widths than
statvfs(2).  Any program you write now should be using statvfs(2)
instead of statfs(2).

Quote:> Unfortunately, this last function works only for mounted file system. Does

Same with statfs(2).

Quote:> anybody know a workaround for this and way to obtain these data (especially
> the whole size and the free space) for an unmounted file system?
> Sure I can use statfs for the moment but statfs may be already removed on
> Solaris9. That's why I'd like to find another way.

It's still in Solaris 9, but it doesn't work the way you want
anyway.

df(1) can be used on an unmounted filesystem by giving the device
name, so unless you want to open the device and crawl through the
filesystem structures yourself, I suggest you run df(1) via
popen(3), and parse the command output in your program.

--
Andrew Gabriel