Nucleus
Barry File object 015db5a (3 years, 3 months ago)
diff --git a/vfs/direntry.c b/vfs/direntry.c
index f0953d1..a8a0110 100644
--- a/vfs/direntry.c
+++ b/vfs/direntry.c
@@ -14,6 +14,7 @@ struct FindData {
static void direntry_delete(Object *);
+/* Directory Entry object type */
ObjectType dirEntryType = {
.size = sizeof(DirEntry),
.delete = direntry_delete,
diff --git a/vfs/file.c b/vfs/file.c
new file mode 100644
index 0000000..8aef18f
--- /dev/null
+++ b/vfs/file.c
@@ -0,0 +1,30 @@
+/*
+ * This file implements the File object and associated functions. A file
+ * represents an opened file, and holds a reference the the underlying inode.
+ * Most of the functions here are just wrappers around the file operations.
+ * They perform the necessary validation to ensure the operation can be called
+ * on the particular file. If no operation is found, they may implement a
+ * generic version.
+ */
+
+#include <nucleus/object.h>
+#include <nucleus/vfs.h>
+
+static void file_delete(Object *);
+
+/* File object type */
+ObjectType fileType = {
+ .size = sizeof(File),
+ .delete = file_delete,
+};
+
+/* Destroy a file */
+static void
+file_delete(Object *obj)
+{
+ File *file = (void *) obj;
+ if (file->inode)
+ put(file->inode);
+ if (file->path)
+ destroy_list(file->path);
+}
diff --git a/vfs/superblock.c b/vfs/superblock.c
index 237f723..657ddc7 100644
--- a/vfs/superblock.c
+++ b/vfs/superblock.c
@@ -15,6 +15,7 @@ struct FindData {
Inode *result;
};
+/* Super Block object type */
ObjectType superBlockType = {
.size = sizeof(SuperBlock),
};