BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / b085b2618dada4e753dc58cad71c21a21eb1c998 / vfs / namespace.c

// Related

Nucleus

Barry File system namespace b085b26 (3 years, 3 months ago)
diff --git a/vfs/namespace.c b/vfs/namespace.c
new file mode 100644
index 0000000..1cf7515
--- /dev/null
+++ b/vfs/namespace.c
@@ -0,0 +1,38 @@
+/*
+ * This file implements the File System object, which is the namespace for a
+ * task's files.  It tracks a task's root and current working directory.
+ */
+
+#include <nucleus/object.h>
+#include <nucleus/vfs.h>
+#include "namespace.h"
+
+static void file_system_new(Object *);
+static void file_system_copy(Object *, Object *);
+
+/* File System object type */
+ObjectType fsType = {
+	.size = sizeof(FileSystem),
+	.new = file_system_new,
+	.copy = file_system_copy,
+};
+
+/* Create a new File System object */
+static void
+file_system_new(Object *obj)
+{
+	FileSystem *fs = (void *) obj;
+	fs->cwdPath = create_list(&dirEntryType);
+}
+
+/* Copy a File System object */
+static void
+file_system_copy(Object *a, Object *b)
+{
+	FileSystem *parent = (void *) a, *child = (void *) b;
+	child->cwd = get(parent->cwd);
+	/* init cwd custody chain */
+	child->cwdPath = copy_list(parent->cwdPath);
+	/* copy cwd custody chain */
+	child->root = get(parent->root);
+}