Volume-centric VFS implementation
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m41s

This commit is contained in:
2026-02-25 08:53:54 +01:00
parent 62a6543dab
commit 704db2dfa4
26 changed files with 441 additions and 406 deletions

View File

@@ -1,64 +1,6 @@
#include <fs/vfs.h>
#include <libk/fieldsizeof.h>
#include <libk/std.h>
bool path_validate_char (char ch) {
return ((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') ||
(ch == '_') || (ch == '-') || (ch == '/') || (ch == '.'));
}
bool path_validate (const char* path) {
if (path == NULL || *path == '\0')
return false;
const char* ptr = path;
if (*ptr != '/')
return false;
while (*ptr != '\0') {
if (*ptr == '/' && *(ptr + 1) == '/')
return false;
if (!path_validate_char (*ptr))
return false;
ptr++;
}
if (ptr > path + 1 && *(ptr - 1) == '/')
return false;
return true;
}
bool path_parse (const char* source, char* mountpoint, const char** path) {
if (source == NULL || mountpoint == NULL || path == NULL)
return false;
size_t i = 0;
while (source[i] != ':' && source[i] != '\0') {
if (i >= (fieldsizeof (struct vfs_mountpoint, key) - 1))
return false;
mountpoint[i] = source[i];
i++;
}
if (source[i] != ':' || i == 0)
return false;
mountpoint[i] = '\0';
const char* internal_path = &source[i + 1];
if (!path_validate (internal_path))
return false;
*path = internal_path;
return true;
}
#include <path_defs.h>
const char* path_basename (const char* path) {
if (path == NULL)