.SH SYNOPSIS
.nf
.B #include <sys/stat.h>
-.PP
+.P
.BI "int chmod(const char *" pathname ", mode_t " mode );
.BI "int fchmod(int " fd ", mode_t " mode );
-.PP
+.P
.BR "#include <fcntl.h>" " /* Definition of AT_* constants */"
.B #include <sys/stat.h>
-.PP
+.P
.BI "int fchmodat(int " dirfd ", const char *" pathname ", mode_t " \
mode ", int " flags );
.fi
-.PP
+.P
.RS -4
Feature Test Macro Requirements for glibc (see
.BR feature_test_macros (7)):
.RE
-.PP
+.P
.nf
.BR fchmod ():
Since glibc 2.24:
_BSD_SOURCE || _XOPEN_SOURCE >= 500
.\" || (_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED)
.fi
-.PP
+.P
.BR fchmodat ():
.nf
Since glibc 2.10:
.BR fchmod ()
changes the mode of the file referred to by the open file descriptor
.IR fd .
-.PP
+.P
The new file mode is specified in
.IR mode ,
which is a bit mask created by ORing together zero or
.TP
.BR S_IXOTH " (00001)"
execute/search by others
-.PP
+.P
The effective UID of the calling process must match the owner of the file,
or the process must be privileged (Linux: it must have the
.B CAP_FOWNER
capability).
-.PP
+.P
If the calling process is not privileged (Linux: does not have the
.B CAP_FSETID
capability), and the group of the file does not match
.B S_ISGID
bit will be turned off,
but this will not cause an error to be returned.
-.PP
+.P
As a security measure, depending on the filesystem,
the set-user-ID and set-group-ID execution bits
may be turned off if a file is written.
For the sticky bit, and for set-user-ID and set-group-ID bits on
directories, see
.BR inode (7).
-.PP
+.P
On NFS filesystems, restricting the permissions will immediately influence
already open files, because the access control is done on the server, but
open files are maintained by the client.
system call operates in exactly the same way as
.BR chmod (),
except for the differences described here.
-.PP
+.P
If the pathname given in
.I pathname
is relative, then it is interpreted relative to the directory
the calling process, as is done by
.BR chmod ()
for a relative pathname).
-.PP
+.P
If
.I pathname
is relative and
is interpreted relative to the current working
directory of the calling process (like
.BR chmod ()).
-.PP
+.P
If
.I pathname
is absolute, then
.I dirfd
is ignored.
-.PP
+.P
.I flags
can either be 0, or include the following flag:
.TP
is a symbolic link, do not dereference it:
instead operate on the link itself.
This flag is not currently implemented.
-.PP
+.P
See
.BR openat (2)
for an explanation of the need for
.SH ERRORS
Depending on the filesystem,
errors other than those listed below can be returned.
-.PP
+.P
The more general errors for
.BR chmod ()
are listed below: