NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO | STANDARDS
#include <unistd.h>int chown(const char * path, uid_t owner, gid_t group);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
MSDOSFS, NFS_CLIENT, UFS
The owner ID and group ID of the file named by path or referenced by fd are changed as specified by the arguments owner and group . The owner of a file may change the group to a group of which he or she is a member, but the change owner capability is restricted to the super-user.
The chown() function clears the set-user-id and set-group-id bits on the file to prevent accidental or mischievous creation of set-user-id and set-group-id programs.
fchown() is particularly useful when used in conjunction with the file locking primitives. See flock(2POSIX) .
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned, and errno is set to indicate the error.
The chown() function will fail and the file will be unchanged if any of the following are true:
Search permission is denied for a component of the path prefix.
Path points outside the process's allocated address space.
An I/O error occurred while reading from or writing to the file system.
Too many symbolic links were encountered when translating the pathname.
A component of a pathname exceeded 255 characters, or an entire pathname exceeded 1023 characters.
The file named does not exist.
A component of the path prefix is not a directory.
The effective user ID is not the super-user.
The file named resides on a read-only file system.
fchown() will fail if:
fd does not refer to a valid descriptor.
fd refers to a socket, not a file.
The effective user ID is not the super-user.
The named file resides on a read-only file system.
An I/O error occurred while reading from or writing to the file system.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
MT-Level | Async-Signal-Safe |
The chown function conforms to IEEE Std 1003.1-1988 POSIX . .
NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUES | ERRORS | ATTRIBUTES | SEE ALSO | STANDARDS