Subject: Re: Trailing '/' to mkdir(2) revisited
To: None <giles@nemeton.com.au>
From: Ben Harris <bjh21@netbsd.org>
List: tech-kern
Date: 06/23/2003 11:10:49
In article <4997.1056333827@nemeton.com.au> you write:
>behaviour be changed, there are some arguments on consistency
>grounds that mkdir(2) should accept a trailing '/' too:
>
>1. mkdir(1) accepts a trailing '/'

This is certainly a worthwhile argument, since POSIX defines mkdir(1) in
terms of mkdir(2).

>2. rmdir(2) accepts a trailing '/'

This is a dodgy precedent for two reasons:

1: rmdir acts on an existing directory.  mkdir doesn't.
2: POSIX-2001 _might_ require that it not accept a trailing slash.

Neither is a good reason, but they should still be considered.

>The only reasons I can think of for keeping the current behaviour:
>
>(a) it's always been that way
>(b) it's more efficient

(c) POSIX requires it

Actually, that's a simplification.  Whether POSIX requires it or not is a
matter of interpretation, and it seems to be generally agreed here that this
is actually a bug in POSIX.  Someone should file a defect report.

>Note that I'm not able to offer a patch: since I have current access
>to those billions of dollars worth of SysV source that SCO is suing
>IBM about discretion is the better part of valour. :-)

Ooh.  I've got access to the Solaris sources.  Does that mean I'm exempt
from fixing bugs?  Cool!  *grin*

Footnote for the bored:  The problem with POSIX-2001 is that the definition
of pathname resolution (section 4.11) says that pathnames ending in '/' that
contain non-'/' characters are resolved as if they had '.' appended.  The
definitions of mkdir() and rmdir() don't override this, but they're
generally a bit fuzzy, and in particular the definition of the ENOENT
failure from mkdir() is pretty much meaningless.

-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/acorn26           <URL:http://www.netbsd.org/Ports/acorn26/>