Open System Services System Calls Reference Manual (G06.25+, H06.03+)

chmod(2) OSS System Calls Reference Manual
NAME
chmod - Changes le 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 chmod(
const char *path,
mode_t mode);
PARAMETERS
path Species the full pathname of the le. If the path parameter refers to a symbolic
link, the chmod() function changes access permissions on the le specied by
the symbolic link.
mode Species the bit pattern that determines the access permissions.
DESCRIPTION
The chmod() function sets the access permissions of the le specied by the path parameter
according to the bit pattern specied by the mode parameter.
To change le-access permissions, either the process must have appropriate privileges or its
effective user ID must be the same as the user ID of the le 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 les owner or the directorys owner, or a process with appropriate privileges, can
remove les from the directory.
A call to the chmod() function has no effect on the le descriptor for a le that is open at the
time of the call. However, new openers of the le will be authorized by using the new access per-
missions that were specied in the call.
The mode parameter is constructed by logically ORing one or more of these symbols, which are
dened in the sys/stat.h header le:
S_ISUID Sets the processs effective user ID to the user ID of the les owner on execu-
tion.
S_ISGID Sets the processs effective group ID to the group ID of the les group on execu-
tion.
S_ISVTX For a directory, permits modication to the directory only if the effective user ID
of the process matches that of the le being accessed.
S_IRWXU Permits the les owner to read, write, and execute the le (or to search the direc-
tory).
S_IRUSR Permits the les owner to read the le.
114 Hewlett-Packard Company 527186-003