Syntax | #include <unistd.h> Optional int chown(const char *path, uid_t owner, gid_t group); | |
Description | path points to a pathname naming a file. The user ID and group ID of the named file are set to the numeric values contained in owner and group, respectively. Only processes with an effective user ID equal to the user ID of the file or processes with appropriate privileges may change the user ID and group ID of a file. The following applies if Changing the user ID is restricted to processes with appropriate privileges. Changing the group ID is permitted to a process with an effective user ID equal to the user ID of the file, but without appropriate privileges, if and only if owner is equal to the user ID of the file and group is equal to either the effective group ID of the process or to one of its supplementary group IDs. If path refers to a regular file, the set-user-ID ( If owner or group is specified as Upon successful completion, The In the flag parameter, the value When the value | |
Return val. | 0 -1 | if successful. if an error occurs; |
Errors |
| |
|
| Search permission is denied on a component of path. |
| Extension | |
|
| An invalid address was passed as an argument. A signal was caught during the The value of the specified user ID or group ID is not supported (e.g. if the value is less than 0) or an attempt was made to access a BS2000 file. |
| Extension | |
| An I/O error occurred while reading from or writing to the file system. Too many symbolic links were encountered in resolving path. (End) | |
| ENAMETOOLONG | |
The length of the path argument exceeds | ||
| path points to the name of a file that does not exist or to an empty string. | |
| A component of path is not a directory. The effective user ID does not match the owner of the file or the calling process does not have the appropriate privileges, although | |
| The named file resides on a read-only file system. | |
In addition, | ||
| The fd parameter was not opened with | |
| The path parameter does not specify an absolute pathname, and the fd parameter does not have the value | |
| The path parameter does not specify an absolute pathname, and the file descriptor fd is not connected with a directory, or the flag parameter has the value | |
| The value of the flag parameter is invalid. | |
Notes |
| |
See also |
|