File space allocation/deallocation under Unix (BSD4.x)
Chris Torek
chris at mimsy.UUCP
Wed Jul 13 07:09:18 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?
The answer is `yes', but given the way you phrased the question, I think
you misunderstand what is going on. The space FOR THE NAME `f' remains
allocated. Since file names are typically very small, this makes little
difference (space is allocated in 512 byte or 1 kbyte units). On the
other hand, if a directory grows very large (many file names) and the
file names are subsequently removed, the space remains occupied, except
in 4.3BSD and later versions of BSD, where any new file creation or
renaming will truncate any unused blocks off the end. For this to
work, the remaining file names need to be near the front of the directory;
this can be arranged by renaming those files near the end:
# approximately,
# do
ls -f
mv last_name_shown x; mv x last_name_shown
# until last_name_shown does not move.
# the directory has now been compacted.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.questions
mailing list