3 * Ext2 Driver Version 1
7 * \brief Second Extended Filesystem Driver
8 * \todo Implement file full write support
12 #include "ext2_common.h"
16 * \brief Read from a file
18 size_t Ext2_Read(tVFS_Node *Node, off_t Offset, size_t Length, void *Buffer)
20 tExt2_Disk *disk = Node->ImplPtr;
26 ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
29 Ext2_int_ReadInode(disk, Node->Inode, &inode);
32 if(Offset >= inode.i_size) {
36 if(Offset + Length > inode.i_size)
37 Length = inode.i_size - Offset;
39 block = Offset / disk->BlockSize;
40 Offset = Offset / disk->BlockSize;
41 base = Ext2_int_GetBlockAddr(disk, inode.i_block, block);
43 Warning("[EXT2 ] NULL Block Detected in INode 0x%llx", Node->Inode);
49 if(Length <= disk->BlockSize - Offset)
51 VFS_ReadAt( disk->FD, base+Offset, Length, Buffer);
58 VFS_ReadAt( disk->FD, base + Offset, disk->BlockSize - Offset, Buffer);
59 remLen -= disk->BlockSize - Offset;
60 Buffer += disk->BlockSize - Offset;
64 while(remLen > disk->BlockSize)
66 base = Ext2_int_GetBlockAddr(disk, inode.i_block, block);
68 Warning("[EXT2 ] NULL Block Detected in INode 0x%llx", Node->Inode);
72 VFS_ReadAt( disk->FD, base, disk->BlockSize, Buffer);
73 Buffer += disk->BlockSize;
74 remLen -= disk->BlockSize;
79 base = Ext2_int_GetBlockAddr(disk, inode.i_block, block);
80 VFS_ReadAt( disk->FD, base, remLen, Buffer);