From 059b2450fb71520e9d0ee1e26dd5bb48c9b6ddf7 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 6 Oct 2025 17:46:47 -0400 Subject: kern: syscall: Add SYS_mount syscall This commit introduces the system call for mounting filesystems. As of now, only the fstype and target params are supported Signed-off-by: Ian Moffett --- src/sys/compat/unix/os/os_filedesc.c | 49 ++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'src/sys/compat/unix/os/os_filedesc.c') diff --git a/src/sys/compat/unix/os/os_filedesc.c b/src/sys/compat/unix/os/os_filedesc.c index 86bb62b..48ea6be 100644 --- a/src/sys/compat/unix/os/os_filedesc.c +++ b/src/sys/compat/unix/os/os_filedesc.c @@ -28,14 +28,15 @@ */ #include +#include +#include +#include #include #include #include #include #include -#include - /* * Write syscall * @@ -60,3 +61,47 @@ sys_write(struct syscall_args *scargs) return write(fd, kbuf, count); } + +/* + * ARG0: Source + * ARG1: Target + * ARG2: Filesystem type + * ARG3: Mountflags + * ARG4: Data + */ +scret_t +sys_mount(struct syscall_args *scargs) +{ + struct mount_args args; + char source[NAME_MAX]; + char target[NAME_MAX]; + char fstype[FSNAME_MAX]; + const char *u_source = SCARG(scargs, const char *, 0); + const char *u_target = SCARG(scargs, const char *, 1); + const char *u_fstype = SCARG(scargs, const char *, 2); + unsigned long u_mountflags = SCARG(scargs, unsigned long, 3); + int error; + + /* Get the filesystem source */ + error = copyinstr(u_source, source, sizeof(source)); + if (error < 0) { + source[0] = '\0'; + } + + /* Get the filesystem target */ + error = copyinstr(u_target, target, sizeof(target)); + if (error < 0) { + return error; + } + + /* Get the filesystem type */ + error = copyinstr(u_fstype, fstype, sizeof(u_fstype)); + if (error < 0) { + return error; + } + + args.source = source; + args.target = target; + args.fstype = fstype; + return kmount(&args, u_mountflags); +} -- cgit v1.2.3