BarryServer : Git

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

// Related

Nucleus

Barry SuperBlock Inode list fdbcccf (3 years, 3 months ago)
diff --git a/vfs/devfs/super.c b/vfs/devfs/super.c
index bfab4e9..20d9a35 100644
--- a/vfs/devfs/super.c
+++ b/vfs/devfs/super.c
@@ -38,7 +38,6 @@ devfs_alloc_inode(SuperBlock *sb)
 	Inode *inode = new(&inodeType);
 	inode->ops = &devfsInodeOps;
 	inode->fileOps = &devfsFileOps;
-	inode->super = get(sb);
 	inode->nlink = 1;
 	return inode;
 }
diff --git a/vfs/inode.c b/vfs/inode.c
index 03c301d..e4414cf 100644
--- a/vfs/inode.c
+++ b/vfs/inode.c
@@ -45,7 +45,7 @@ inode_delete(Object *obj)
 
 	/* Remove inode from the SuperBlock's list */
 	if (inode->super) {
-//		super_remove_inode(inode->super, inode);
+		remove(inode->super->inodes, inode);
 		put(inode->super);
 	}
 
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 */
diff --git a/vfs/tmpfs/super.c b/vfs/tmpfs/super.c
index 4746588..50376b0 100644
--- a/vfs/tmpfs/super.c
+++ b/vfs/tmpfs/super.c
@@ -33,7 +33,6 @@ tmpfs_alloc_inode(SuperBlock *sb)
 	Inode *inode = new(&inodeType);
 	inode->ops = &tmpfsInodeOps;
 	inode->fileOps = &tmpfsFileOps;
-	inode->super = get(sb);
 	inode->nlink = 1;
 	return inode;
 }