Xref: utzoo comp.unix.questions:8210 comp.unix.wizards:9890 comp.sys.apollo:1119
Path: utzoo!attcan!uunet!mcvax!tuvie!tugiig!plipp
From: plipp@tugiig (Lipp Peter)
Newsgroups: comp.unix.questions,comp.unix.wizards,comp.sys.apollo
Subject: Re: File space allocation/deallocation under Unix (BSD4.x)
Keywords: Unix, BSD, File, Delete
Message-ID: <17@tugiig>
Date: 13 Jul 88 13:46:39 GMT
References: <9662@eddie.MIT.EDU>
Organization: none
Lines: 25

In article <9662@eddie.MIT.EDU>, rich@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@tugiig.uucp)