PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
path.c File Reference
#include <_libstd/MAX_PATH.h>
#include <kernel/fs/path.h>
#include <kernel/fs/dentry.h>
#include <kernel/fs/namespace.h>
#include <kernel/fs/vfs.h>
#include <kernel/log/log.h>
#include <kernel/log/panic.h>
#include <kernel/sync/mutex.h>
#include <errno.h>
#include <kernel/sync/rcu.h>
#include <kernel/utils/map.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for path.c:

Go to the source code of this file.

Data Structures

struct  path_flag_short_t
 
struct  path_flag_t
 
struct  path_walk_ctx_t
 

Functions

static mode_t path_flag_to_mode (const char *flag, size_t length)
 
static bool path_is_char_valid (char ch)
 
uint64_t pathname_init (pathname_t *pathname, const char *string)
 Initialize a pathname.
 
static bool path_is_name_valid (const char *name)
 
void path_set (path_t *path, mount_t *mount, dentry_t *dentry)
 Set a path.
 
void path_copy (path_t *dest, const path_t *src)
 Copy a path.
 
void path_put (path_t *path)
 Put a path.
 
static uint64_t path_rcu_walk (path_walk_ctx_t *ctx)
 
static uint64_t path_walk_acquire (path_walk_ctx_t *ctx)
 
static void path_walk_release (path_walk_ctx_t *ctx)
 
static void path_walk_set_lookup (path_walk_ctx_t *ctx, dentry_t *dentry)
 
static void path_walk_cleanup (path_walk_ctx_t *ctx)
 
static uint64_t path_walk_get_result (path_walk_ctx_t *ctx, path_t *path)
 
static uint64_t path_rcu_dotdot (path_walk_ctx_t *ctx)
 
static uint64_t path_rcu_symlink (path_walk_ctx_t *ctx, dentry_t *symlink)
 
static uint64_t path_rcu_step (path_walk_ctx_t *ctx, const char *name, size_t length)
 
uint64_t path_step (path_t *path, mode_t mode, const char *name, namespace_t *ns)
 Walk a single path component.
 
uint64_t path_walk (path_t *path, const pathname_t *pathname, namespace_t *ns)
 Walk a pathname to a path.
 
uint64_t path_walk_parent (path_t *path, const pathname_t *pathname, char *outLastName, namespace_t *ns)
 Walk a pathname to its parent and get the name of the last component.
 
uint64_t path_walk_parent_and_child (const path_t *from, path_t *outParent, path_t *outChild, const pathname_t *pathname, namespace_t *ns)
 Traverse a pathname to its parent and child paths.
 
uint64_t path_to_name (const path_t *path, pathname_t *pathname)
 Convert a path to a pathname.
 
uint64_t mode_to_string (mode_t mode, char *out, uint64_t length)
 Convert a mode to a string representation.
 
uint64_t mode_check (mode_t *mode, mode_t maxPerms)
 Check and adjust mode permissions.
 

Variables

static path_flag_short_t shortFlags [UINT8_MAX+1]
 
static const path_flag_t flags []
 

Function Documentation

◆ path_flag_to_mode()

static mode_t path_flag_to_mode ( const char *  flag,
size_t  length 
)
static

Definition at line 65 of file path.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ path_is_char_valid()

static bool path_is_char_valid ( char  ch)
inlinestatic

Definition at line 99 of file path.c.

Here is the caller graph for this function:

◆ path_is_name_valid()

static bool path_is_name_valid ( const char *  name)
static

Definition at line 220 of file path.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ path_rcu_walk()

static uint64_t path_rcu_walk ( path_walk_ctx_t ctx)
static

Definition at line 516 of file path.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ path_walk_acquire()

static uint64_t path_walk_acquire ( path_walk_ctx_t ctx)
inlinestatic

Definition at line 301 of file path.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ path_walk_release()

static void path_walk_release ( path_walk_ctx_t ctx)
inlinestatic

Definition at line 319 of file path.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ path_walk_set_lookup()

static void path_walk_set_lookup ( path_walk_ctx_t ctx,
dentry_t dentry 
)
inlinestatic

Definition at line 327 of file path.c.

Here is the caller graph for this function:

◆ path_walk_cleanup()

static void path_walk_cleanup ( path_walk_ctx_t ctx)
inlinestatic

Definition at line 336 of file path.c.

Here is the caller graph for this function:

◆ path_walk_get_result()

static uint64_t path_walk_get_result ( path_walk_ctx_t ctx,
path_t path 
)
inlinestatic

Definition at line 345 of file path.c.

Here is the caller graph for this function:

◆ path_rcu_dotdot()

static uint64_t path_rcu_dotdot ( path_walk_ctx_t ctx)
static

Definition at line 374 of file path.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ path_rcu_symlink()

static uint64_t path_rcu_symlink ( path_walk_ctx_t ctx,
dentry_t symlink 
)
static

Definition at line 415 of file path.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ path_rcu_step()

static uint64_t path_rcu_step ( path_walk_ctx_t ctx,
const char *  name,
size_t  length 
)
static

Definition at line 464 of file path.c.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ shortFlags

path_flag_short_t shortFlags[UINT8_MAX+1]
static
Initial value:
= {
['r'] = {.mode = MODE_READ},
['w'] = {.mode = MODE_WRITE},
['x'] = {.mode = MODE_EXECUTE},
['n'] = {.mode = MODE_NONBLOCK},
['a'] = {.mode = MODE_APPEND},
['c'] = {.mode = MODE_CREATE},
['e'] = {.mode = MODE_EXCLUSIVE},
['p'] = {.mode = MODE_PARENTS},
['t'] = {.mode = MODE_TRUNCATE},
['d'] = {.mode = MODE_DIRECTORY},
['R'] = {.mode = MODE_RECURSIVE},
['l'] = {.mode = MODE_NOFOLLOW},
['P'] = {.mode = MODE_PRIVATE},
['g'] = {.mode = MODE_PROPAGATE},
['L'] = {.mode = MODE_LOCKED},
}
@ MODE_LOCKED
Definition path.h:95
@ MODE_CREATE
Definition path.h:86
@ MODE_APPEND
Definition path.h:85
@ MODE_PRIVATE
Definition path.h:93
@ MODE_NOFOLLOW
Definition path.h:92
@ MODE_EXECUTE
Definition path.h:83
@ MODE_NONBLOCK
Definition path.h:84
@ MODE_TRUNCATE
Definition path.h:89
@ MODE_WRITE
Definition path.h:82
@ MODE_RECURSIVE
Definition path.h:91
@ MODE_READ
Definition path.h:81
@ MODE_EXCLUSIVE
Definition path.h:87
@ MODE_PROPAGATE
Definition path.h:94
@ MODE_PARENTS
Definition path.h:88
@ MODE_DIRECTORY
Definition path.h:90

Definition at line 23 of file path.c.

◆ flags

const path_flag_t flags[]
static
Initial value:
= {
{.mode = MODE_READ, .name = "read"},
{.mode = MODE_WRITE, .name = "write"},
{.mode = MODE_EXECUTE, .name = "execute"},
{.mode = MODE_NONBLOCK, .name = "nonblock"},
{.mode = MODE_APPEND, .name = "append"},
{.mode = MODE_CREATE, .name = "create"},
{.mode = MODE_EXCLUSIVE, .name = "exclusive"},
{.mode = MODE_PARENTS, .name = "parents"},
{.mode = MODE_TRUNCATE, .name = "truncate"},
{.mode = MODE_DIRECTORY, .name = "directory"},
{.mode = MODE_RECURSIVE, .name = "recursive"},
{.mode = MODE_NOFOLLOW, .name = "nofollow"},
{.mode = MODE_PRIVATE, .name = "private"},
{.mode = MODE_PROPAGATE, .name = "propagate"},
{.mode = MODE_LOCKED, .name = "locked"},
}

Definition at line 47 of file path.c.