From 84b464a185d20d8e329b7aad0b482687a9705b58 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Sun, 8 Mar 2026 13:37:37 +0100 Subject: Add a path parsing mechanism Now the system can parse paths to files/directories. It follows the same Unix standard namespace. For now, only absolute paths are allowed. The parse mechanism relies on the struct path_part. Which represents each component on a single path. All the components are chain-linked through path_part->next, where the last path component will have ->next == NULL. This also introduces path_root struct, which represents the root of the path. The first component, linked to path_root->head, is always the "/" component. The disk_id represents the disk the root directory is found into. This should actually (and likely will) be a mountpoint not a disk id. Signed-off-by: Carlos Maiolino --- src/include/fs/path.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/include/fs/path.h (limited to 'src/include/fs') diff --git a/src/include/fs/path.h b/src/include/fs/path.h new file mode 100644 index 0000000..369e8b0 --- /dev/null +++ b/src/include/fs/path.h @@ -0,0 +1,25 @@ +#ifndef PATH_H +#define PATH_H + +/* + * Path structure follows unix format: + * + * /foo/bar/file + * + */ + +struct path_part { + const char *name; + struct path_part *next; +}; + +/* head is a linked list of all path components. + * the '/' is a component itself with name == NULL + */ +struct path_root { + int disk_id; + struct path_part *head; +}; + +struct path_root * parse_path(char *path); +#endif /* PATH_H */ -- cgit v1.2.3