Subject: Re: funlink() for fun!
To: NetBSD Kernel Technical Discussion List <firstname.lastname@example.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
Date: 07/10/2003 23:41:40
> Perhaps you've forgotten either one of: (a) the option of caching
> open filenames; or (b) the qualifier that funlink() could/should
> fail/misbehave if the inode has multiple hard links.
Neither is of any real use by itself.
fd = open("/home/alice/fnord/flarp",O_WRONLY|O_CREAT|O_EXCL,0666);
funlink(fd); /* What does this do? Why and how? */
Even if you cache the pathname passed to open, even though the rename()
does not have anything obvious to do with the open()ed path, even
though file still has only one hard link, you have to search the
filesystem. Or else you have to do an amazing amount of work
(including, at a minimum, an open file table walk) in rename(), link(),
unlink(), and probably other calls I haven't thought of to make sure
that the "cached" pathnames remain correct as files and directories get
It might work to cache the containing-directory vnode and the opened-as
name (or moral equivalent, such as having directory vnodes point to a
list of currently-open files in them), and then all you have to worry
about is other clients of the same fileserver renaming it out from
behind your back (which admittedly is really no different from many
other issues such environments already have). You don't even need the
nlink==1 check if you do that.
/~\ The ASCII der Mouse
\ / Ribbon Campaign
X Against HTML email@example.com
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B