Subject: Re: mkdir with trailing / (patch proposed)
To: Wolfgang Rupprecht <wolfgang+gnus20020428T160900@wsrcc.com>
From: Rick Kelly <firstname.lastname@example.org>
Date: 04/28/2002 17:59:02
Wolfgang Rupprecht said:
>I think they are talking about mkdir(2) not mkdir(1).
> ret = mkdir("//tmp//bar//", 0777);
> ret = mkdir("/tmp/bar2", 0777);
>The first fails in -current with a "mkdir 1: No such file or
>directory" and the second succeeds.
That would explain this code in mkdir(1):
/* Remove trailing slashes, per POSIX. */
slash = strrchr(*argv, '\0');
while (--slash > *argv && *slash == '/')
*slash = '\0';
On the other hand, at least up as far as System 3 UNIX, there was no
mkdir(2). That function was performed by mknod(2), which seems to just
gamely try to create whatever is passed to it or return an error. Since
System 3 didn't support "mkdir -p", mkdir(1) just has a simple loop that
avoids extra "/" characters.
Rick Kelly email@example.com www.rmkhome.com