summaryrefslogtreecommitdiff
path: root/src/sys/compat
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-10-06 17:46:47 -0400
committerIan Moffett <ian@osmora.org>2025-10-06 17:47:12 -0400
commit059b2450fb71520e9d0ee1e26dd5bb48c9b6ddf7 (patch)
tree320dc8ad1205bacc86143a7bbb3918bb1925318b /src/sys/compat
parente8723abcad202fc12c3e32879c9865bae524e9ce (diff)
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 <ian@osmora.org>
Diffstat (limited to 'src/sys/compat')
-rw-r--r--src/sys/compat/unix/os/os_filedesc.c49
1 files changed, 47 insertions, 2 deletions
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 <sys/syscall.h>
+#include <sys/limits.h>
+#include <sys/syslog.h>
+#include <sys/mount.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <os/systm.h>
#include <os/filedesc.h>
#include <compat/unix/syscall.h>
-#include <sys/syslog.h>
-
/*
* 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);
+}