CHOWN(2) COMMAND REFERENCE CHOWN(2) NAME chown, fchown - change owner and group of a file SYNOPSIS chown(path, owner, group) char *path; int owner, group; fchown(fd, owner, group) int fd, owner, group; DESCRIPTION The file which is named by path or referenced by fd has its owner and group changed as specified. 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. Fchown is particularly useful when used in conjunction with the file locking primitives (see flock(2)). Only one of owner and group may be set by specifying the other as -1. Normally only the super-user may execute this call, because if users were able to give files away, they could defeat the file-space accounting procedures. The exception to this is when owner is -1 and group is in the current group access list of the calling process. This lets any user change the group of a file they own as long as they're a member of that group. DIAGNOSTICS Chown will fail and the file will be unchanged if: [ENOTDIR] A component of the path prefix is not a directory. [ENAMETOOLONG] The argument pathname is too long. [ENOASCII] The argument path contains a byte with the high-order bit set. [ENOENT] The named file does not exist. [EPERM] The effective user ID is not the super-user and this call would change the file's ownership, or would change the file's group to one of which the process is not a member. [EROFS] The named file resides on a read-only file Printed 5/12/88 1
CHOWN(2) COMMAND REFERENCE CHOWN(2) system. [EFAULT] Path points outside the process's allocated address space. [ELOOP] Too many symbolic links were encountered in translating the pathname. [EIO] An I/O error occurred while reading from or writing to the file system. Fchown will fail if: [EBADF] Fd does not refer to a valid descriptor. [EPERM] The effective user ID is not the super-user and this call would change the file's ownership, or would change the file's group to one of which the process is not a member. [EROFS] The named file resides on a read-only file system. [EIO] An I/O error occurred while reading from or writing to the file system. [EINVAL] Fd refers to a socket, not a file. RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. SEE ALSO chmod(2), flock(2), and getgroups(2). Printed 5/12/88 2
%%index%% na:264,100; sy:364,1099; de:1463,1179; di:2642,856;3834,1031; rv:4865,280; se:5145,183; %%index%%000000000121