HPlogo MPE/iX Developer's Kit Reference Manual Volume I: HP 3000 MPE/iX Computer Systems > Chapter 4  POSIX/iX Library Function Descriptions

umask

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Sets a process's file mode creation mask.

Syntax

   #include <sys/types.h>

   #include <sys/stat.h>

   mode_t umask (mode_t cmask);

Parameters

cmask

A bit map specifying a creation mask. Bits that are not access permission bits must be set to zero or an error occurs.

Return Values

0

Success. This is the first time umask() has been invoked by the calling process. There is no previous valid file creation mask.

-1

An error occurred, and errno is set to indicate the error condition.

Any other value

Success. The previous file creation mask of the calling process.

Description

The umask() function sets the calling process's file mode creation mask to the mask specified in the object of type mode_t passed in cmask and returns the previous value of the mask.

Only the file permission bits (defined in <sys/stat.h>) of cmask are used. Bits of cmask that are not file permission bits must contain zeros or an error occurs.

The process's file mode creation mask is used during open(), create(), and mkdir() calls to turn off permission bits in the mode parameter supplied. Bit positions that are set in cmask are cleared in the mode of the created file.

Implementation Considerations

Refer to the EIMPL error description below.

The first time umask() is invoked by a process, zero is returned to indicate that the previous file creation mask was not initialized.

Errors

If an error occurs, errno is set to the following value:

EIMPLCAUSEBits of cmask that are not file permission bits do not contain zeros.
 ACTIONMake sure that bits that are not file permission bits contain zeros.

See Also

chmod(), creat(), mkdir(), open(), <sys/stat.h>, POSIX.1 (Section 5.3.3)

Feedback to webmaster