Subject: Re: Linux emulation and mkdir with trailing /
To: NetBSD Kernel Technical Discussion List <tech-kern@netbsd.org>
From: Dan Riley <dsr@mail.lns.cornell.edu>
List: tech-kern
Date: 09/29/2000 21:52:24
several days back, woods@weird.com (Greg A. Woods) wrote:
> [ On , September 25, 2000 at 16:21:56 (-0400), Dan Riley wrote: ]
> > Subject: Re: Linux emulation and mkdir with trailing /
> >
> > The language appears to be the same in 1003.2-1992 and 1003.1-1996
> > (ISO/IEC 9945-1:1996)--just the section numbers are different.
> > 
> > >  2.2.2.102  pathname:  A string that is used to identify a file.
> > >  
> > >  A pathname consists of, at most, {PATH_MAX} bytes, including the
> > >  terminating null character.  It has an optional beginning slash, followed
> > >  by zero or more filenames separated by slashes.  If the pathname refers
> > >  to a directory, it may also have one or more trailing slashes.
> 
> OK, so to stray a bit more off-topic, why does SunOS-5.6, apparently in
> conformance with both 1003.2-1992 and 1003.1-1988, do this?
> 
> 	17:13 [154] $ ls -l /usr/bin/sh
> 	-r-xr-xr-x   2 bin      root       88620 Jul 16  1997 /usr/bin/sh
> 	17:18 [155] $ ls -l /usr/bin/sh/                                   
> 	-r-xr-xr-x   2 bin      root       88620 Jul 16  1997 /usr/bin/sh/
> 	17:18 [156] $ sh
> 	$ ls -l /usr/bin/sh
> 	-r-xr-xr-x   2 bin      root       88620 Jul 16  1997 /usr/bin/sh
> 	$ ls -l /usr/bin/sh/
> 	-r-xr-xr-x   2 bin      root       88620 Jul 16  1997 /usr/bin/sh/

Dunno.  However, I personally would not recommend Solaris as a model
of POSIX compliance--Sun often bends over backwards in the name of
backwards compatibility, requiring various hoops be jumped through to
achieve POSIX compliance (both parenthetically and illustratively, I'd
note that you should be using /usr/xpg4/bin/sh and /usr/xpg4/bin/ls
(they do have the same behavior)).  I'd also note that POSIX doesn't
say what should be done with trailing slashes on filenames, so it
presumably falls within the real of implementation defined
behavior--it merely says that a trailing slash on a directory is
legal, not that a trailing slash on a filename must be forbidden.
Finally, let me offer up the .1-1990, .2-1992, OpenGroup UNIX98(?)
branded operating-system-formerly-known-as-DEC-OSF/1:

dsr_lnscu4% /usr/bin/posix/sh
$ uname -a
OSF1 lnscu4.lns.cornell.edu V4.0 1229 alpha alpha
$ /usr/bin/ls -l /usr/bin/sh
-rwxr-xr-x   2 bin      bin       131072 Apr 12  1999 /usr/bin/sh
$ /usr/bin/ls -l /usr/bin/sh/
/usr/bin/sh/ not found

I've completely lost track of the roots of this thread, but that
behavior makes more sense to me than Solaris's, and is at least as
POSIX compliant, but arguably either is allowed.  What clearly isn't
allowed is disallowing trailing slashes on directories.
-- 
Dan Riley                                         dsr@mail.lns.cornell.edu
Wilson Lab, Cornell University      <URL:http://www.lns.cornell.edu/~dsr/>
    "History teaches us that days like this are best spent in bed"