chown(2)
NAME
chown − change owner and group of a file
SYNTAX
int chown(name, owner, group)
char *name;
int owner, group;
DESCRIPTION
The chown system call changes the owner and group of the file name (null-terminated string) to owner and group.
RESTRICTIONS
Only processes with effective user ID equal to the file owner or the superuser may change the ownership of a file.
If the chown call is invoked by anyone other than the superuser, the set-user-ID and set-group-ID bits of the file mode (04000 and 02000, respectively) will be cleared. This prevents an ordinary user from effectively making themselves another user or a member of a group to which they do not belong.
RETURN VALUE
If unsuccessful, returns a −1, and the global variable errno indicates the error code.
DIAGNOSTICS
The chown call will fail if:
[EACCES] Search permission is denied on a component of the path prefix.
[EFAULT] The specified name points outside the process’s allocated address space.
[ENFILE] There is insufficient system space to contain the inode.
[ENOENT] Either a named file or an element within a path does not exist.
[ENOTDIR] A component of the path prefix is not a directory.
[EPERM] The effective user ID does not match the owner of the file, and the effective user ID is not the superuser.
[EROFS] The named file resides on a read-only file system.
ASSEMBLER
(chown = 16.)
sys chown; name; owner; group