Go to the previous, next section.
int chmod(const char *path, mode_t mode);
int fchmod(int fd, mode_t mode);
path: [in] points to the path of the file to modify.
fd: [in] the file descriptor to modify.
mode: [in] the new mode.
chmod
changes the mode of the file specified by path to
mode. fchmod
changes the mode of the file descriptor
specified by fd to mode.The possible values of mode
are obtained by or'ing the following constants:
S_ISUID
: set uid on execution.
S_ISGID
: set gid on execution.
S_ISVTX
: sticky bit.
S_IRUSR
: readable by owner.
S_IWUSR
: writable by owner.
S_IXUSR
: executable by owner.
S_IRGRP
: readable by group.
S_IWGRP
: writable by group.
S_IXGRP
: executable by group.
S_IROTH
: readable by the world.
S_IWOTH
: writable by the world.
S_IXOTH
: executable by the world.
On success zero is returned. On error, -1 is returned and errno
is
set to one of the following values:
for chmod
:
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 fchmod
:
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.