tExt2_SuperBlock sb;\r
tExt2_Inode inode;\r
\r
+ ENTER("sDevice pOptions", Device, Options);\r
+ \r
// Open Disk\r
fd = VFS_Open(Device, VFS_OPENFLAG_READ|VFS_OPENFLAG_WRITE); //Open Device\r
if(fd == -1) {\r
- Warning("[EXT2] Unable to open '%s'\n", Device);\r
+ Warning("[EXT2 ] Unable to open '%s'\n", Device);\r
+ LEAVE('n');\r
return NULL;\r
}\r
\r
if(sb.s_magic != 0xEF53) {\r
Warning("[EXT2 ] Volume '%s' is not an EXT2 volume\n", Device);\r
VFS_Close(fd);\r
+ LEAVE('n');\r
return NULL;\r
}\r
\r
// Get Group count\r
groupCount = DivUp(sb.s_blocks_count, sb.s_blocks_per_group);\r
- //LogF(" Ext2_initDevice: groupCount = %i\n", groupCount);\r
+ LOG("groupCount = %i", groupCount);\r
\r
// Allocate Disk Information\r
disk = malloc(sizeof(tExt2_Disk) + sizeof(tExt2_Group)*groupCount);\r
+ if(!disk) {\r
+ Warning("[EXT2 ] Unable to allocate disk structure\n");\r
+ VFS_Close(fd);\r
+ LEAVE('n');\r
+ return NULL;\r
+ }\r
disk->FD = fd;\r
memcpy(&disk->SuperBlock, &sb, 1024);\r
disk->GroupCount = groupCount;\r
disk->CacheID = Inode_GetHandle();\r
\r
// Get Block Size\r
- //LogF(" Ext2_initDevice: s_log_block_size = 0x%x\n", sb.s_log_block_size);\r
+ LOG("s_log_block_size = 0x%x", sb.s_log_block_size);\r
disk->BlockSize = 1024 << sb.s_log_block_size;\r
\r
// Read Group Information\r
- VFS_ReadAt(disk->FD,\r
+ VFS_ReadAt(\r
+ disk->FD,\r
sb.s_first_data_block * disk->BlockSize + 1024,\r
sizeof(tExt2_Group)*groupCount,\r
- disk->Groups);\r
- \r
- #if 0\r
- Log(" Ext2_initDevice: Block Group 0\n");\r
- Log(" Ext2_initDevice: .bg_block_bitmap = 0x%x\n", disk->Groups[0].bg_block_bitmap);\r
- Log(" Ext2_initDevice: .bg_inode_bitmap = 0x%x\n", disk->Groups[0].bg_inode_bitmap);\r
- Log(" Ext2_initDevice: .bg_inode_table = 0x%x\n", disk->Groups[0].bg_inode_table);\r
- Log(" Ext2_initDevice: Block Group 1\n");\r
- Log(" Ext2_initDevice: .bg_block_bitmap = 0x%x\n", disk->Groups[1].bg_block_bitmap);\r
- Log(" Ext2_initDevice: .bg_inode_bitmap = 0x%x\n", disk->Groups[1].bg_inode_bitmap);\r
- Log(" Ext2_initDevice: .bg_inode_table = 0x%x\n", disk->Groups[1].bg_inode_table);\r
+ disk->Groups\r
+ );\r
+ \r
+ #if DEBUG\r
+ LOG("Block Group 0");\r
+ LOG(".bg_block_bitmap = 0x%x", disk->Groups[0].bg_block_bitmap);\r
+ LOG(".bg_inode_bitmap = 0x%x", disk->Groups[0].bg_inode_bitmap);\r
+ LOG(".bg_inode_table = 0x%x", disk->Groups[0].bg_inode_table);\r
+ LOG("Block Group 1");\r
+ LOG(".bg_block_bitmap = 0x%x", disk->Groups[1].bg_block_bitmap);\r
+ LOG(".bg_inode_bitmap = 0x%x", disk->Groups[1].bg_inode_bitmap);\r
+ LOG(".bg_inode_table = 0x%x", disk->Groups[1].bg_inode_table);\r
#endif\r
\r
// Get root Inode\r
disk->RootNode.NumACLs = 1;\r
disk->RootNode.ACLs = &gVFS_ACL_EveryoneRW;\r
\r
- #if 0\r
- Log(" Ext2_InitDevice: inode.i_size = 0x%x\n", inode.i_size);\r
- Log(" Ext2_InitDevice: inode.i_block[0] = 0x%x\n", inode.i_block[0]);\r
+ #if DEBUG\r
+ LOG("inode.i_size = 0x%x", inode.i_size);\r
+ LOG("inode.i_block[0] = 0x%x", inode.i_block[0]);\r
#endif\r
\r
+ LEAVE('p', &disk->RootNode);\r
return &disk->RootNode;\r
}\r
\r
Uint block;\r
Uint64 remLen;\r
\r
+ ENTER("pNode XOffset XLength pBuffer", Node, Offset, Length, Buffer);\r
+ \r
// Get Inode\r
Ext2_int_GetInode(Node, &inode);\r
\r
if(Length <= disk->BlockSize - Offset)\r
{\r
VFS_ReadAt( disk->FD, base+Offset, Length, Buffer);\r
+ LEAVE('X', Length);\r
return Length;\r
}\r
\r
base = Ext2_int_GetBlockAddr(disk, inode.i_block, block);\r
VFS_ReadAt( disk->FD, base, remLen, Buffer);\r
\r
+ LEAVE('X', Length);\r
return Length;\r
}\r
\r
\r
// Read Entry\r
VFS_ReadAt( disk->FD, Base+ofs, sizeof(tExt2_DirEnt), &dirent );\r
- //LOG(" Ext2_ReadDir: dirent.inode = %i\n", dirent.inode);\r
- //LOG(" Ext2_ReadDir: dirent.rec_len = %i\n", dirent.rec_len);\r
- //LOG(" Ext2_ReadDir: dirent.name_len = %i\n", dirent.name_len);\r
+ //LOG("dirent.inode = %i\n", dirent.inode);\r
+ //LOG("dirent.rec_len = %i\n", dirent.rec_len);\r
+ //LOG("dirent.name_len = %i\n", dirent.name_len);\r
VFS_ReadAt( disk->FD, Base+ofs+sizeof(tExt2_DirEnt), dirent.name_len, namebuf );\r
namebuf[ dirent.name_len ] = '\0'; // Cap off string\r
\r