PatchworkOS
Loading...
Searching...
No Matches
path.h File Reference
#include <kernel/utils/map.h>
#include <alloca.h>
#include <ctype.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/io.h>

Go to the source code of this file.

Data Structures

struct  path_t
 Path structure. More...
 
struct  pathname_t
 Pathname structure. More...
 

Macros

#define PATH_DEFER(path)   __attribute__((cleanup(path_defer_cleanup))) path_t* CONCAT(i, __COUNTER__) = (path)
 Defer path put.
 
#define PATH_VALID_CHAR(ch)    (strchr("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-. ()[]{}~!@#$%^&?',;=+", (ch)))
 Check if a char is valid.
 
#define PATH_HANDLE_DOTDOT_MAX_ITER   1000
 Maximum iterations to handle .. in a path.
 
#define PATHNAME_IS_VALID(pathname)   ((pathname) != NULL && (pathname)->isValid)
 Check if a pathname is valid.
 
#define PATHNAME(string)
 Helper to create a pathname.
 
#define PATH_EMPTY
 Helper to create an empty path.
 
#define PATH_CREATE(inMount, inDentry)
 Helper to create a path.
 

Typedefs

typedef struct path path_t
 
typedef struct mount mount_t
 
typedef struct dentry dentry_t
 

Enumerations

enum  path_flags_t {
  PATH_NONE = 0 ,
  PATH_NONBLOCK = 1 << 0 ,
  PATH_APPEND = 1 << 1 ,
  PATH_CREATE = 1 << 2 ,
  PATH_EXCLUSIVE = 1 << 3 ,
  PATH_TRUNCATE = 1 << 4 ,
  PATH_DIRECTORY = 1 << 5 ,
  PATH_RECURSIVE = 1 << 6 ,
  PATH_FLAGS_AMOUNT = 7
}
 Path flags. More...
 
enum  walk_flags_t {
  WALK_NONE = 0 ,
  WALK_NEGATIVE_IS_OK = 1 << 0
}
 Flags for walking a path. More...
 

Functions

void path_flags_init (void)
 Initialize path flags resolution.
 
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.
 
uint64_t path_walk_single_step (path_t *outPath, const path_t *parent, const char *name, walk_flags_t flags, namespace_t *ns)
 Traverse a single component from a parent path.
 
uint64_t path_walk (path_t *outPath, const pathname_t *pathname, const path_t *start, walk_flags_t flags, namespace_t *ns)
 Traverse a pathname from a specified starting path.
 
uint64_t path_walk_parent (path_t *outPath, const pathname_t *pathname, const path_t *start, char *outLastName, walk_flags_t flags, namespace_t *ns)
 Traverse a pathname to its parent and get the last component name.
 
uint64_t path_to_name (const path_t *path, pathname_t *pathname)
 Convert a path to a pathname.
 
static void path_defer_cleanup (path_t **path)
 

Typedef Documentation

◆ dentry_t

typedef struct dentry dentry_t

Definition at line 13 of file path.h.

◆ mount_t

typedef struct mount mount_t

Definition at line 12 of file path.h.

◆ path_t

typedef struct path path_t

Definition at line 11 of file path.h.