The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
permission.h File Reference
#include "common/stdint.h"
#include "kernel/fs/fs.h"

Go to the source code of this file.

Macros

#define MAY_EXEC   1
#define MAY_WRITE   2
#define MAY_READ   4
#define S_ISUID   04000
#define S_ISGID   02000
#define S_ISVTX   01000

Functions

int32_t permission_check (const fs_stat_t *st, uint32_t uid, uint32_t gid, uint32_t want)
 check an access against a file's mode and owner.
int32_t permission_check_path (const char *path, uint32_t want)
 check an access to a path for the current process (effective ids).
int32_t permission_check_parent (const char *path, bool victim)
 check that the current process may add or remove an entry of a directory: write and search rights on the parent of path.
void permission_parent_path (const char *path, char *out, uint32_t size)
 the parent directory of an absolute path ("/a/b" -> "/a", "/a" -> "/").

Macro Definition Documentation

◆ MAY_EXEC

#define MAY_EXEC   1

◆ MAY_WRITE

#define MAY_WRITE   2

◆ MAY_READ

#define MAY_READ   4

◆ S_ISUID

#define S_ISUID   04000

◆ S_ISGID

#define S_ISGID   02000

◆ S_ISVTX

#define S_ISVTX   01000

Function Documentation

◆ permission_check()

int32_t permission_check ( const fs_stat_t * st,
uint32_t uid,
uint32_t gid,
uint32_t want )

check an access against a file's mode and owner.

Parameters
stthe file's stat.
uidthe user id to check as (effective, or real for access()).
gidthe group id to check as.
wantMAY_* bits.
Returns
0, or -EACCES.

◆ permission_check_path()

int32_t permission_check_path ( const char * path,
uint32_t want )

check an access to a path for the current process (effective ids).

Returns
0, -EACCES, or the error of finding the file (-ENOENT).

◆ permission_check_parent()

int32_t permission_check_parent ( const char * path,
bool victim )

check that the current process may add or remove an entry of a directory: write and search rights on the parent of path.

for a removal (victim true) in a sticky directory, it must also own the entry or the directory.

Returns
0, -EACCES, -EPERM, or the error of finding the parent.

◆ permission_parent_path()

void permission_parent_path ( const char * path,
char * out,
uint32_t size )

the parent directory of an absolute path ("/a/b" -> "/a", "/a" -> "/").

Parameters
paththe path.
outreceives the parent.
sizesize of out.