Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fchmod(2) — CX/UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chown(2)

mknod(2)



chmod(2)                                                 chmod(2)



NAME
     chmod, fchmod - change mode of file

SYNOPSIS
     #include <sys/types.h>
     #include <sys/stat.h>
     int chmod (path, mode)
     char *path;
     modet mode;

SYNOPSIS (4.2BSD)
     #include <sys/types.h>
     #include <sys/stat.h>
     int fchmod (fd, mode)
     int fd;
     modet mode;

DESCRIPTION
     chmod sets the access permission portion of a file's mode
     according to the bit pattern contained in mode.  Path points
     to the file's path name.  Using fchmod, the file may be
     specified by descriptor fd.

     Access permission bits are interpreted as follows:

          S_ISUID        Set user ID on execution.

          S_ISGID        Set group ID on execution.

          S_ISVTX        Save text image after execution.

          S_IRUSR        Read by owner.

          S_IWUSR        Write by owner.

          S_IXUSR        Execute (search if a directory) by
                         owner.

          S_IRGRP        Read by group.

          S_IWGRP        Write by group.

          S_IXGRP        Execute (search) by group.

          S_IROTH        Read by others (i.e., by anyone else).

          S_IWOTH        Write by others.

          S_IXOTH        Execute (search) by others.

          S_ENFMT        Record locking enforced.




Page 1                        CX/UX Programmer's Reference Manual





chmod(2)                                                 chmod(2)



     The effective user ID of the process must match the owner of
     the file or be super-user to change the mode of a file.

     If the effective user ID of the process is not super-user,
     the effective label of the calling process (current security
     label) must match the label of the file identically. (B1
     only)

     If the effective user ID of the process is not super-user or
     the user does not have the ACC_SET_VEC effective access vec-
     tor (if configured), mode bit S_ISVTX (save text image on
     execution) is cleared.

     If the effective user ID of the process is not super-user
     and the effective group ID of the process does not match the
     group ID of the file, mode bit S_ISGID (set group ID on exe-
     cution) is cleared.

     If an executable file is prepared for sharing then mode bit
     S_ISVTX prevents the system from abandoning the swap-space
     image of the program-text portion of the file when its last
     user terminates.  Thus, when the next user of the file exe-
     cutes it, the text need not be read from the file system but
     can simply be swapped in, saving time.

     For ordinary files, if the mode bit SENFMT (record locking
     enforced) is set and the mode bit SIXGRP (execute or search
     by group) is not set, enforced record locking is enabled.
     This will affect future calls to open(2), creat(2), read(2),
     and write(2) routines on this file.  If these conditions are
     not met, all locks on the file will be advisory (see
     fcntl(2)).

     chmod will fail and the file mode will be unchanged if one
     or more of the following are true:

     [EACCES]       Search permission is denied on a component of
                    the path prefix.

     [EFAULT]       Path points outside the allocated address
                    space of the process.

     [ENAMETOOLONG] The path argument exceeds {PATHMAX} in
                    length, or a pathname component is longer
                    than {NAMEMAX}  (see pathconf(2)).

     [ENOTDIR]      A component of the path prefix is not a
                    directory.

     [ENOENT]       The named file does not exist, or the path
                    argument points to an empty string.




Page 2                        CX/UX Programmer's Reference Manual





chmod(2)                                                 chmod(2)



     [EPERM]        The effective user ID does not match the
                    owner of the file and the effective user ID
                    is not super-user, or the current effective
                    security label does not match the classifica-
                    tion of the file and the effective user ID is
                    not super-user. (B1 only)

     [EROFS]        The named file resides on a read-only file
                    system.

     fchmod will fail and the file mode will be unchanged if one
     or more of the following are true:

     [EBADF]        The descriptor is not valid.

     [EINVAL]       Fd refers to a socket, not to a file.

     [EROFS]        The named file resides on a read-only file
                    system.

RETURN VALUE
     Upon successful completion, a value of 0 is returned.  Oth-
     erwise, a value of -1 is returned and errno is set to indi-
     cate the error.

NOTE
     The chmod function is defined in the 88open Binary and
     Object Compatibility Standards (BCS/OCS) for use in BCS/OCS
     compliant applications.  The fchmod function is defined in
     the 88open BCS/OCS Networking Supplements (BCSNS/OCSNS) for
     use in BCS/OCS compliant networking applications.
     OCS/OCSNS-defined functions may be accessed by passing OCS
     options to cc(1) and ld(1).

SEE ALSO
     chown(2), mknod(2).



















Page 3                        CX/UX Programmer's Reference Manual



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