Subject: Re: mkdir with trailing / (patch proposed)
To: Olaf Seibert <email@example.com>
From: Bill Studenmund <firstname.lastname@example.org>
Date: 04/30/2002 12:23:47
On Tue, 30 Apr 2002, Olaf Seibert wrote:
> On Mon 29 Apr 2002 at 15:06:07 -0400, Greg A. Woods wrote:
> > Besides this "bug" exists very deep in the core of the NetBSD kernel --
> > it just manifests itself most obviously and most frequently with
> > mkdir(2). See for example the need to avoid it as implemented in
> > /usr/src/bin/rmdir/rmdir.c too. Obviously with rmdir(2) there can be no
> > mistake that the caller expects the pathname to refer to an existing
> > directory.
I have no idea why the code in rmdir.c is there; it is not needed with our
current implementation. Unfortunatly the CVS server is down, so I can't
tell how long that code's been there.
> Aha, that makes a difference indeed. I was assuming an implementation
> where trailing slashes were being processed only after verifying that
> the pathname so far was actually a directory. Which seems reasonable to
> me. So I ought to check how it is actually done.
It won't make a difference for our code. Look at how REQUIREDIR is used in
vfs_lookup.c. If we see '/'s after a component, we swallow them & require
that component be an existing directory. This method works fine except for
when we're at the last component and it's either a file or a to-be-created