Your Browser is not longer supported
Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...
{{viewport.spaceProperty.prod}}
fchown - change owner or group of file
&pagelevel(4)&pagelevel
Syntax | #include <unistd.h> int fchown(int fildes, uid_t owner, gid_t group); |
Description | Like chown() , fchown() changes the user ID and the group ID of the addressed file, except that the file is not identified by the pathname but by the file descriptor fildes. The user ID is set to owner and the group ID is set to group. If owner or group is specified as -1, the corresponding ID is not changed. If fchown() is called by a process without appropriate privileges, the bits set-user-ID on execution and set-group-ID on execution, i.e. S_ISUID and S_ISGID , are cleared (see chmod() ). The effective user ID of the process must match the owner of the file or the process must have the appropriate privilege to change ownership of a file. On successful completion, fchown() marks the st_ctime field of the file for update. |
Return val. | 0 | if successful. The user ID and group ID of the specified file are set as required. |
-1 | if an error occurs. The user ID and group ID of the file are not changed, and errno is set to indicate the error. |
Errors | fchown() will fail if:
|
|
| EABDF
| fildes does not point to an open file. |
| EINTR
| A signal was caught during the system call. |
| EINVAL
| An attempt was made to access a BS2000 file. group or owner is not in the permissible range. |
| EIO
| An I/O error occurred while reading from or writing to the file system. |
| EPERM
| The user ID does not match the owner of the file, or the process does not have the appropriate privileges. |
| EROFS
| The file resides on a read-only file system. |
Notes | fchown() is executed only for POSIX files
|
See also | chmod() , chown() , unistd.h .
|