|
|
1.1 root 1: .TH CHMOD 2 "2 July 1983"
2: .UC 4
3: .SH NAME
4: chmod \- change mode of file
5: .SH SYNOPSIS
6: .nf
7: .ft B
8: chmod(path, mode)
9: char *path;
10: int mode;
11: .PP
12: .ft B
13: fchmod(fd, mode)
14: int fd, mode;
15: .fi
16: .SH DESCRIPTION
17: The file whose name
18: is given by \fIpath\fP
19: or referenced by the descriptor
20: .I fd
21: has its mode changed to
22: .IR mode .
23: Modes are constructed by
24: .IR or 'ing
25: together some
26: combination of the following:
27: .PP
28: .RS
29: 04000 set user ID on execution
30: 02000 set group ID on execution
31: 01000 save text image after execution
32: 00400 read by owner
33: 00200 write by owner
34: 00100 execute (search on directory) by owner
35: 00070 read, write, execute (search) by group
36: 00007 read, write, execute (search) by others
37: .RE
38: .PP
39: If an executable file is set up for sharing (this is the default)
40: then mode 1000 prevents the system from
41: abandoning the swap-space image of the program-text portion
42: of the file when its last user
43: terminates.
44: Ability to set this bit is restricted to the super-user.
45: .PP
46: Only the owner of a file (or the super-user) may change the mode.
47: .PP
48: Writing or changing the owner of a file
49: turns off the set-user-id and set-group-id bits.
50: This makes the system somewhat more secure
51: by protecting set-user-id (set-group-id) files
52: from remaining set-user-id (set-group-id) if they are modified,
53: at the expense of a degree of compatibility.
54: .SH "RETURN VALUE
55: Upon successful completion, a value of 0 is returned.
56: Otherwise, a value of \-1 is returned and
57: .I errno
58: is set to indicate the error.
59: .SH "ERRORS
60: .I Chmod
61: will fail and the file mode will be unchanged if:
62: .TP 15
63: [EPERM]
64: The argument contains a byte with the high-order bit set.
65: .TP 15
66: [ENOTDIR]
67: A component of the path prefix is not a directory.
68: .TP 15
69: [ENOENT]
70: The pathname was too long.
71: .TP 15
72: [ENOENT]
73: The named file does not exist.
74: .TP 15
75: [EACCES]
76: Search permission is denied on a component of the path prefix.
77: .TP 15
78: [EPERM]
79: The effective user ID does not match the owner of the file and
80: the effective user ID is not the super-user.
81: .TP 15
82: [EROFS]
83: The named file resides on a read-only file system.
84: .TP 15
85: [EFAULT]
86: .I Path
87: points outside the process's allocated address space.
88: .TP 15
89: [ELOOP]
90: Too many symbolic links were encountered in translating the pathname.
91: .PP
92: .I Fchmod
93: will fail if:
94: .TP 15
95: [EBADF]
96: The descriptor is not valid.
97: .TP 15
98: [EINVAL]
99: .I Fd
100: refers to a socket, not to a file.
101: .TP 15
102: [EROFS]
103: The file resides on a read-only file system.
104: .SH "SEE ALSO"
105: open(2), chown(2)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.