Subject: Re: mkdir with trailing / (patch proposed)
To: NetBSD Userlevel Technical Discussion List <tech-userlevel@NetBSD.ORG>
From: Greg A. Woods <>
List: tech-userlevel
Date: 04/28/2002 19:17:35
[ On Sunday, April 28, 2002 at 22:15:20 (+0200), Martin Husemann wrote: ]
> Subject: Re: mkdir with trailing / (patch proposed)
> > I've heard POSIX say pathname _may_ have trailing slash,
> I think it says (from memory):
>  - anywhere a slash is allowed multiple ones are allowed too and don't
>    change the semantics
>  - path names may have trailing slashes, which don't alter the semantics
> But I have no copy right now to check.

I can quote draft 11.2 of IEEE POSIX-1003.2, which says much the same:  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.  Multiple
 successive slashes are considered to be the same as one slash.  A
 pathname that begins with two successive slashes may be interpreted in an
 implementation-defined manner, although more than two leading slashes
 shall be treated as a single slash.  The interpretation of the pathname
 is described in pathname resolution in  [POSIX.1 {8}]

(SuSv2 says essentially exactly the same thing, almost word-for-word.)

Which of course means any POSIX-1003.2 conforming application has every
right to expect that when running on a POSIX-1003.1 compliant system it
may express a directory pathname with one or more a trailing slashes
(and indeed use multiple successive slashes anywhere a pathname
component separator is used, though it should be careful to use only
one, or more than two, leading slashes).  That goes for mkdir(2),
opendir() or any other system call accepting a pathname and which allows
directory names, as well as of course any standard user-level utility.

								Greg A. Woods

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