The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
permission.c File Reference
#include "permission.h"
#include "common/memory.h"
#include "common/string.h"
#include "kernel/errno.h"
#include "kernel/process/process.h"
#include "kernel/vfs/stat.h"
#include "kernel/vfs/vfs.h"

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).
void permission_parent_path (const char *path, char *out, uint32_t size)
 the parent directory of an absolute path ("/a/b" -> "/a", "/a" -> "/").
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.

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_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.

◆ 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.