Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ chmod(2) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                 chmod(2)



        _________________________________________________________________
        chmod                                                 System Call
        Change mode of file.
        _________________________________________________________________


        SYNTAX

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

        int   chmod  (path, mode)
        char *          path;
        int             mode;


        PARAMETERS

        path           Address of a pathname.


        mode           File's new mode.


        DESCRIPTION

        <Path> points to a pathname naming a file of type ordinary,
        directory, FIFO, block special, character special, or symbolic
        link.  If <path> refers to a symbolic link, the target of the
        symbolic link is handled, not the symbolic link.  The file must
        reside on a file system device mounted read-write.  Chmod sets
        the protection rights, sticky bit, set-user-id bit, and set-
        group-id bit of the file's mode (st_mode) according to <mode>.

        Values of <mode> are constructed by or-ing one or more of the
        following flags:




              S_ISUID         04000   Set user id on execution.
              S_ISGID         02000   Set group id on execution.
                                      If the (S_IEXEC >> 3) bit is not set
                                      and the file is an ordinary file, then
                                      this bit enables mandtory record locking
                                      for the file.
              S_ISVTX         01000   Sticky bit.



              S_IREAD         00400   Read by owner.



        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                                 chmod(2)



              S_IWRITE        00200   Write by owner.
              S_IEXEC         00100   Execute (search, if a directory)
                                      by owner.



              (S_IREAD  >> 3) 00040   Read by group.
              (S_IWRITE >> 3) 00020   Write by group.
              (S_IEXEC  >> 3) 00010   Execute (search) by group.



              (S_IREAD  >> 6) 00004   Read by others.
              (S_IWRITE >> 6) 00002   Write by others.
              (S_IEXEC  >> 6) 00001   Execute (search) by others.



        For each flag set in <mode>, the corresponding attribute bit or
        protection right is set.  The other attribute bits and protection
        rights are cleared.  If the calling process attempts to set the
        sticky bit or the set-group-id bit but does not meet the
        requirements for doing so (see access control), that bit is
        cleared, but the process is not notified of the failed attempt.
        One of the access requirements to perform this call (the
        effective user id of the process must be superuser or match the
        file's user id) coincides with the access needed to set the set-
        user-id bit, hence the process may always set that bit if it
        chooses.

        The time of last change to the file's attributes (st_ctime) is
        set to the current time.

        If chmod fails, the file's attributes remain unchanged.


        ACCESS CONTROL

        The effective user id of the calling process must be superuser or
        match the user id of the file.

        The process's effective user id must be superuser to set the
        sticky bit.

        To set the set-group-id bit, either

        *    the process's effective user id must be superuser,

        *    the process's effective user id must match the user id of
             the file and the process's effective group id must match the
             file's group id.



        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)





                                                                 chmod(2)



        Failure to meet the requirements for setting one of these bits
        does not produce an error.  Note that meeting the first access
        requirement is sufficient to allow a process to set the set-
        user-id bit.

        The process must have permission to resolve <path>.


        RETURN VALUE

        0              The file's mode was successfully changed.


        -1             An error occurred.  Errno is set to indicate the
                       error.


        EXCEPTIONS

        Errno may be set to one of the following error codes:


        EROFS          The named file resides on a file system device
                       mounted read-only.


        EPERM          The file's user id does not match yours, and you
                       are not the superuser.


        ENOENT         The file the pathname resolved to does not exist.


        ENOENT         A non-terminal component of the pathname does not
                       exist.


        ENOTDIR        A non-terminal component of the pathname was not a
                       directory or symbolic link.


        ENAMETOOLONG   The pathname exceeds the length limit for
                       pathnames.


        ENAMETOOLONG   A component of the pathname exceeds the length
                       limit for filenames.


        ENOMEM         There are not enough system resources to resolve
                       the pathname or to expand a symbolic link.



        DG/UX 4.00                                                 Page 3
               Licensed material--property of copyright holder(s)





                                                                 chmod(2)



        ELOOP          The number of symbolic links encountered during
                       pathname resolution exceeded MAXSYMLINKS.  A
                       symbolic link cycle is suspected.


        EPERM          The pathname contains a character not in the
                       allowed character set.


        EFAULT         The pathname does not completely reside in the
                       process's address space or the pathname does not
                       terminate in the process's address space.


        SEE ALSO

        The related manual sections:  chmod(1),
        chown(2), creat(2), fchmod(2), fchown(2), fcntl(2), fstat(2),
        mknod(2), open(2), read(2), stat(2), write(2).



































        DG/UX 4.00                                                 Page 4
               Licensed material--property of copyright holder(s)



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