[ On Saturday, July 12, 2003 at 03:38:51 (+0200), Matthias Buelow wrote: ]
I think you're forgetting that a "unix file" includes its metadata
(especially if you're talking about kernel internals) and unlink() most
certainly always operates directly on the metadata of a file, even if
the link count is greater than one since the link count is always
decremented.
Unlink() _also_ operates on directories, but most importantly it
decrements the inode link count.
Ah, not, that's wrong. The kernel most definitely always decrements the
link count of an inode when unlink() is called. It _also_ zeros out the
inode number of a filename entry in the parent directory file.
The directory reference is only a part of the picture -- if you ignore
the link count in the inode then you have failed to understand the unix
filesystem sufficiently.
The fact that the unix filesystem is primarily a table of inodes is no
mere implementation detail.
No, one could not concieve of such a thing since it would have to be run
either in single user mode or while the filesystem was not mounted (or
while the whole filesystem is locked from modification). Do you forget
that Unix systems are inherently multi-processing systems? It is
absolutely fundamental and critical that unlink() modify the file's link
count (as well as of course freeing the directory entry).
(in fact the moral opposite is true -- it would be possible to not
immediately free the directory entry if inodes included two reference
counts instead of just one such count since an attempt to reference a
file with no valid links but only remaining directory references could
be treated as if there were in fact no directory reference)
No doubt -- but there it is none the less. :-)
--
Greg A. Woods
+1 416 218-0098; <g.a.woods@ieee.org>; <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>