mkdir -p through a dangling symlink
wollman at csail.mit.edu
Mon Jun 30 18:41:07 UTC 2008
<<On Mon, 30 Jun 2008 19:51:45 +0200, Kris Kennaway <kris at 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
# 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.)
More information about the freebsd-standards