From 23f12d626f33bf03295ca4c1165155cfacec01ed Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 19 Sep 2025 13:20:40 -0400 Subject: kern: vfs: Add mountpoint lookup helper Add helper function to lookup mountpoints such as '/' Signed-off-by: Ian Moffett --- src/sys/os/vfs_mount.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/sys/os') diff --git a/src/sys/os/vfs_mount.c b/src/sys/os/vfs_mount.c index bfb5fc8..8f09096 100644 --- a/src/sys/os/vfs_mount.c +++ b/src/sys/os/vfs_mount.c @@ -112,6 +112,28 @@ mount_to(struct mount_args *margs, struct mount **mp_res, int flags) return 0; } +/* + * Lookup a specific mountpoint + */ +int +mount_lookup(const char *name, struct mount **mp_res) +{ + struct mount *mp; + + if (name == NULL || mp_res == NULL) { + return -EINVAL; + } + + TAILQ_FOREACH(mp, &root.list, link) { + if (strcmp(mp->name, name) == 0) { + *mp_res = mp; + return 0; + } + } + + return -ENOENT; +} + /* * Allocate a new mountpoint */ -- cgit v1.2.3