|
PatchworkOS
19e446b
A non-POSIX operating system.
|
#include <kernel/utils/map.h>#include <alloca.h>#include <ctype.h>#include <stdbool.h>#include <stdint.h>#include <sys/fs.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_MAX_DOTDOT 1000 |
Maximum iterations to handle .. in a path. | |
| #define | PATH_MAX_SYMLINK 40 |
| Maximum iterations to handle symlinks in a path. | |
| #define | PATH_EMPTY |
| Helper to create an empty path. | |
| #define | PATH_CREATE(inMount, inDentry) |
| Helper to create a path. | |
| #define | PATH_IS_EMPTY(path) ((path).mount == NULL && (path).dentry == NULL) |
| Check if a path is empty. | |
| #define | PATH_IS_VALID(path) ((path) != NULL && (path)->mount != NULL && (path)->dentry != NULL) |
| Check if a path is valid. | |
Typedefs | |
| typedef struct path | path_t |
| typedef struct mount | mount_t |
| typedef struct dentry | dentry_t |
| typedef struct namespace | namespace_t |
| typedef struct file | file_t |
Enumerations | |
| enum | mode_t { MODE_NONE = 0 , MODE_READ = 1 << 0 , MODE_WRITE = 1 << 1 , MODE_EXECUTE = 1 << 2 , MODE_NONBLOCK = 1 << 3 , MODE_APPEND = 1 << 4 , MODE_CREATE = 1 << 5 , MODE_EXCLUSIVE = 1 << 6 , MODE_PARENTS = 1 << 7 , MODE_TRUNCATE = 1 << 8 , MODE_DIRECTORY = 1 << 9 , MODE_RECURSIVE = 1 << 10 , MODE_NOFOLLOW = 1 << 11 , MODE_PRIVATE = 1 << 12 , MODE_PROPAGATE = 1 << 13 , MODE_LOCKED = 1 << 14 , MODE_ALL_PERMS = MODE_READ | MODE_WRITE | MODE_EXECUTE } |
| Path flags and permissions. More... | |
Functions | |
| 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_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. | |
| static void | path_defer_cleanup (path_t **path) |
| typedef struct namespace namespace_t |