3 * Ext2 Driver Version 1
7 * \brief Second Extended Filesystem Driver
8 * \todo Implement file full write support
12 #include "ext2_common.h"
15 Uint64 Ext2_Read(tVFS_Node *node, Uint64 offset, Uint64 length, void *buffer);
19 * \fn Uint64 Ext2_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
20 * \brief Read from a file
22 Uint64 Ext2_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer)
24 tExt2_Disk *disk = Node->ImplPtr;
30 ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);
33 Ext2_int_ReadInode(disk, Node->Inode, &inode);
36 if(Offset >= inode.i_size) {
40 if(Offset + Length > inode.i_size)
41 Length = inode.i_size - Offset;
43 block = Offset / disk->BlockSize;
44 Offset = Offset / disk->BlockSize;
45 base = Ext2_int_GetBlockAddr(disk, inode.i_block, block);
47 Warning("[EXT2 ] NULL Block Detected in INode 0x%llx", Node->Inode);
53 if(Length <= disk->BlockSize - Offset)
55 VFS_ReadAt( disk->FD, base+Offset, Length, Buffer);
62 VFS_ReadAt( disk->FD, base + Offset, disk->BlockSize - Offset, Buffer);
63 remLen -= disk->BlockSize - Offset;
64 Buffer += disk->BlockSize - Offset;
68 while(remLen > disk->BlockSize)
70 base = Ext2_int_GetBlockAddr(disk, inode.i_block, block);
72 Warning("[EXT2 ] NULL Block Detected in INode 0x%llx", Node->Inode);
76 VFS_ReadAt( disk->FD, base, disk->BlockSize, Buffer);
77 Buffer += disk->BlockSize;
78 remLen -= disk->BlockSize;
83 base = Ext2_int_GetBlockAddr(disk, inode.i_block, block);
84 VFS_ReadAt( disk->FD, base, remLen, Buffer);