Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chown(2)

fcntl(2)

getgroups(2)

mkdir(2)

mkfifo(2)

mknod(2)

open(2)

read(2)

setgroups(2)

truncate(2)

write(2)

chmod(1)

CHMOD(2)                             SysV                             CHMOD(2)



NAME
     chmod, fchmod - Changes file access permissions

SYNOPSIS
     #include <sys/types.h>

     #include <sys/stat.h>

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

     int fchmod (filedes,  mode )
     int filedes;
     mode_t mode );

DESCRIPTION
     The chmod function sets the access permissions of the file specified by
     the path argument according to the bit pattern specified by the mode
     argument.

     If the effective user ID of the calling process matches the file owner of
     the calling process has superuser privileges, chmod changes the S_ISUID,
     S_ISGID, and the file permission bits, as described in <sys/stat.h>, of
     the named file from the corresponding bits in the mode argument.  If the
     path argument refers to a symbolic link, chmod changes access permissions
     on the file specified by the symbolic link.

     If the calling process does not have superuser privileges, and if the
     group ID of the file does not match the current process' effective group
     ID or one of the supplementary group ID and if the file is a regular
     file, bit S_ISGID (set group ID on execution) in the file's mode is
     cleared upon successful return from chmod or fchmod.

     The fchmod function sets the access permissions of an open file pointed
     to by the filedes argument according to the bit pattern specified by the
     mode argument.

     To change file access permissions, the process must have the same
     effective user ID as the owner of the file or the process must have
     superuser privileges.

     Upon successful completion, the chmod and fchmod functions mark the
     st_ctime field of the file for update.

DIAGNOSTICS
     Upon successful completion, the chmod and fchmod functions return a value
     of 0 (zero). If the chmod or fchmod function fails, a value of -1 is
     returned, no change to the mode occurs, and errno is set to indicate the
     error.

ERRORS
     If the chmod function fails, the file permissions remain unchanged and
     errno is set to one of the following values:

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

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

     [ENOENT]  A symbolic link was named, but the file to which it refers does
               not exist.

     [EACCES]  A component of the path argument has search permission denied.

     [EPERM]   The effective user ID does not match the ID of the owner of the
               file or the owner does not have superuser privilege.

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

     [EFAULT]  The path argument points to a location outside of the allocated
               address space of the process.

     [ENAMETOOLONG]
               The length of the path argument exceeds PATH_MAX or a pathname
               component is longer than NAME_MAX.

     [EINTR]   A signal was caught during execution of the system call.

     If the fchmod() function fails, the file permissions remain unchanged and
     errno is be set to one of the following values:

     [EBADF]   The file descriptor filedes is not valid.

     [EROFS]   The file referred to by filedes resides on a read-only file
               system.

     [EPERM]   The effective user ID does not match the ID of the owner of the
               file, and the calling process does not have

     [EINTR]   A signal was caught during execution of the system call.

SEE ALSO
     chown(2), fcntl(2), getgroups(2), mkdir(2), mkfifo(2), mknod(2), open(2),
     read(2) setgroups(2) truncate(2) write(2) </sys/stat.h> </sys/types.h>
     chmod(1)

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