Nucleus
Barry Mount system call 64f99b6 (3 years, 3 months ago)
diff --git a/include/nucleus/vfs.h b/include/nucleus/vfs.h
index 19793bb..8ac8613 100644
--- a/include/nucleus/vfs.h
+++ b/include/nucleus/vfs.h
@@ -37,5 +37,7 @@ extern ObjectType inodeType;
void init_vfs(void);
void register_fstype(const char *name, mount_callback_t mount);
+int mount(const char *src, const char *target, const char *type,
+ unsigned long flags, void *data);
#endif
diff --git a/vfs/mount.c b/vfs/mount.c
new file mode 100644
index 0000000..472b30f
--- /dev/null
+++ b/vfs/mount.c
@@ -0,0 +1,34 @@
+/*
+ * This file handles mounting various file systems into the VFS. This is the
+ * mount system call.
+ */
+
+#include <errno.h>
+#include <nucleus/task.h>
+#include <nucleus/vfs.h>
+#include "namespace.h"
+
+int mount_fstype(const char *name, int flags, const char *src, void *data,
+ Inode **root);
+
+/* Mount a file system */
+int
+mount(const char *src, const char *target, const char *type,
+ unsigned long flags, void *data)
+{
+ Inode *mnt = NULL;
+ int res = mount_fstype(type, flags, src, data, &mnt);
+ if (res < 0)
+ return res;
+ if (!mnt)
+ return -ENODEV;
+
+ /* Mount as VFS root */
+ if (!target && !current->fs->root) {
+ current->fs->root = get(mnt);
+ current->fs->cwd = get(mnt);
+ return 0;
+ }
+
+ return 0;
+}