Talk:Umask
From Wikipedia, the free encyclopedia
This doesn't look like a bitwise AND to me; more like a subtraction. 777 & 177 makes 177, not 600, wherease 777-177 does make 600. The unix man pages for umask(1) also refer to subtraction rather than ANDing.
- That sounds right to me. With my umask set to 002, if I create a new file or directory it has its permissions set to 0775, which of course is 777-002. On the other hand, the man page for the C function (umask(2)) that I have says "umask sets the umask to mask & 0777." I don't know enough on this subject to make an edit, though. Does anyone have an idea of how that bit should be written? It's somewhat confusing as it is. --Dirk Gently 03:48, 28 July 2005 (UTC)
-
- Doesn't the current notation (^ ~) indicate the XOR of the complement of the argument? I think that's incorrect, and at least, could be simplified greatly to say simply the complement, (~) of the argument (although it should probably be explicitly stated as such for clarity). It comes out like the following:
- ~1778 = 6008
- --Max Magee
-
-
- This is correct. ^ = XOR. I'm the editor who did those major changes back in 17 August 2005. Note it was a simple AND before, and totally wrong. The XOR with the argument itself (not with the complement!) also works. Prove me wrong. A ^ B in this case will give the same result as in A AND ( ~ B). -andy 80.129.114.15 04:05, 14 January 2007 (UTC)
-
-
-
- 666 AND NOT 174 = 602 = WTF?
-
It is correct that 666 AND NOT 174 = 602. It is also NOT true in general that A ^ B = A AND ~B. In fact, an XOR can be reduced to (A AND NOT B) OR (B AND NOT A). Using the standard notation for boolean algebra ( + for OR and . for AND) we can define the XOR by the following:
A^B = (A+B)(~(AB)) and reduction gives: = A(~AB) + B(~AB) = A(~A + ~B) + B(~A + ~B) = ~AA + ~BA + ~AB + ~BB = ~BA + ~AB
Using ~ instead of a bar necesitates that it has a higher precedent than '.' or '+' . John Pearcey 83.147.135.251 10:16, 9 April 2007 (UTC)
[edit] Clarity
This article seems to be a little hazy and unclear to me. What exactly is umask? From what I can understand, it's 'default permissions'. In other words, a way of automatically setting chmod permissions, so if umask is 777 for my application, all files created from my application will have 777 as the default chmod values. Is this right? The article doesn't exactly make that clear Grayda 00:35, 16 November 2007 (UTC)
- Not quite. You've got the idea right but the calculations wrong. Putting aside the binary logic and focusing just on numerical permissions, you have an octal number to which you add your permissions, effectively making a bitfield. For permissions, 4 means read, 2 means write, and 1 means execute. Add these together to get one permission value. For example, having read and write access would give you 6, or having just read and execute access would give you 5. Place three of these values together to get the numerical permissions, and prefix it with a 0 to explicitly specify that you're using an octal number. The permission set giving the owner r/w/x, the group r/w, and others x, would be 0761.
- Now to actually answer your question. The umask is really what rights not to grant. If your umask is set to 0100, the permissions on created files will be 0677. Similarly, using a umask of 0133 will make the permissions on created files 0644. Hope this helps! Dandaman32 (talk) 03:41, 21 November 2007 (UTC)

