Xref: utzoo comp.unix.questions:23383 comp.sys.pyramid:859 Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!ulysses!swfc From: swfc@ulysses.att.com (Shu-Wie F Chen) Newsgroups: comp.unix.questions,comp.sys.pyramid Subject: Re: getting 'df' info from inside a program? Message-ID: <13254@ulysses.att.com> Date: 29 Jun 90 14:58:12 GMT References: <797@massey.ac.nz> <3394@sactoh0.UUCP> <4881@pegasus.ATT.COM> Sender: netnews@ulysses.att.com Reply-To: swfc@ulysses.att.com (Shu-Wie F Chen) Organization: AT&T Bell Labs Lines: 32 In article <4881@pegasus.ATT.COM>, mpl@pegasus.ATT.COM (Michael P. Lindner) writes: |>In article <3394@sactoh0.UUCP> jak@sactoh0.UUCP (Jay A. Konigsberg) writes: |>>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) |> 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 So what happens if two of these things execute simultaneously. Both calculate that they can copy their files onto the file system and try to do so. If the sum of the sizes of both files is greater than the available space, one of those processes will lose. Or is this not a problem? That is, will you check afterwards if the copy was successful, etc. *swfc