Orion
Barry Importing existing Orion kernel d41a53c (2 years, 4 months ago)diff --git a/vfs/ext2fs/block.c b/vfs/ext2fs/block.c new file mode 100644 index 0000000..28cf480 --- /dev/null +++ b/vfs/ext2fs/block.c @@ -0,0 +1,32 @@ +/* + * This file contains the Ext2 block implementation. It reads a backing file + * from the super block in the intervals specified by the superblock. It also + * contains functions for reading blocks from files. + */ + +#include <stdint.h> +#include "fs.h" + +/* Read a block of data */ +void +ext2_read_block(SuperBlock *super, uint32_t index, char *buf) +{ + Ext2Super *rsuper = super->data; + + super->back->pos = index * (1024 << rsuper->blockSize); + file_read(super->back, buf, 1024 << rsuper->blockSize); +} + +/* Get the data block address from inode block index */ +uint32_t +ext2_get_data_addr(SuperBlock *super, Ext2Inode *node, uint32_t index) +{ + uint32_t tmp; + char block[4096]; + + /* Main blocks */ + if (index < 12) + return node->directBlock[index]; + index -= 12; + return 0; +}