diff options
author | Kaimakan71 <undefined.foss@gmail.com> | 2024-04-27 09:21:31 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-04-27 20:27:42 -0400 |
commit | 5b6085504086f72939306337dfec01698b1a92cb (patch) | |
tree | d26c1bd0907109b2673a169b705628cfebb8f0a4 /sys/kern/vfs_mount.c | |
parent | a65592778b5cb6adde3ab53ebe758c4d875a0d79 (diff) |
kernel: vfs: Implement sys_mount()
Signed-off-by: Kaimakan71 <undefined.foss@gmail.com>
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/kern/vfs_mount.c')
-rw-r--r-- | sys/kern/vfs_mount.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 84985bf..25ad17d 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -34,6 +34,7 @@ #include <sys/errno.h> #include <vm/dynalloc.h> #include <assert.h> +#include <string.h> /* TODO: Make this more flexible */ #define MOUNTLIST_SIZE 8 @@ -60,6 +61,49 @@ vfs_create_mp(const char *path, int mntflags, struct mount **mp_out) return 0; } +static int +mount(const char *source, const char *target, const char *filesystemtype, + unsigned long mountflags, const void *data) +{ + struct fs_info *info; + int status; + + if (source == NULL || target == NULL || filesystemtype == NULL) + return -EFAULT; + + /* + * Check mount flags. + * + * XXX: No flags implemented yet. + */ + if (mountflags != 0) + return -EINVAL; + + /* + * Locate source. + * + * XXX: Only "none" is currently supported. + */ + if (strcmp(source, "none") != 0) + return -ENOENT; + + /* Locate filesystem */ + info = vfs_byname(filesystemtype); + if (info == NULL) + return -ENODEV; + + /* Create mount point */ + status = vfs_mount(target, 0, info); + if (status != 0) + return status; + + /* Initialize filesystem if needed */ + if (info->vfsops->init != NULL) + return info->vfsops->init(info); + + return 0; +} + /* * Mount a mountpoint * @@ -162,3 +206,10 @@ vfs_mount_init(void) TAILQ_INIT(&mountlist[i].buckets); } } + +uint64_t +sys_mount(struct syscall_args *args) +{ + return mount((void *)args->arg0, (void *)args->arg1, (void *)args->arg2, + (unsigned long)args->arg3, (void *)args->arg4); +} |