Peter Pilgrim wrote:
> 
> I am interesting in getting the disk space and partition
> in a Java program by using JNI. What is the std UNIX API
> call to do this? I have tried grepping the man pages
> and got the source to kdf program but it didn't help
> because it was executing `/usr/bin/df -k -T' and parsing
> the output. Is there a native portable UNIX system call that
> provides partition information and also disk space size and free
> information?

I don't know of a standard UNIX API, and I don't think that Wintel's
notion of partitions is particularly portable. On Linux, you can get
some of the information you want from the /proc filesystem:

/proc/partitions gives you a lists of hard drive partitions and their
sizes

/proc/mounts shows you what's mounted where


What you don't get from these two files is:

1) What device is serving as your root partition (/proc/mounts calls it,
annoyingly, /dev/root)

2) How full the partition is


You can also get the df.c source (it's about 800 lines of open source)
and learn about the APIs it uses (it doesn't appear to use the /proc
filesystem). Looks like there are some interesting APIs described in
header files named mountlist.h and fsusage.h. If you don't have a
convenient source, I can send it to you.

You were probably hoping for a more portable answer... I'm not aware of
one.

Nathan


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to