From 0876ffb05e6973601ef1e930f1ed8d939666132a Mon Sep 17 00:00:00 2001 From: dzwdz Date: Thu, 26 Aug 2021 22:05:06 +0200 Subject: separate mount resolving into vfs_mount_resolve --- src/kernel/vfs/mount.c | 13 +++++++++++++ src/kernel/vfs/mount.h | 3 +++ 2 files changed, 16 insertions(+) (limited to 'src/kernel/vfs') 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 +#include #include 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); + -- cgit v1.2.3