Open System Services System Calls Reference Manual (G06.28+)

fchmod(2) OSS System Calls Reference Manual
NAME
fchmod - Changes file-access permissions
LIBRARY
G-series native Guardian processes: system library
G-series native OSS processes: system library
H-series native Guardian processes: implicit libraries
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <sys/stat.h>
int fchmod(
int filedes,
mode_t mode);
PARAMETERS
filedes Species the file descriptor of an open file.
mode Species the bit pattern that determines the access permissions.
DESCRIPTION
The fchmod( ) function sets the access permissions of a file pointed to by the filedes parameter
according to the bit pattern specified by the mode parameter.
To change file-access permissions, either the process must have appropriate privileges or its
effective user ID must be the same as the user ID of the file owner.
If the S_ISVTX bit is on for a directory, only processes with an effective user ID equal to the
user ID of the file’s owner or the directory’s owner, or a process with appropriate privileges, can
remove files from the directory.
A call to the fchmod() function has no effect on the file descriptor for a file that is open at the
time of the call. However, new openers of the file will be authorized by using the new access per-
missions that were specified in the call.
The mode parameter is constructed by logically ORing one or more of these symbols, which are
defined in the sys/stat.h header file:
S_ISUID Sets the process’s effective user ID to the user ID of the file’s owner on execu-
tion.
S_ISGID Sets the process’s effective group ID to the group ID of the files group on execu-
tion.
S_ISVTX For a directory, permits modification to the directory only if the effective user ID
of the process matches that of the file being accessed.
S_IRWXU Permits the file’s owner to read, write, and execute the file (or to search the direc-
tory).
S_IRUSR Permits the file’s owner to read the file.
S_IWUSR Permits the file’s owner to write to the file.
32 Hewlett-Packard Company 527186-005