BarryServer : Git

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

// Related

Nucleus

Barry SuperBlock Inode list fdbcccf (3 years, 3 months ago)
diff --git a/vfs/superblock.c b/vfs/superblock.c
index 41f35b3..6c3776f 100644
--- a/vfs/superblock.c
+++ b/vfs/superblock.c
@@ -9,19 +9,43 @@
 #include <sys/types.h>
 #include <nucleus/vfs.h>
 
+static void super_block_new(Object *);
+static void super_block_delete(Object *);
+
 /* Super Block object type */
 ObjectType superBlockType = {
 	.name = "SUPER BLOCK",
 	.size = sizeof(SuperBlock),
+	.new = super_block_new,
+	.delete = super_block_delete,
 };
 
+/* Create a new SuperBlock object */
+static void
+super_block_new(Object *obj)
+{
+	SuperBlock *sb = (void *) obj;
+	sb->inodes = create_list(&inodeType);
+}
+
+/* Destroy SuperBlock object */
+static void
+super_block_delete(Object *obj)
+{
+	SuperBlock *sb = (void *) obj;
+	destroy_list(sb->inodes);
+}
+
 /* Allocate an Inode */
 Inode *
 super_alloc_inode(SuperBlock *sb)
 {
 	if (!sb->ops || !sb->ops->alloc_inode)
 		return NULL;
-	return sb->ops->alloc_inode(sb);
+	Inode *inode = sb->ops->alloc_inode(sb);
+	inode->super = get(sb);
+	add(sb->inodes, inode);
+	return inode;
 }
 
 /* Search for an Inode in a Super Block's Inode list */