source: trunk/minix/man/man2/chmod.2@ 9

Last change on this file since 9 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 3.2 KB
Line 
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)chmod.2 6.5 (Berkeley) 5/13/86
6.\"
7.TH CHMOD 2 "May 13, 1986"
8.UC 4
9.SH NAME
10chmod \- change mode of file
11.SH SYNOPSIS
12.nf
13.ft B
14#include <sys/types.h>
15#include <sys/stat.h>
16
17int chmod(const char *\fIpath\fP, mode_t \fImode\fP)
18.ig \" You never know
19.PP
20.ft B
21int fchmod(int \fIfd\fP, mode_t \fImode\fP)
22..
23.fi
24.SH DESCRIPTION
25The file whose name
26is given by \fIpath\fP
27.ig
28or referenced by the descriptor
29.I fd
30..
31has its mode changed to
32.IR mode .
33Modes are constructed by
34.IR or 'ing
35together some
36combination of the following, defined in
37.IR <sys/stat.h> :
38.PP
39.RS
40.nf
41.ta \w'S_ISUID\ \ 'u +\w'04000\ \ \ 'u
42S_ISUID 04000 set user ID on execution
43S_ISGID 02000 set group ID on execution
44S_ISVTX 01000 `sticky bit' (see below)
45S_IRWXU 00700 read, write, execute by owner
46S_IRUSR 00400 read by owner
47S_IWUSR 00200 write by owner
48S_IXUSR 00100 execute (search on directory) by owner
49S_IRWXG 00070 read, write, execute by group
50S_IRGRP 00040 read by group
51S_IWGRP 00020 write by group
52S_IXGRP 00010 execute (search on directory) by group
53S_IRWXO 00007 read, write, execute by others
54S_IROTH 00004 read by others
55S_IWOTH 00002 write by others
56S_IXOTH 00001 execute (search on directory) by others
57.fi
58.RE
59.PP
60If mode ISVTX (the `sticky bit') is set on a directory,
61an unprivileged user may not delete or rename
62files of other users in that directory. (Minix-vmd)
63.PP
64Only the owner of a file (or the super-user) may change the mode.
65.PP
66Writing or changing the owner of a file
67turns off the set-user-id and set-group-id bits
68unless the user is the super-user.
69This makes the system somewhat more secure
70by protecting set-user-id (set-group-id) files
71from remaining set-user-id (set-group-id) if they are modified,
72at the expense of a degree of compatibility.
73.SH "RETURN VALUE
74Upon successful completion, a value of 0 is returned.
75Otherwise, a value of \-1 is returned and
76.B errno
77is set to indicate the error.
78.SH "ERRORS
79.B Chmod
80will fail and the file mode will be unchanged if:
81.TP 15
82[ENOTDIR]
83A component of the path prefix is not a directory.
84.TP 15
85[ENAMETOOLONG]
86The path name exceeds PATH_MAX characters.
87.TP 15
88[ENOENT]
89The named file does not exist.
90.TP 15
91[EACCES]
92Search permission is denied for a component of the path prefix.
93.TP 15
94[ELOOP]
95Too many symbolic links were encountered in translating the pathname.
96(Minix-vmd)
97.TP 15
98[EPERM]
99The effective user ID does not match the owner of the file and
100the effective user ID is not the super-user.
101.TP 15
102[EROFS]
103The named file resides on a read-only file system.
104.TP 15
105[EFAULT]
106.I Path
107points outside the process's allocated address space.
108.TP 15
109[EIO]
110An I/O error occurred while reading from or writing to the file system.
111.ig
112.PP
113.I Fchmod
114will fail if:
115.TP 15
116[EBADF]
117The descriptor is not valid.
118.TP 15
119[EROFS]
120The file resides on a read-only file system.
121.TP 15
122[EIO]
123An I/O error occurred while reading from or writing to the file system.
124..
125.SH "SEE ALSO"
126.BR chmod (1),
127.BR open (2),
128.BR chown (2),
129.BR stat (2).
130.SH NOTES
131The sticky bit was historically used to lock important executables into
132memory.
Note: See TracBrowser for help on using the repository browser.