#define F_OK 0b0001 #define R_OK 0b0010 #define W_OK 0b0100 #define X_OK 0b1000 #define AT_EACCESS 512 int access(int dir_fd, char *path, int len, mode_t mode, int flags);
This syscall whether the callee process can access the passed file against
POSIX file permissions and Ironclad’s MAC. What to check for is specified in
mode
as an ORd list, as such:
F_OK
: When passed, only file existance will be checked.
R_OK
: When passed, read permissions will be checked.
W_OK
: When passed, write permissions will be checked.
X_OK
: When passed, execute permissions will be checked.
Permissions are checked with the real user and group IDs, instead of the
effective ones, that behaviour can be changed by passing AT_EACCESS
in
flags
, which can also be used for other common AT flags.
AT_EMPTY_PATH
is not accepted because that does not make any sense with
this syscall.
The syscall returns 0
on success when the passed mode is checked valid,
or -1
on check failure, with the following errno:
EBADF
: dirfd
is not valid.
ENOENT
: The requested file does not exist.
EACCES
: The access is not allowed.