Commit | Line | Data |
---|---|---|
37512f15 KM |
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 | .\" | |
fd690c8b | 5 | .\" @(#)chown.2 6.4 (Berkeley) %G% |
37512f15 | 6 | .\" |
9a68374b | 7 | .TH CHOWN 2 "" |
37512f15 KM |
8 | .UC 4 |
9 | .SH NAME | |
10 | chown \- change owner and group of a file | |
11 | .SH SYNOPSIS | |
12 | .nf | |
0aa506e6 KM |
13 | .ft B |
14 | chown(path, owner, group) | |
15 | char *path; | |
16 | int owner, group; | |
17 | .PP | |
18 | .ft B | |
19 | fchown(fd, owner, group) | |
20 | int fd, owner, group; | |
37512f15 KM |
21 | .fi |
22 | .SH DESCRIPTION | |
23 | The file | |
d84f45ef | 24 | that is named by \fIpath\fP or referenced by \fIfd\fP |
37512f15 KM |
25 | has its |
26 | .I owner | |
27 | and | |
28 | .I group | |
29 | changed as specified. | |
30 | Only the super-user may | |
31 | execute this call, | |
32 | because if users were able to give files away, | |
0aa506e6 | 33 | they could defeat the file-space accounting procedures. |
37512f15 KM |
34 | .PP |
35 | On some systems, | |
36 | .I chown | |
0aa506e6 | 37 | clears the set-user-id and set-group-id bits |
37512f15 KM |
38 | on the file |
39 | to prevent accidental creation of | |
0aa506e6 KM |
40 | set-user-id and set-group-id programs |
41 | owned by the super-user. | |
42 | .PP | |
43 | .I Fchown | |
44 | is particularly useful when used in conjunction | |
45 | with the file locking primitives (see | |
46 | .IR flock (2)). | |
47 | .PP | |
48 | Only one of the owner and group id's | |
49 | may be set by specifying the other as \-1. | |
50 | .SH "RETURN VALUE | |
51 | Zero is returned if the operation was successful; | |
52 | \-1 is returned if an error occurs, with a more specific | |
53 | error code being placed in the global variable \fIerrno\fP. | |
54 | .SH "ERRORS | |
55 | .I Chown | |
56 | will fail and the file will be unchanged if: | |
57 | .TP 15 | |
0aa506e6 KM |
58 | [ENOTDIR] |
59 | A component of the path prefix is not a directory. | |
60 | .TP 15 | |
b5984ffe KM |
61 | [EINVAL] |
62 | The pathname contains a character with the high-order bit set. | |
0aa506e6 | 63 | .TP 15 |
b5984ffe KM |
64 | [ENAMETOOLONG] |
65 | A component of a pathname exceeded 255 characters, | |
66 | or an entire path name exceeded 1023 characters. | |
0aa506e6 KM |
67 | .TP 15 |
68 | [ENOENT] | |
69 | The named file does not exist. | |
70 | .TP 15 | |
71 | [EACCES] | |
b5984ffe KM |
72 | Search permission is denied for a component of the path prefix. |
73 | .TP 15 | |
74 | [ELOOP] | |
75 | Too many symbolic links were encountered in translating the pathname. | |
0aa506e6 KM |
76 | .TP 15 |
77 | [EPERM] | |
fd690c8b | 78 | The effective user ID is not the super-user. |
0aa506e6 KM |
79 | .TP 15 |
80 | [EROFS] | |
81 | The named file resides on a read-only file system. | |
82 | .TP 15 | |
83 | [EFAULT] | |
84 | .I Path | |
85 | points outside the process's allocated address space. | |
fd690c8b KM |
86 | .TP 15 |
87 | [EIO] | |
88 | An I/O error occurred while reading from or writing to the file system. | |
0aa506e6 KM |
89 | .PP |
90 | .I Fchown | |
91 | will fail if: | |
92 | .TP 15 | |
93 | [EBADF] | |
94 | .I Fd | |
95 | does not refer to a valid descriptor. | |
96 | .TP 15 | |
97 | [EINVAL] | |
98 | .I Fd | |
99 | refers to a socket, not a file. | |
b5984ffe | 100 | .TP 15 |
fd690c8b KM |
101 | [EPERM] |
102 | The effective user ID is not the super-user. | |
103 | .TP 15 | |
b5984ffe KM |
104 | [EROFS] |
105 | The named file resides on a read-only file system. | |
fd690c8b KM |
106 | .TP 15 |
107 | [EIO] | |
108 | An I/O error occurred while reading from or writing to the file system. | |
37512f15 | 109 | .SH "SEE ALSO" |
0aa506e6 | 110 | chmod(2), flock(2) |