Subject: Re: Linux emulation and mkdir with trailing /
To: NetBSD Kernel Technical Discussion List <tech-kern@netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: tech-kern
Date: 09/29/2000 11:38:48
[ On Friday, September 29, 2000 at 10:37:48 (+0200), Olaf Seibert wrote: ]
> Subject: Re: Linux emulation and mkdir with trailing /
>
> On Tue 26 Sep 2000 at 08:48:58 +0200, Lucio De Re wrote:
> > The same applies to "cp foo bar/": if the semantics of the trailing
> > "/" are dropped, then the safeguard in the above is lost and totally
> > irrecoverably so.  
> 
> You can always do cp foo bar/. . Slightly more typing work, but it makes
> explicit what you want.

Exactly!  The point (interpretations of POSIX-1003.1 aside) is to make
things flexible and be damned about the amount of rope you're carrying.
It's sort of like the argument against C pointers -- if you take away
the dangers then you've damn near taken away the entire feature!  (It's
not nearly so bad in this case, of course.)

If the authors of the Unix namei() had wanted to avoid troubles they
probably wouldn't even have allowed sloppy programmers to get away with
multiple slashes, let alone trailing slashes.  However by eliminating
*all* unnecessary slashes, including trailing slashes, it is made clear
exactly which directory entry is being acted upon and only then will an
error become apparent if the entry points to a file of the wrong type.

I think BSD's authors (and apparently POSIX in their wake) made a
mistake in catering to these unnecessary and incorrect user
expectations.  If users can't figure out how the filesystem works at
even this trivial level then they shouldn't be getting that close to it
because it has some sharp edges (that are useful for things sharp edges
are generally useful for).  Let their GUI protect them!  If they mean to
specify the directory then let them or their agents type one more
trailing character too (i.e. a ".").

(BTW, NFS is not Unix, and it does not honour Unix filesystem semantics
in the first place, so I don't think it has any real place in this
discussion.)

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>