getting 'df' info from inside a program?

Michael P. Lindner mpl at pegasus.ATT.COM
Fri Jun 29 07:57:11 AEST 1990


In article <3394 at sactoh0.UUCP> jak at sactoh0.UUCP (Jay A. Konigsberg) writes:
>In article <797 at massey.ac.nz> GEustace at massey.ac.nz (Glen Eustace) writes:
>>We are trying to write some code that will check whether a file will
>>fit on a given file system prior to copying it.  It would be great if
>>the information given in a 'df' were available with some system call.
>>Does anyone know whether there is one and if so how one uses it.
>>
>This looks like a job for the stat() system call. (Sys V)
	code deleted

Close, but NO CIGAR!
Glen KNOWS how big his file is.  The problem is to find out how much space
is available in the destination filesystem.  To do that call statfs() (Sys
V once again).  On older systems you could use ustat().  See section 2 of
the programmer's reference manual for more info.

Mike Lindner
AT&T Bell Labs
attmail!mplindner



More information about the Comp.unix.questions mailing list