Subject: Re: Linux emulation and mkdir with trailing /
To: Warner Losh <imp@village.org>
From: Bill Sommerfeld <sommerfeld@orchard.arlington.ma.us>
List: tech-kern
Date: 09/23/2000 19:06:53
> FreeBSD succeeds with mkdir /tmp/foo/. So does NetBSD -current from
> the second week in august.
because the mkdir command trims the trailing / before passing the
pathname to the syscall:
% ktrace mkdir /tmp/zzz/
% kdump | grep NAMI
23330 ktrace NAMI "/usr/local/bin/mkdir"
23330 ktrace NAMI "/usr/bin/mkdir"
23330 ktrace NAMI "/bin/mkdir"
23330 mkdir NAMI "/tmp/zzz"
23330 mkdir NAMI "/tmp/zzz"
which is because of the following code in mkdir.c:
/* Remove trailing slashes, per POSIX. */
slash = strrchr(*argv, '\0');
while (--slash > *argv && *slash == '/')
*slash = '\0';
- Bill