BarryServer : Git

All the code for all my projects
// BarryServer : Git / Orion / commit / e59e4fe0bbf5a3f56db0700ee49a81131b590f9c / vfs / ext2fs

// Related

Orion

Barry Adding pipes e59e4fe (2 years, 4 months ago)
diff --git a/vfs/ext2fs/block.c b/vfs/ext2fs/block.c
index 28cf480..08f2185 100644
--- a/vfs/ext2fs/block.c
+++ b/vfs/ext2fs/block.c
@@ -23,10 +23,32 @@ ext2_get_data_addr(SuperBlock *super, Ext2Inode *node, uint32_t index)
 {
 	uint32_t tmp;
 	char block[4096];
+	Ext2Super *rsuper = super->data;
+	/* Blocks per indirect block */
+	uint32_t bpib = (1024 << rsuper->blockSize) / sizeof(uint32_t);
 
 	/* Main blocks */
 	if (index < 12)
 		return node->directBlock[index];
 	index -= 12;
+
+	/* Single indirect block */
+	if (index < bpib) {
+		ext2_read_block(super, node->singleBlock, block);
+		return *((uint32_t *) block + index);
+	}
+	index -= bpib;
+
+	/* Double indirect block */
+	if (index < bpib*bpib) {
+		panic("Attempt to read from double indirect block");
+	}
+	index -= bpib*bpib;
+
+	/* Triple indirect block */
+	if (index < bpib*bpib*bpib) {
+		panic("Attempt to read from triple indirect block");
+	}
+
 	return 0;
 }