bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mkdir -p and -m cannot be used together


From: Eric Blake
Subject: Re: mkdir -p and -m cannot be used together
Date: Fri, 31 Oct 2008 12:38:52 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Jon Stanley on 10/31/2008 11:20 AM:
> Trying to make a directory structure with mode 755, when your umask is
> for example 0007, doesn't produce the desired results for the parent
> directories:
> 
> address@hidden src]# ./mkdir -m 755 -p /tmp/a/b/c
> address@hidden src]# ls -lR /tmp/a
> drwxrwx--- 3 root root 4096 Oct 31 17:17 b
> drwxr-xr-x 2 root root 4096 Oct 31 17:17 c

> Is there some reason for this? I've verified this in my distros
> coreutils, as well as coreutils-6.9 (above).  I'd think this would be
> a FAQ. but I found no other references to this aberrant behavior
> anywhere :)

Thanks for the report.  However, this behavior is not aberrant.  Rather,
it is mandated by POSIX:

http://www.opengroup.org/onlinepubs/009695399/utilities/mkdir.html

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.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkkLULwACgkQ84KuGfSFAYAUWwCcDoXU92w8+dxiLI4LDvrXsVgY
FOYAn0/5ej2t0ar6KuzP8IyKPi4QK93A
=h5w5
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]