From 9600d3df3e1b75cff0e3ecd20ae3ca2fe393eb8b Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 21 Nov 2025 13:59:34 -0500 Subject: kern: vfs: Decouple mounting from initialization Upon bootup, all filesystems are to be enumerated and initialized before they are mounted. Some filesystems may decide to mount themselves right away. However, it is crucial to keep mounting and initialization seperate. Signed-off-by: Ian Moffett --- sys/kern/vfs_init.c | 11 +++++------ sys/kern/vfs_mount.c | 8 +++++++- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'sys/kern') diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c index 6372f3d..08be17a 100644 --- a/sys/kern/vfs_init.c +++ b/sys/kern/vfs_init.c @@ -87,18 +87,17 @@ vfs_init(void) continue; } - /* Mount if we can */ - if (ops->mount != NULL) { - error = ops->mount(fip, NULL); + /* Initialize the filesystem */ + if (ops->init != NULL) { + error = ops->init(fip); } if (error != 0) { - dtrace("failed to mount %s\n", fip->name); + dtrace("failed to init %s\n", fip->name); continue; } - dtrace("mounted %s\n", fip->name); - fip->is_mounted = 1; + dtrace("initialized %s\n", fip->name); ++mount_count; } diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 51a464a..39f98d2 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -74,6 +74,7 @@ int mount(struct mount_args *margs) { struct fs_info *fip; + struct vfsops *vfsops; struct mount *mp; int error; @@ -95,13 +96,18 @@ mount(struct mount_args *margs) return error; } + vfsops = fip->vfsops; + if (vfsops->mount == NULL) { + return -ENOTSUP; + } + mp = kalloc(sizeof(*mp)); if (mp == NULL) { return -ENOMEM; } mp->fip = fip; - error = vnode_init(&mp->vp, VDIR); + error = vfsops->mount(fip, mp); if (error < 0) { kfree(mp); return error; -- cgit v1.2.3