File space allocation/deallocation under Unix (BSD4.x)

Randy_Davis rjd at occrsh.ATT.COM
Wed Jul 13 23:38:28 AEST 1988


In article <9662 at eddie.MIT.EDU> rich at eddie.MIT.EDU (Richard Caloggero) writes:
:     If you create a directory "d", then create a file "d/f" 1 megabyte
:long (big), then "rm d/f", is it true that the space remains allocated
:to directory "d" and cannot be garbage collected or otherwise reclaimed
:until another file is created in directory "d" or "d" is deleted?  If this is
 true, why?  What good does it do to delete files, say, in your home directory
:(if, for example, disk resources are low and you system administrator
:keeps hounding you to "clean up your directory")?
:						-- Rich (rich at eddie.mit.edu).

  When you remove the file, the space taken by the file *contents* is reclaimed,
i.e., the 1 megabye above is available for system use again.  The 16 bytes
(for System V) taken by the file entry in the directory "file" is *not*
reclaimed unless you remove the directory.
  To explain the directory part further: if you make the directory then ls -al
the directory, you will see that the directory entry, ".", takes up 32 bytes
of space; 16 bytes for the "." entry, and 16 bytes for the ".." entry (you can
check this under System V via the 'od -c .' command).  If you create a file
under this directory, the directory "file" will increase by 16 bytes to 48
bytes.  If you then remove this file, the directory "file" does *not* reduce
by 16 bytes....

Randy



More information about the Comp.unix.questions mailing list