Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ umask(DOS) — System V/386 Software Development System 3.2.2b

Media Vault

Software Library

Restoration Projects

Artifacts Sought

     Name
          umask - Sets the file permission mask.

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

          int umask(pmode)
          int pmode;

     Description
          The umask function sets the file-permission mask of the
          current process to the mode specified by pmode. The file-
          permission mask is used to modify the permission setting of
          new files created by creat, open, or sopen. If a bit in the
          mask is 1, the corresponding bit in the file's requested
          permission value is set to 0 (disallowed). If a bit in the
          mask is 0, the corresponding bit is left unchanged. The
          permission setting for a new file is not set until the file
          is closed for the first time.

          The argument pmode is a constant expression containing one
          or both of the manifest constants S_IWRITE and S_IREAD,
          defined in sys/stat.h.  When both constants are given, they
          are joined with the bitwise-OR operator ( | ). The meaning
          of the pmode argument is as follows:

            Value       Meaning

            S_IWRITE    Writing not allowed (file is read only)

            S_IREAD     Reading not allowed (file is write only)

          For example, if the write bit is set in the mask, any new
          files will be read only.

     Notes
          Under DOS and OS/2, all files are readable - it is not
          possible to give write-only permission.  Therefore, setting
          the read bit with umask has no effect on the file's modes.

     Return Value
          The umask function returns the previous value of pmode.
          There is no error return.

     See Also
          chmod(DOS), creat(DOS), mkdir(DOS), open(DOS)

     Example
          #include <sys/types.h> #include <sys/stat.h> #include <io.h>
          #include <stdio.h>

          int oldmask;

          main()
           {

                  /* Create read-only files: */
                  oldmask = umask(S_IWRITE);
                  printf( "oldmask =%#x\n", oldmask );
           }

          This program uses umask to set the file-permission mask so
          that all future files will be created as read-only files. It
          also displays the old mask.

                                                (printed 6/18/89)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026