Subject: Re: Linux emulation and mkdir with trailing /
To: NetBSD Kernel Technical Discussion List <>
From: Greg A. Woods <>
List: tech-kern
Date: 09/25/2000 17:39:07
[ On Monday, September 25, 2000 at 18:52:16 (+0200), Alan Barrett wrote: ]
> Subject: Re: Linux emulation and mkdir with trailing /
> If bar is a non-directory file, why would you expect to be able to
> open "bar/" (with a trailing slash)?  What's the point of the trailing
> slash?

There's no real point -- just that it sometimes makes it easier to be
lazy in conjuring up filenames.  In this particular scenario it isn't
very easy to think of an example though....

> I expect '/' to mark directories.  My expectation is based on
> observing patterns of behaviour.  The only use I know for slashes in a
> unix-like filesystem is to mark the root of the filesystem and to
> separate components where all components (except perhaps the last) are
> directory names.  In my limited experience, I have never encountered
> any use for a trailing slash after a non-directory file name, nor seen
> anybody deliberately put trailing slashes after a non-directory file
> name.

I agree that there are certain expectations about what a trailing slash
indicates.  Whether these expectations have been caused by the *BSD
behaviour, or the other way around perhaps, I cannot say for sure.

I have vague memories of wondering why "ls -l /bin/sh/" worked on
traditional system (up to and including SunOS-5.6 it seems!).  I seem to
recall the explanation given to me at the time being much the same as
the one I quoted from John Lions....

Perhaps it's just a learned expectation that "mv foo bar/" will rename
"foo" to "bar" if there's no pre-existing directory "bar", but I
personally am not surprised in any way by that happening.

> I might not have non-BSD historical precedent on my side, but I surely
> have the principle of least astonishment on my side.  Allowing "bar/"
> to refer to a non-directory file is very astonishing to people
> familiar with the way '/' is usually used in filenames.

The only real issue I have is with the inconsistency of behaviour
between systems, though I'm only really concerned about "modern"
systems, not antiques, even if those antiques were the defining

I.e. if many other systems are going to continue to always strip
trailing slashes then NetBSD should too.

However if systems are growing into compliance with what POSIX would
seem to say by implication, then NetBSD should continue to interpret
trailing slashes as it seems to do now:

	$ ls -l /bin/sh
	-r-xr-xr-x  1 bin  bin  360448 May 11  1998 /bin/sh
	$ ls -l /bin/sh/
	ls: /bin/sh/: Not a directory

In the latter case the only thing I would ask is that this behaviour not
be described as ``"foo/" is interpreted as "foo/."'' especially in any
written documentation since that's not really true except in the most
vague and generic sense.  The POSIX wording is much more concise and

							Greg A. Woods

+1 416 218-0098      VE3TCP      <>      <robohack!woods>
Planix, Inc. <>; Secrets of the Weird <>