CHMOD(2) — HP-UX
NAME
chmod, fchmod − change access mode of file
SYNOPSIS
int chmod (path, mode)
char ∗path;
int mode; fchmod (fd, mode)
int fd, mode;
DESCRIPTION
Path points to a path name naming a file. Fd is a descriptor for a file. Chmod sets the access permission portion of the file’s mode according to the bit pattern contained in mode.
Access permission bits are interpreted as follows:
04000 Set user ID on execution
02000 Set group ID on execution
02000 Set file locking mode to enforced (shared with set group ID on execution bit)
01000 Save text image after execution
00400 Read by owner
00200 Write by owner
00100 Execute (or search if a directory) by owner
00070 Read, write, execute (search) by group
00007 Read, write, execute (search) by others
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, mode bit 01000 (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 and none of the group IDs in the access group list match the group ID of the file, mode bit 02000 (set group ID on execution and enforced file locking mode) is cleared.
The set group ID on execution bit is also used to cause file-locking mode (see lockf(2) and fcntl(2)) to be enforced. Files with this bit set that are not group-executable will have enforcement set. This may affect future calls to open(2), creat(2), read(2), and write(2) on this file.
If an executable file is prepared for sharing then mode bit 01000 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 executes it, the text need not be read from the file system but can simply be swapped in, saving time.
RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a value of −1 is returned and errno is set to indicate the error.
ERRORS
Chmod will fail and the file mode will be unchanged if one or more of the following are true:
[ENOTDIR] A component of the path prefix is not a directory.
[ENOENT] The named file does not exist.
[EACCES] Search permission is denied on a component of the path prefix.
[EPERM] The effective user ID does not match the owner of the file and the effective user ID is not super-user.
[EROFS] The named file resides on a read-only file system.
[EFAULT] Path points outside the allocated address space of the process. The reliable detection of this error will be implementation dependent.
[ENOENT] A component of the path does not exist.
[ENAMETOOLONG] The named file exceeds MAXPATHLEN characters.
[ELOOP] Too many symbolic links were encountered in translating the path name.
DEPENDENCIES
Series 300 Diskless
If the file is a directory, the access permission bit 04000 indicates a hidden directory (see cdf(4)).
AUTHOR
Chmod was developed by AT&T, the University of California, Berkeley, and HP.
Fchmod was developed by the University of California, Berkeley.
SEE ALSO
cdf(4), chmod(1), chown(2), creat(2), fcntl(2), lockf(2), open(2), mknod(2), read(2), write(2).
Hewlett-Packard Company — May 11, 2021