Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/u/umask.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/u/umask.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/u/umask.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/u/umask.html on line 8

umask()

Set the file-mode creation mask for the process

Synopsis:

#include <sys/types.h>
#include <sys/stat.h>

mode_t umask( mode_t cmask );

Arguments:

cmask
The new file-mode creation mask; that is, the permissions that you don't want set when the process creates a file. The mask is a combination of these bits:
Owner Group Others Permission
S_IRUSR S_IRGRP S_IROTH Read
S_IRWXU S_IRWXG S_IRWXO Read, write, execute/search. A bitwise inclusive OR of the other three constants.
(S_IRWXU is OR of IRUSR, S_IWSUR and S_IXUSR.)
S_IWUSR S_IWGRP S_IWOTH Write
S_IXUSR S_IXGRP S_IXOTH Execute/search

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The umask() function sets the process's file-mode creation mask to cmask, and returns the previous value of the mask. Only the file permission bits (as defined in <sys/stat.h>) are used.

The file-mode creation mask for the process is used when you call creat(), mkdir(), mkfifo(), and open(), to turn off permission bits in the mode argument supplied. Bit positions set in cmask are cleared in the mode of the created file.

Returns:

The previous value of the file-mode creation mask.

Examples:

/*
 * Set the umask to RW for owner,group; R for other
 */
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>

int main( void )
  {
    mode_t omask;
    mode_t nmask;

    nmask = S_IRUSR | S_IWUSR | /* owner read write */
            S_IRGRP | S_IWGRP | /* group read write */
            S_IROTH;            /* other read */
    omask = umask( nmask );
    printf( "Mask changed from %o to %o\n",
             omask, nmask );
    return EXIT_SUCCESS;
  }

Classification:

POSIX 1003.1

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

chmod(), creat(), mkdir(), mkfifo(), open(), stat()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/u/umask.html on line 231

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/u/umask.html on line 231