xref: /386bsd/usr/share/man/cat2/fchmod.0 (revision a2142627)
1CHMOD(2)                  386BSD Programmer's Manual                  CHMOD(2)
2
3NNAAMMEE
4     cchhmmoodd, ffcchhmmoodd - change mode of file
5
6SSYYNNOOPPSSIISS
7     ##iinncclluuddee <<ssyyss//ssttaatt..hh>>
8
9     _i_n_t
10     cchhmmoodd(_c_o_n_s_t _c_h_a_r *_p_a_t_h, _m_o_d_e__t _m_o_d_e)
11
12     _i_n_t
13     ffcchhmmoodd(_i_n_t _f_d, _m_o_d_e__t _m_o_d_e)
14
15DDEESSCCRRIIPPTTIIOONN
16     The function cchhmmoodd() sets the file permission bits of the file specified
17     by the pathname _p_a_t_h to _m_o_d_e. FFcchhmmoodd() sets the permission bits of the
18     specified file descriptor _f_d. CChhmmoodd() verifies that the process owner
19     (user) either owns the file specified by _p_a_t_h (or _f_d), or is the super-
20     user.  A mode is created from _o_r'd permission bit masks defined in
21     <_s_y_s/_s_t_a_t._h>:
22           #define S_IRWXU 0000700    /* RWX mask for owner */
23           #define S_IRUSR 0000400    /* R for owner */
24           #define S_IWUSR 0000200    /* W for owner */
25           #define S_IXUSR 0000100    /* X for owner */
26
27           #define S_IRWXG 0000070    /* RWX mask for group */
28           #define S_IRGRP 0000040    /* R for group */
29           #define S_IWGRP 0000020    /* W for group */
30           #define S_IXGRP 0000010    /* X for group */
31
32           #define S_IRWXO 0000007    /* RWX mask for other */
33           #define S_IROTH 0000004    /* R for other */
34           #define S_IWOTH 0000002    /* W for other */
35           #define S_IXOTH 0000001    /* X for other */
36
37           #define S_ISUID 0004000    /* set user id on execution */
38           #define S_ISGID 0002000    /* set group id on execution */
39           #define S_ISVTX 0001000    /* save swapped text even after use */
40
41     The ISVTX (the _s_t_i_c_k_y _b_i_t) indicates to the system which executable files
42     are shareable (the default) and the system maintains the program text of
43     the files in the swap area. The sticky bit may only be set by the super
44     user on shareable executable files.
45
46     If mode ISVTX (the `sticky bit') is set on a directory, an unprivileged
47     user may not delete or rename files of other users in that directory. The
48     sticky bit may be set by any user on a directory which the user owns or
49     has appropriate permissions.  For more details of the properties of the
50     sticky bit, see sticky(8).
51
52     Writing or changing the owner of a file turns off the set-user-id and
53     set-group-id bits unless the user is the super-user.  This makes the
54     system somewhat more secure by protecting set-user-id (set-group-id)
55     files from remaining set-user-id (set-group-id) if they are modified, at
56     the expense of a degree of compatibility.
57
58RREETTUURRNN VVAALLUUEESS
59     Upon successful completion, a value of 0 is returned.  Otherwise, a value
60     of -1 is returned and _e_r_r_n_o is set to indicate the error.
61
62EERRRROORRSS
63     CChhmmoodd() will fail and the file mode will be unchanged if:
64
65
66     [ENOTDIR]     A component of the path prefix is not a directory.
67
68     [EINVAL]      The pathname contains a character with the high-order bit
69                   set.
70
71     [ENAMETOOLONG]
72                   A component of a pathname exceeded 255 characters, or an
73                   entire path name exceeded 1023 characters.
74
75     [ENOENT]      The named file does not exist.
76
77     [EACCES]      Search permission is denied for a component of the path
78                   prefix.
79
80     [ELOOP]       Too many symbolic links were encountered in translating the
81                   pathname.
82
83     [EPERM]       The effective user ID does not match the owner of the file
84                   and the effective user ID is not the super-user.
85
86     [EROFS]       The named file resides on a read-only file system.
87
88     [EFAULT]      _P_a_t_h points outside the process's allocated address space.
89
90     [EIO]         An I/O error occurred while reading from or writing to the
91                   file system.
92
93     FFcchhmmoodd() will fail if:
94
95     [EBADF]       The descriptor is not valid.
96
97     [EINVAL]      _F_d refers to a socket, not to a file.
98
99     [EROFS]       The file resides on a read-only file system.
100
101     [EIO]         An I/O error occurred while reading from or writing to the
102                   file system.
103
104SSEEEE AALLSSOO
105     chmod(1),  open(2),  chown(2),  stat(2),  sticky(8)
106
107SSTTAANNDDAARRDDSS
108     CChhmmoodd() is expected to conform to IEEE Std 1003.1-1988 (``POSIX'').
109
110HHIISSTTOORRYY
111     The ffcchhmmoodd() function call appeared in 4.2BSD.
112
1134th Berkeley Distribution       March 10, 1991                               2
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133