Improved English
[unix-history] / usr / src / lib / libc / sys / chown.2
index 2f78001..99b9f1e 100644 (file)
@@ -2,22 +2,26 @@
 .\" 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     4.1 (Berkeley) %G%
+.\"    @(#)chown.2     6.3 (Berkeley) %G%
 .\"
 .\"
-.TH CHOWN 2 
+.TH CHOWN 2 ""
 .UC 4
 .SH NAME
 chown \- change owner and group of a file
 .SH SYNOPSIS
 .nf
 .UC 4
 .SH NAME
 chown \- change owner and group of a file
 .SH SYNOPSIS
 .nf
-.B chown(name, owner, group)
-.B char *name;
+.ft B
+chown(path, owner, group)
+char *path;
+int owner, group;
+.PP
+.ft B
+fchown(fd, owner, group)
+int fd, owner, group;
 .fi
 .SH DESCRIPTION
 The file
 .fi
 .SH DESCRIPTION
 The file
-whose name is given by the null-terminated string pointed
-to by
-.I name
+that is named by \fIpath\fP or referenced by \fIfd\fP
 has its
 .I owner
 and 
 has its
 .I owner
 and 
@@ -26,22 +30,73 @@ changed as specified.
 Only the super-user may
 execute this call,
 because if users were able to give files away,
 Only the super-user may
 execute this call,
 because if users were able to give files away,
-they could defeat the (nonexistent)
-file-space accounting procedures.
+they could defeat the file-space accounting procedures.
 .PP
 On some systems,
 .I chown
 .PP
 On some systems,
 .I chown
-clears the set-user-id bit
+clears the set-user-id and set-group-id bits
 on the file
 to prevent accidental creation of
 on the file
 to prevent accidental creation of
-set-user-id programs owned by the super-user.
+set-user-id and set-group-id programs
+owned by the super-user.
+.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.
+.SH "RETURN VALUE
+Zero is returned if the operation was successful;
+\-1 is returned if an error occurs, with a more specific
+error code being placed in the global variable \fIerrno\fP.
+.SH "ERRORS
+.I Chown
+will fail and the file will be unchanged if:
+.TP 15
+[ENOTDIR]
+A component of the path prefix is not a directory.
+.TP 15
+[EINVAL]
+The pathname contains a character with the high-order bit set.
+.TP 15
+[ENAMETOOLONG]
+A component of a pathname exceeded 255 characters,
+or an entire path name exceeded 1023 characters.
+.TP 15
+[ENOENT]
+The named file does not exist.
+.TP 15
+[EACCES]
+Search permission is denied for a component of the path prefix.
+.TP 15
+[ELOOP]
+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.
+.TP 15
+[EROFS]
+The named file resides on a read-only file system.
+.TP 15
+[EFAULT]
+.I Path
+points outside the process's allocated address space.
+.PP
+.I Fchown
+will fail if:
+.TP 15
+[EBADF]
+.I Fd
+does not refer to a valid descriptor.
+.TP 15
+[EINVAL]
+.I Fd
+refers to a socket, not a file.
+.TP 15
+[EROFS]
+The named file resides on a read-only file system.
 .SH "SEE ALSO"
 .SH "SEE ALSO"
-chown(1), passwd(5)
-.SH DIAGNOSTICS
-Zero is returned if the owner is changed;
-\-1 is returned
-on illegal owner changes.
-.SH "ASSEMBLER (PDP-11)"
-(chown = 16.)
-.br
-.B sys chown; name; owner; group
+chmod(2), flock(2)