summaryrefslogtreecommitdiff
path: root/src/kernel/vfs
diff options
context:
space:
mode:
authordzwdz2021-08-26 22:05:06 +0200
committerdzwdz2021-08-26 22:05:06 +0200
commit0876ffb05e6973601ef1e930f1ed8d939666132a (patch)
tree957f27d4027fa8549382a5d3a6b83a87316c3430 /src/kernel/vfs
parent7e6034c601aa04f27eaa605fa2639804eeca8280 (diff)
separate mount resolving into vfs_mount_resolve
Diffstat (limited to 'src/kernel/vfs')
-rw-r--r--src/kernel/vfs/mount.c13
-rw-r--r--src/kernel/vfs/mount.h3
2 files changed, 16 insertions, 0 deletions
diff --git a/src/kernel/vfs/mount.c b/src/kernel/vfs/mount.c
index be33b6b..bf98957 100644
--- a/src/kernel/vfs/mount.c
+++ b/src/kernel/vfs/mount.c
@@ -1,4 +1,5 @@
#include <kernel/mem.h>
+#include <kernel/util.h>
#include <kernel/vfs/mount.h>
struct vfs_mount *vfs_mount_seed(void) {
@@ -13,3 +14,15 @@ struct vfs_mount *vfs_mount_seed(void) {
};
return mount;
}
+
+struct vfs_mount *vfs_mount_resolve(
+ struct vfs_mount *top, const char *path, size_t path_len)
+{
+ for (; top; top = top->prev) {
+ if (top->prefix_len > path_len)
+ continue;
+ if (memcmp(top->prefix, path, top->prefix_len) == 0)
+ break;
+ }
+ return top;
+}
diff --git a/src/kernel/vfs/mount.h b/src/kernel/vfs/mount.h
index 982f951..51990a1 100644
--- a/src/kernel/vfs/mount.h
+++ b/src/kernel/vfs/mount.h
@@ -10,3 +10,6 @@ struct vfs_mount {
// prepares init's filesystem view
struct vfs_mount *vfs_mount_seed(void);
+struct vfs_mount *vfs_mount_resolve(
+ struct vfs_mount *top, const char *path, size_t path_len);
+