Subject: Re: Defragmenting a NetBSD drive
To: Robert Elz <kre@munnari.OZ.AU>
From: Guenther Grau <>
List: netbsd-ports
Date: 09/16/1999 18:11:27
Robert Elz wrote:
>     Date:        Thu, 16 Sep 1999 17:39:46 +0200
>     From:        Guenther Grau <>
>     Message-ID:  <>
>   | The unlink() just needed to lock the directory and all other tools
>   | trying to access this directory would fail to open it.
> And those that already have it open, and are part way through reading it?

Hmm, ok, I see I am talking to a real expert here :-)
Looks like I make a complete idiot out of me ;-)

> You can't really prevent anyone else from creating or removing files in
> the directory (consider /tmp ...) for 100 hours or you have a huge DOS
> potential.   Nor is there any rational way in the current model to
> signal to this process that its scan of the directory has broken.

Ok, you are right. All the processes doing a opendir()/readdir()
need to fail when the directory changes behind their backs.
So a real solution (I wonder what I forgot now :-) would be
to return E_DIRWASCHANGED on readdir() in this case, and
fix all the programs you were talking about to handle this
case, right? This should be possible, as the kernel should know
which processes have the directory open for reading and could
mark the fds as invalid for additional readdir() calls.