CHMOD(2-POSIX) RISC/os Reference Manual CHMOD(2-POSIX)
NAME
chmod - change mode of file
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
int chmod (path, mode)
char *path;
modet mode;
DESCRIPTION
chmod sets the access permission portion of the mode of the
named path according to the bit pattern contained in mode.
Access permission bits are interpreted as described in
<sys/stat.h> (see stat(5)).
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,
and the file is not a directory, the S_ISVTX bit is cleared.
If the effective user ID of the process is not super-user
and the group ID of the file does not match the effective
group ID of the process or one of its supplementary group
IDs, and the file is a regular file, the S_ISGID bit is
cleared.
If a 410 executable file has the S_ISVTX bit set, the
operating system will not delete the program text from the
swap area when the last user process terminates. If a 413
executable file has the S_ISVTX bit set, the operating sys-
tem will not delete the program text from memory when the
last user process terminates. In either case, if the
S_ISVTX bit is set the text will already be available
(either in a swap area or in memory) when the next user of
the file executes it, thus making execution faster.
If the S_ISGID mode bit is set and the S_IXGRP mode bit is
not set, mandatory file/record locking will exist on a regu-
lar file. This may effect future calls to open(2),
creat(2), read(2), and write(2) on this file.
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.
Printed 1/15/91 Page 1
CHMOD(2-POSIX) RISC/os Reference Manual CHMOD(2-POSIX)
[ENOENT] The named file does not exist, or path
is an empty string.
[ENAMETOOLONG] The length of path exceeds {PATH_MAX},
or a pathname component is longer than
{NAME_MAX} while {_POSIX_NO_TRUNC} is in
effect.
[EACCES] Search permission is denied on a com-
ponent 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.
[EINTR] A signal was caught during the chmod
system call.
SEE ALSO
chown(2), creat(2), fcntl(2), mkdir(2), mkfifo(2), mknod(2),
open(2), read(2), write(2).
chmod(1) in the User's Reference Manual.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Oth-
erwise, a value of -1 is returned and errno is set to indi-
cate the error.
Page 2 Printed 1/15/91