Xref: utzoo comp.unix.questions:23338 comp.sys.pyramid:853 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!zaphod.mps.ohio-state.edu!mips!pacbell.com!pacbell!sactoh0!jak From: jak@sactoh0.UUCP (Jay A. Konigsberg) Newsgroups: comp.unix.questions,comp.sys.pyramid Subject: Re: getting 'df' info from inside a program? Message-ID: <3394@sactoh0.UUCP> Date: 28 Jun 90 01:08:55 GMT References: <797@massey.ac.nz> Reply-To: jak@sactoh0.UUCP (Jay A. Konigsberg) Organization: SAC-UNIX, Sacramento, Ca. Lines: 32 In article <797@massey.ac.nz> GEustace@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) #include #include #include main() { struct stat *buf; buf = (struct stat *)malloc(sizeof(struct stat)); /* error check removed */ if ( stat("filename", buf) == -1 ) { fprintf("stat: error=%d\n", errno); exit(2); } else { printf("%s is %ld bytes.\n", "filename", buf->st_size); } } -- ------------------------------------------------------------- Jay @ SAC-UNIX, Sacramento, Ca. UUCP=...pacbell!sactoh0!jak If something is worth doing, its worth doing correctly.