sockaddr's now require length (K. Sklower);
[unix-history] / usr / src / lib / libc / sys / chown.2
index f43be0f..5236170 100644 (file)
@@ -2,7 +2,7 @@
 .\" All rights reserved.  The Berkeley software License Agreement
 .\" specifies the terms and conditions for redistribution.
 .\"
 .\" All rights reserved.  The Berkeley software License Agreement
 .\" specifies the terms and conditions for redistribution.
 .\"
-.\"    @(#)chown.2     6.2 (Berkeley) %G%
+.\"    @(#)chown.2     6.6 (Berkeley) %G%
 .\"
 .TH CHOWN 2 ""
 .UC 4
 .\"
 .TH CHOWN 2 ""
 .UC 4
@@ -21,32 +21,39 @@ int fd, owner, group;
 .fi
 .SH DESCRIPTION
 The file
 .fi
 .SH DESCRIPTION
 The file
-which is named by \fIpath\fP or referenced by \fIfd\fP
+that is named by \fIpath\fP or referenced by \fIfd\fP
 has its
 .I owner
 and 
 .I group
 changed as specified.
 has its
 .I owner
 and 
 .I group
 changed as specified.
-Only the super-user may
-execute this call,
+Only the super-user
+may change the owner of the file,
 because if users were able to give files away,
 they could defeat the file-space accounting procedures.
 because if users were able to give files away,
 they could defeat the file-space accounting procedures.
+The owner of the file may change the group
+to a group of which he is a member.
 .PP
 On some systems,
 .I chown
 clears the set-user-id and set-group-id bits
 on the file
 to prevent accidental creation of
 .PP
 On some systems,
 .I chown
 clears the set-user-id and set-group-id bits
 on the file
 to prevent accidental creation of
-set-user-id and set-group-id programs
-owned by the super-user.
+set-user-id and set-group-id programs.
 .PP
 .I Fchown
 is particularly useful when used in conjunction
 with the file locking primitives (see
 .IR flock (2)).
 .PP
 .PP
 .I Fchown
 is particularly useful when used in conjunction
 with the file locking primitives (see
 .IR flock (2)).
 .PP
-Only one of the owner and group id's
-may be set by specifying the other as \-1.
+One of the owner or group id's
+may be left unchanged by specifying it as \-1.
+.PP
+If the final component of
+.I path
+is a symbolic link,
+the ownership and group of the symbolic link is changed,
+not the ownership and group of the file or directory to which it points.
 .SH "RETURN VALUE
 Zero is returned if the operation was successful;
 \-1 is returned if an error occurs, with a more specific
 .SH "RETURN VALUE
 Zero is returned if the operation was successful;
 \-1 is returned if an error occurs, with a more specific
@@ -75,8 +82,7 @@ Search permission is denied for a component of the path prefix.
 Too many symbolic links were encountered in translating the pathname.
 .TP 15
 [EPERM]
 Too many symbolic links were encountered in translating the pathname.
 .TP 15
 [EPERM]
-The effective user ID does not match the owner of the file and
-the effective user ID is not the super-user.
+The effective user ID is not the super-user.
 .TP 15
 [EROFS]
 The named file resides on a read-only file system.
 .TP 15
 [EROFS]
 The named file resides on a read-only file system.
@@ -84,6 +90,9 @@ The named file resides on a read-only file system.
 [EFAULT]
 .I Path
 points outside the process's allocated address space.
 [EFAULT]
 .I Path
 points outside the process's allocated address space.
+.TP 15
+[EIO]
+An I/O error occurred while reading from or writing to the file system.
 .PP
 .I Fchown
 will fail if:
 .PP
 .I Fchown
 will fail if:
@@ -96,7 +105,13 @@ does not refer to a valid descriptor.
 .I Fd
 refers to a socket, not a file.
 .TP 15
 .I Fd
 refers to a socket, not a file.
 .TP 15
+[EPERM]
+The effective user ID is not the super-user.
+.TP 15
 [EROFS]
 The named file resides on a read-only file system.
 [EROFS]
 The named file resides on a read-only file system.
+.TP 15
+[EIO]
+An I/O error occurred while reading from or writing to the file system.
 .SH "SEE ALSO"
 .SH "SEE ALSO"
-chmod(2), flock(2)
+chown(8), chgrp(1), chmod(2), flock(2)