Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Jun 2008 14:18:36 -0400
From:      Garrett Wollman <wollman@csail.mit.edu>
To:        Kris Kennaway <kris@freebsd.org>
Cc:        standards@freebsd.org
Subject:   mkdir -p through a dangling symlink
Message-ID:  <18537.9084.554477.556052@khavrinen.csail.mit.edu>
In-Reply-To: <48691D31.9010202@FreeBSD.org>
References:  <48691D31.9010202@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
<<On Mon, 30 Jun 2008 19:51:45 +0200, Kris Kennaway <kris@freebsd.org> said:

> Suppose you do this:
> gohan20# ln -sf /y/portbuild /var/portbuild
> gohan20# mkdir -p /var/portbuild/scripts
> mkdir: /var/portbuild: No such file or directory

> (because /y/portbuild doesn't exist yet).

> Is this the correct behaviour, or should mkdir -p be creating 
> /var/portbuild/ before failing?

This is the correct behavior.  The semantics of the -p option are
defined lexically on the arguments provided, not on the contents of
the filesystem.  See XCU page 635 lines 24488ff:

# For each dir operand that does not name an existing directory,
# effects equivalent to those caused by the following command shall
# occur:

#	mkdir -p -m $(umask -S),u+wx $(dirname dir) &&
#	mkdir [-m mode] dir

# where the -m mode option represents that option supplied to the original
# invocation of mkdir, if any.

(References are for the 2001 final published standard.)

-GAWollman




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?18537.9084.554477.556052>