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

Lipp Peter plipp at tugiig
Wed Jul 13 23:46:39 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")?

I really have never heard such a ridiculous theory. I really do not KNOW, how
bsd4.2 does it, but (see Maurice J. Bach, The Design of the Unix Operating System,
Prentice Hall) as in all Unix Systems I am very sure it is like this:

Every file is represented by an inode. This inode contains a list of disk-blocks
the file consist of (about 2000 for your MB). If you remove the file all the disk-
blocks are freed.

The only chance you have that the MB is still in use after removing is, that somebody 
has made a link to your file (hard-link). You wouldn`t notice this and, if you do the rm,
the directory of the other user still has a reference to the files inode - so the inode
and the disk-blocks would not be freed. But - the inode and the data still belong to you.

Peter Lipp (plipp at tugiig.uucp)



More information about the Comp.unix.wizards mailing list