Go to the previous, next section.
int chown(const char *path, uid_t owner, gid_t group);
int fchown(int fd, uid_t owner, gid_t group);
path: [in] points to the path of the file to modify.
fd: [in] the file descriptor to modify.
owner: [in] the new uid. -1 for no change.
group: [in] the new gid. -1 for no change.
chown
changes the uid and gid of file specified by path to
owner and group. fchown
changes the uid and gid of
file descriptor fd to owner and group. The superuser
may do whatever he wishes with the uid and gid of a file. The owner of a
file may only change the gid of the file to any group he belongs to.
On success zero is returned. On error, -1 is returned and errno
is
set to one of the following values:
for chown
:
EPERM
: the effective uid of the task is not equal the the
uid of the file and the task does not have superuser privileges.
ENOTDIR
, EACCESS
, EFAULT
, ENOENT
,
ENOMEM
ENAMETOOLONG
, EROFS
or ELOOP
.
for fchown
:
EPERM
: the effective uid of the task is not equal the the
uid of the file and the task does not have superuser privileges.
ENOENT
, EROFS
or EBADF
.
Go to the previous, next section.