CHOWN(2,L) AIX Technical Reference CHOWN(2,L)
-------------------------------------------------------------------------------
chown, fchown
PURPOSE
Changes the owner and group IDs of files associated with a path name or with a
file descriptor.
LIBRARY
Standard C Library (libc.a)
SYNTAX
int chown (path, owner, group) int fchown (fd, owner, group)
char *path; int fd;
uid_t owner; uid_t owner;
gid_t group; gid_t group;
DESCRIPTION
The chown and fchown system calls change the owner ID and/or the group ID of
the file named by the path parameter or of the open file named by the fd
parameter, respectively. If the named file is a symbolic link, the owner ID
and/or group ID of the symbolic link itself are changed, not those of the file
pointed to by the symbolic link.
The owner and group IDs of the named file are set to the numeric values
contained in the owner and group parameters, respectively.
If either the owner or group parameter has the value (uid_t)-1 or (gid_t)-1,
respectively the corresponding ID in the named file is left unchanged.
A process can change the ownership of a file only if its effective user ID is
the superuser. The group ID may be changed if the effective user ID of the
process is superuser or matches the file's owner ID. In the latter case, the
group ID may only be changed to the value of the process's effective group ID
or a value in the process's concurrent group list.
RETURN VALUE
Upon successful completion, a value of 0 is returned. If the chown or fchown
system call fails, a value of -1 is returned, and errno is set to indicate the
error.
ERROR CONDITIONS
Processed November 7, 1990 CHOWN(2,L) 1
CHOWN(2,L) AIX Technical Reference CHOWN(2,L)
The chown system call fails and the owner ID and the group ID of the named file
remain unchanged if one or more of the following are true:
ENOTDIR A component of the path prefix is not a directory.
ENOENT The named file does not exist.
EACCES Search permission is denied on a component of the path prefix.
ENOENT A symbolic link was named, but the file to which it refers does
exist. Since chown does not follow a symbolic link when it is the
last component of the path, this error cannot occur on the last
component.
EFAULT The path parameter points to a location outside of the process's
allocated address space in an NFS virtual file system that has been
unmounted.
ENAMETOOLONG
A component of the path parameter exceeded NAME_MAX characters or the
entire path parameter exceeded PATH_MAX characters.
ENOENT A hidden directory was named, but no component inside it matched the
process's current site path list.
ELOOP A loop of symbolic links was detected. Since chown does not follow
symbolic links in the last component of the path, this error cannot
occur on the last component.
ENOSTORE The path is a name relative to the working directory, but no site
which stores this directory is currently up.
EINTR A signal was caught during the system call.
The fchown system call fails and the owner ID and group ID of the named file
remain unchanged if one or more of the following are true:
EBADF fd does not refer to a valid file descriptor
EINVAL fd refers to a socket, not a file.
The chown and fchown system calls fail and the owner ID and group ID of the
named file remain unchanged if one or more of the following are true:
EPERM The effective user ID does not match the owner of the file and the
effective user ID is not superuser.
EROFS The named file resides on a read-only file system.
ESTALE The process's root or current directory is located
Processed November 7, 1990 CHOWN(2,L) 2
CHOWN(2,L) AIX Technical Reference CHOWN(2,L)
If the Transparent Computing Facility is installed on your system, chown can
also fail if one or more of the following are true:
ESITEDN1 The specified file cannot be accessed because a site went down.
ESITEDN2 The operation was terminated because a site failed.
ENOSTORE The file specified by fd or a component of path is replicated but is
not stored on any site which is currently up.
EROFS Write access is requested for a file on a replicated file system in
which the primary copy is unavailable.
EIO An I/O error occurred while reading from or writing to the file
system.
RELATED INFORMATION
In this book: "chmod, fchmod," "statx, fstatx, stat, fstat, fullstat,
ffullstat, lstat," and "stat.h."
The chown command in AIX Operating System Commands Reference.
Processed November 7, 1990 CHOWN(2,L) 3