checking disk space from c program
Jon A. Tankersley
zjat02 at apctrc.UUCP
Sun Apr 10 14:18:45 AEST 1988
On a Sun maybe on any BSD system - statfs has the information.
Here is a skeleton:
#include <sys/types.h>
#include <sys/vfs.h>
.
.
.
struct statfs buf;
/*
* call statfs regarding a filename path and check out the results
* filename MUST exist as either file or directory
*/
if ( statfs(path,&buf) == 0 )
/* return block_size*blocks_avail as size in bytes */
return(buf.f_bsize*buf.f_bavail);
else
/* error, return -1 */
return(-1);
-tank-
More information about the Comp.unix.questions
mailing list