BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / 00988dd2787481f6abbbb2b83fcc6745fbc85d01

// Related

Nucleus

Barry Inode object 00988dd (3 years, 3 months ago)
diff --git a/include/nucleus/vfs.h b/include/nucleus/vfs.h
new file mode 100644
index 0000000..f20cd47
--- /dev/null
+++ b/include/nucleus/vfs.h
@@ -0,0 +1,32 @@
+#ifndef _NUCLEUS_VFS_H
+#define _NUCLEUS_VFS_H
+
+#include <stddef.h>
+#include <sys/types.h>
+#include <nucleus/object.h>
+#include <nucleus/memory.h>
+
+typedef struct Inode Inode;
+typedef struct InodeOps InodeOps;
+
+/* Structure for an Inode */
+struct Inode {
+	Object obj;
+	ino_t ino;
+	uid_t uid;
+	gid_t gid;
+	mode_t mode;
+	nlink_t nlink;
+	size_t size;
+	dev_t dev;
+	InodeOps *ops;
+	union {
+		ObjectList *pages;
+	};
+};
+struct InodeOps {
+};
+
+extern ObjectType inodeType;
+
+#endif
diff --git a/vfs/inode.c b/vfs/inode.c
new file mode 100644
index 0000000..77b23ad
--- /dev/null
+++ b/vfs/inode.c
@@ -0,0 +1,45 @@
+/*
+ * This file implements the Inode object and associated inode operations.  Most
+ * of the functions here are just wrappers for the file system specific inode
+ * operations.  They generally check if the operation exists and use it if it
+ * does.  If one does not exist, a function may implement a generic action, or
+ * just simply return.  They also perform the necessary validation to ensure the
+ * operation can be called on the particular inode.
+ */
+
+#include <nucleus/object.h>
+#include <nucleus/memory.h>
+#include <nucleus/cache.h>
+#include <nucleus/vfs.h>
+
+static void inode_new(Object *);
+static void inode_delete(Object *);
+
+/* Inode object type */
+ObjectType inodeType = {
+	.size = sizeof(Inode),
+	.new = inode_new,
+	.delete = inode_delete,
+};
+
+/* Create a new Inode */
+static void
+inode_new(Object *obj)
+{
+	Inode *inode = (void *) obj;
+	inode->pages = create_list(&pageType);
+}
+
+/* Destroy an Inode */
+static void
+inode_delete(Object *obj)
+{
+	Inode *inode = (void *) obj;
+
+	/* Remove inode from the SuperBlock's list */
+//	if (inode->super)
+//		super_remove_inode(inode->super, inode);
+
+	/* Clean cache */
+	destroy_list(inode->pages);
+}