summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/include/sys/syscall.h1
-rw-r--r--sys/include/sys/vfs.h2
-rw-r--r--sys/kern/kern_syscall.c2
-rw-r--r--sys/kern/vfs_mount.c51
4 files changed, 56 insertions, 0 deletions
diff --git a/sys/include/sys/syscall.h b/sys/include/sys/syscall.h
index a2ca992..6a102aa 100644
--- a/sys/include/sys/syscall.h
+++ b/sys/include/sys/syscall.h
@@ -47,6 +47,7 @@ enum {
SYS_munmap,
SYS_ioctl,
SYS_execv,
+ SYS_mount,
__MAX_SYSCALLS
};
diff --git a/sys/include/sys/vfs.h b/sys/include/sys/vfs.h
index a55af12..98c784f 100644
--- a/sys/include/sys/vfs.h
+++ b/sys/include/sys/vfs.h
@@ -55,6 +55,8 @@ ssize_t vfs_read(struct vnode *vp, struct sio_txn *sio);
ssize_t vfs_write(struct vnode *vp, struct sio_txn *sio);
int vfs_getattr(struct vnode *vp, struct vattr *vattr);
+uint64_t sys_mount(struct syscall_args *args);
+
#endif /* defined(_KERNEL) */
#endif /* !_SYS_VFS_H_ */
diff --git a/sys/kern/kern_syscall.c b/sys/kern/kern_syscall.c
index 0461977..9faa5af 100644
--- a/sys/kern/kern_syscall.c
+++ b/sys/kern/kern_syscall.c
@@ -34,6 +34,7 @@
#include <sys/filedesc.h>
#include <sys/system.h>
#include <sys/exec.h>
+#include <sys/vfs.h>
#include <vm/map.h>
uint64_t(*g_syscall_table[__MAX_SYSCALLS])(struct syscall_args *args) = {
@@ -47,4 +48,5 @@ uint64_t(*g_syscall_table[__MAX_SYSCALLS])(struct syscall_args *args) = {
sys_munmap,
sys_ioctl,
sys_execv,
+ sys_mount
};
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);
+}