RFS | XFS

chmod()

PROTOTYPE

#include <posix.h>

int chmod(const char *path, mode_t mode);

DESCRIPTION

chmod() assigns the access permission bits specified by mode to the file specified by path. Paths starting with ‘/’ are absolute, otherwise they are relative to the CWD.

The caller must own the file and have search access to the path prefix. The file’s status change timestamp is updated.

If successful, chmod() returns 0. Otherwise, it sets errno and returns -1.

ERROR CODES

EACCES No execute access to a directory in the path prefix.
EFAULT path equals NULL.
EINVAL The value of mode is invalid.
ENAMETOOLONG A name in path exceeds the effective maximum file name length.
ENOENT path is the empty string or includes a file that was not found.
ENOTDIR One of the non-leaf path components is not a directory.
EPERM The caller is not the file’s owner (per FsGetId()).
EROFS The volume is read-only.

EXAMPLE

if (chmod(path, S_RUSR | S_WUSR | S_XUSR | S_RGRP))
  return -1;