Nucleus
Barry Files namespace f0dcd54 (3 years, 3 months ago)
diff --git a/vfs/namespace.c b/vfs/namespace.c
index 1cf7515..638453f 100644
--- a/vfs/namespace.c
+++ b/vfs/namespace.c
@@ -1,6 +1,6 @@
/*
* 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.
+ * task's file system. It tracks a task's root and current working directory.
*/
#include <nucleus/object.h>
@@ -8,12 +8,15 @@
#include "namespace.h"
static void file_system_new(Object *);
+static void file_system_delete(Object *);
static void file_system_copy(Object *, Object *);
/* File System object type */
ObjectType fsType = {
+ .name = "FILE SYSTEM",
.size = sizeof(FileSystem),
.new = file_system_new,
+ .delete = file_system_delete,
.copy = file_system_copy,
};
@@ -25,14 +28,22 @@ file_system_new(Object *obj)
fs->cwdPath = create_list(&dirEntryType);
}
+/* Destory a File System object */
+static void
+file_system_delete(Object *obj)
+{
+ FileSystem *fs = (void *) obj;
+ put(fs->cwd);
+ destroy_list(fs->cwdPath);
+ put(fs->root);
+}
+
/* 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);
}