note 14811 deleted from function.mkdir by aidan
| From: | aidan@php.net | Date: | Sun, 03 Oct 2004 13:41:03 +0000 |
| Subject: | note 14811 deleted from function.mkdir by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77850@lists.php.net to get a copy of this message | ||
Note Submitter: jiblet at visi dot com
----
I just wanted to clarify why the umask isn't technically being subtracted. Suppose you want to
make sure that no file gets created with write permission for everyone. You would use the umask:
0002 (-------w-)
If you then created a directory with the following permissions:
0774 (rwxrwx--x)
subtraction would yield:
0772 (rwxrwx-w-)
which is exactly what you DIDN'T want. That's why instead, the umask is inverted then
"BITWISE AND"ed to negate the umask's bit(s) and preserve any existing bits:
775 (rwxrwxr-x) & (bitwise AND)
774 (rwxrwx--x) =
774 (rwxrwx--x)