Why is umask a $perms AND NOT $mask and not simply $perms AND $mask instead?
In other words why is there a NOT in there; why doesn't wasn't it implemented as an and mask?
As an example, 666 and 700, to give 600?
The key is that the umask ("user mask") is intended to keep processes from creating files with permission bits they're not supposed to use. If you look at it from that perspective, the concept of a umask may make more sense; in particular, the common umask of 022 prevents processes from creating files that are writable by group or world, which is usually what you want.
|show 3 more comments|
The input value is octal which may require a leading 0 to be parsed correctly. As the owner mask is almost always 0 the mask can be entered with three digits. As an AND mask, it would need to be entered as 0755 or 0750.
Defining it as an AND NOT operation makes it safer if characters are missed in the mask. If umask was and AND operation
EDIT: From another perspective, the mask is a list of the bits you want masked off. Therefore you want masks like