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.
5 .\" @(#)chown.2 6.6 (Berkeley) 5/22/86
7 .TH CHOWN 2 "May 22, 1986"
10 chown, fchown \- change owner and group of a file
14 int chown(const char *\fIpath\fP, int \fIowner\fP, int \fIgroup\fP)
18 int fchown(int \fIfd\fP, int \fIowner\fP, int \fIgroup\fP)
23 that is named by \fIpath\fP
25 or referenced by \fIfd\fP
33 may change the owner of the file,
34 because if users were able to give files away,
35 they could defeat file-space accounting procedures.
36 The owner of the file may change the group
37 to a group of which he is a member.
41 clears the set-user-id and set-group-id bits
43 to prevent accidental creation of
44 set-user-id and set-group-id programs.
46 Zero is returned if the operation was successful;
47 \-1 is returned if an error occurs, with a more specific
48 error code being placed in the global variable \fBerrno\fP.
51 will fail and the file will be unchanged if:
54 A component of the path prefix is not a directory.
57 The path name exceeds PATH_MAX characters.
60 The named file does not exist.
63 Search permission is denied for a component of the path prefix.
66 Too many symbolic links were encountered in translating the pathname.
69 The effective user ID is not the super-user.
72 The named file resides on a read-only file system.
76 points outside the process's allocated address space.
79 An I/O error occurred while reading from or writing to the file system.
87 does not refer to a valid descriptor.
90 The effective user ID is not the super-user.
93 The named file resides on a read-only file system.
96 An I/O error occurred while reading from or writing to the file system.