chmod.2 (2010 09)

c
chmod(2) chmod(2)
If the process does not have the
OBJSUID privilege, mode bit S_ISVTX is cleared.
If the process does not have
OBJSUID privilege, 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 supplementary groups list match the group ID of
the file, mode bit S_ISGID is cleared.
If the mode bit
S_ISVTX (sticky bit) is set on a directory, files inside the directory can be renamed or
removed only by the owner of the file, the owner of the directory, or a process with the
OWNER privilege
(even if the modes of the directory would otherwise allow such an operation).
See privileges (5) for more information about privileged access on systems that support fine-grained
privileges.
RETURN VALUE
chmod() returns the following values:
0 Successful completion.
-1 Failure.
errno is set to indicate the error.
ERRORS
If
chmod() fails, the file mode is unchanged.
errno is set to one of the following values:
[EACCES] Search permission is denied on a component of the path prefix.
[EFAULT] path points outside the allocated address space of the process. The reliable
detection of this error is implementation dependent.
[EINVAL] path or fildes descriptor does not refer to an appropriate file.
[ELOOP] Too many symbolic links were encountered in translating path .
[ENAMETOOLONG]
A component of path exceeds
NAME_MAX bytes while _POSIX_NO_TRUNC
is
in effect or path exceeds
PATH_MAX bytes.
[ENOENT] A component of path or the file named by path does not exist.
[ENOTDIR] A component of the path prefix is not a directory.
[EPERM] The effective user ID does not match that of the owner of the file or the process
does not have
OWNER privilege.
[EROFS] The named file resides on a read-only file system.
If
fchmod() fails, the file mode is unchanged. errno is set to one of the following values:
[EBADF] fildes is not a valid file descriptor.
[EINVAL] path or fildes descriptor does not refer to an appropriate file.
[EPERM] The effective user ID does not match that of the owner of the file, and the
effective user ID is not that of a user with appropriate privileges.
[EPROFS] The named file resides on a read-only file system.
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
chmod(1), getacl(1), chown(2), creat(2), fcntl(2), flock(2), getacl(2), lockf(2), mknod(2), open(2), read(2),
setacl(2), truncate(2), write(2), acl(5), aclv(5), privileges(5).
STANDARDS CONFORMANCE
chmod(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1
fchmod(): AES, SVID3
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010