To what can I set the umask variable to produce files with mode 111?
A 'umask 555' produces a '222' mode file and 'umask 666' produces a
'000' mode file.
Excerpt from anserbook:
"To determine the umask value you want to set, subtract the value of
the permissions you want from 666 (for a file) or 777 (for a
directory). The remainder is the value to use with the umask command.
For example, suppose you want to change the default mode for files to
644 (rw-r--r--). The difference between 666 and 644 is 022, which is
the value you would use as an argument to the umask command."
I'll include two received mail messages that will summaries all the
The mode of a file is determined by two variables: the umask and the
3rd parameter to open (second parameter to creat()).
Generally, all programs use open(....., 0666) or creat(..., 0666) and
so do the fopen() and ilk library calls. That is ebcause typically
you don't create executable files.
The umask 0666 does create mode 0111 directories (these are typically
created with mkdirpath, 0777)
So it is not possible to set the umask such that all files created
will have mode 0111, only files created by ld will have a mode 0111)
The way umask works is
file protection = (proposed protection) & !(umask) so if one
specifies mode 777 in an open/create, and the umask is 666, then the
result is 777 & !666 = 777 & 111 = 111. The default "proposed
protection" when no argument is specified to open() is "666", not
"777". So with a umask of 666, that yields a file with 000 as its
protection. Directories will come up mode 111.
If you can't modify the file creation code to open with mode 777, then
you need to do an explicit "chmod 111 file" after the fact.
Thanks to *
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:47 CDT