PatchworkOS  da8a090
A non-POSIX operating system.
Loading...
Searching...
No Matches
path.c File Reference
#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/utils/map.h>
#include <stdint.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
 

Functions

static mode_t path_flag_to_mode (const char *flag, uint64_t length)
 
uint64_t pathname_init (pathname_t *pathname, const char *string)
 Initialize a pathname.
 
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 bool path_is_name_valid (const char *name)
 
static uint64_t path_handle_dotdot (path_t *path)
 
uint64_t path_step (path_t *path, const char *component, namespace_t *ns)
 Walk a single step in a path.
 
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.
 

Variables

static map_t flagMap
 
static map_t flagShortMap
 
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,
uint64_t  length 
)
static

Definition at line 55 of file path.c.

Here is the call graph for this function:
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 261 of file path.c.

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

◆ path_handle_dotdot()

static uint64_t path_handle_dotdot ( path_t path)
static

Definition at line 283 of file path.c.

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

Variable Documentation

◆ flagMap

map_t flagMap
static

Definition at line 15 of file path.c.

◆ flagShortMap

map_t flagShortMap
static

Definition at line 16 of file path.c.

◆ 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},
['t'] = {.mode = MODE_TRUNCATE},
['d'] = {.mode = MODE_DIRECTORY},
['R'] = {.mode = MODE_RECURSIVE},
}
@ MODE_CREATE
Definition path.h:81
@ MODE_APPEND
Definition path.h:80
@ MODE_EXECUTE
Definition path.h:78
@ MODE_NONBLOCK
Definition path.h:79
@ MODE_TRUNCATE
Definition path.h:83
@ MODE_WRITE
Definition path.h:77
@ MODE_RECURSIVE
Definition path.h:85
@ MODE_READ
Definition path.h:76
@ MODE_EXCLUSIVE
Definition path.h:82
@ MODE_DIRECTORY
Definition path.h:84

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_TRUNCATE, .name = "truncate"},
{.mode = MODE_DIRECTORY, .name = "directory"},
{.mode = MODE_RECURSIVE, .name = "recursive"},
}

Definition at line 42 of file path.c.