From b7816ab497682a5f73e08729a3862e9944b9623f Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 22 Nov 2025 17:50:46 -0500 Subject: kern: mount: Split mounting logic into types Signed-off-by: Ian Moffett --- sys/kern/vfs_mount.c | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'sys') diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index bfbc355..5c94b16 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -70,27 +71,18 @@ mountlist_init(void) is_mountlist_init = true; } -int -mount(struct mount_args *margs) +static int +mount_by_fsname(struct mount_args *margs, struct mount **mp_res) { + struct mount *mp; struct fs_info *fip; struct vfsops *vfsops; - struct mount *mp; int error; - if (margs == NULL) { - return -EINVAL; - } - - if (margs->target == NULL || margs->fstype == NULL) { + if (margs == NULL || mp_res == NULL) { return -EINVAL; } - /* Initialize the mountlist if needed */ - if (!is_mountlist_init) { - mountlist_init(); - } - error = vfs_byname(margs->fstype, &fip); if (error != 0) { return error; @@ -113,9 +105,34 @@ mount(struct mount_args *margs) return error; } - /* - * TODO: We'd need to do a namei() here, add by-path - */ + *mp_res = mp; +} + +int +mount(struct mount_args *margs) +{ + struct mount *mp; + struct nameidata ndp; + int error; + + if (margs == NULL) { + return -EINVAL; + } + + if (margs->target == NULL || margs->fstype == NULL) { + return -EINVAL; + } + + /* Initialize the mountlist if needed */ + if (!is_mountlist_init) { + mountlist_init(); + } + + error = mount_by_fsname(margs, &mp); + if (error != 0) { + return error; + } + spinlock_acquire(&mount_lock, true); TAILQ_INSERT_TAIL(&mountlist, mp, link); spinlock_release(&mount_lock, true); -- cgit v1.2.3