aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/vfs_mount.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-04-09 22:48:53 -0400
committerIan Moffett <ian@osmora.org>2024-04-09 22:48:53 -0400
commite326f77a5441abbacd23b8309a59e744999779ca (patch)
treea3d65aa32971f8ab42789e26db7725f3ac7a75a2 /sys/kern/vfs_mount.c
parent0103817eb5b580d769e793c8bef053eb077fa0be (diff)
kernel: vfs_mount: Fix mount code
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/kern/vfs_mount.c')
-rw-r--r--sys/kern/vfs_mount.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 3efd7a7..84985bf 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -63,23 +63,32 @@ vfs_create_mp(const char *path, int mntflags, struct mount **mp_out)
/*
* Mount a mountpoint
*
- * @mp: Mountpoint to mount
* @path: Path this mountpoint belongs to
+ * @mntflags: Flags to mount with
+ * @fs: Filesystem to mount
*
* If this mount entry already exists, -EEXIST
* will be returned.
*/
int
-vfs_mount(const char *path, int mntflags)
+vfs_mount(const char *path, int mntflags, struct fs_info *fs)
{
size_t hash;
int status;
struct mountlist_entry *entry;
struct mount *mp;
+ /* Exclude leading slash */
+ if (*path == '/') {
+ ++path;
+ }
+
+ hash = vfs_hash_path(path);
+
if ((status = vfs_create_mp(path, mntflags, &mp)) != 0) {
return status;
}
+
if (hash == -1) {
/* Something is wrong with the path */
return -EINVAL;
@@ -90,13 +99,14 @@ vfs_mount(const char *path, int mntflags)
return -EEXIST;
}
- mp->phash = hash;
- status = vfs_alloc_vnode(&mp->vnode, mp, VDIR);
-
- if (status != 0) {
+ if ((status = vfs_alloc_vnode(&fs->vnode, mp, VDIR)) != 0) {
return status;
}
+ mp->phash = hash;
+ mp->fs = fs;
+ fs->vnode->vops = fs->vops;
+
entry = &mountlist[hash % MOUNTLIST_SIZE];
TAILQ_INSERT_TAIL(&entry->buckets, mp, link);
return 0;
@@ -115,10 +125,17 @@ vfs_mount(const char *path, int mntflags)
int
vfs_get_mp(const char *path, struct mount **mp)
{
- size_t hash = vfs_hash_path(path);
+ size_t hash;
struct mountlist_entry *entry;
struct mount *mount_iter;
+ /* Exclude leading slash */
+ if (*path == '/') {
+ ++path;
+ }
+
+ hash = vfs_hash_path(path);
+
if (hash == 0) {
/* Something is wrong with the path */
return -EINVAL;