How do you find the symbolic links to files.

Jonathan I. Kamens jik at athena.mit.edu
Fri Dec 14 07:39:26 AEST 1990


In article <1990Dec12.174807.12868 at specialix.co.uk>, jonb at specialix.co.uk (Jon Brawn) writes:
|> (This isn't a flame, I'm quite serious now!)
|> Can anyone think up a good use for looking at the st_blocks field?

  I'm not sure whether you mean any use in general, or a use specifically
related to backup and restore, since that's what's being discussed here.

  If you mean the former, then I can give you one way st_blocks is used.  The
expunge program in my undel2 package (available at a comp.sources.unix archive
site near you, in volume22, make sure to also get "et" in the same volume :-)
has options to report the amount of space made free by the expunging of each
file, and the total amount of space freed after all appropriate files are
expunged.  It does this by multiplying the number of blocks (st_blocks) for
each file by DEV_BSIZE (from <sys/param.h> and dividing by 1024 to get
kilobytes instead of bytes (Yes, I should probably be calling statfs on the
filesystem instead of using DEV_BSIZE, but it hasn't been a problem up to this
point :-).

  The point of this is that when someone expunges files, they want to know how
much space was actually freed, not what the total size of all the files in the
filesystem is.  Those two values would differ in the case of files with holes
in them, and in the much more common case of files which are not exactly a
multiple of the block size in length, since the space in the partially
unfilled block at the end of a file is wasted.

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.internals mailing list