Author: dgorbachev
Date: Sun Aug 9 00:39:04 2009
New Revision: 42541
URL:
http://svn.reactos.org/svn/reactos?rev=42541&view=rev
Log:
Fix issue #4673 ("Misrepresented license in FreeLDR"), Robert Millan
(rmh.reactos at
aybabtu.com).
Modified:
trunk/reactos/boot/freeldr/freeldr/fs/ext2.c
trunk/reactos/boot/freeldr/freeldr/fs/fsrec.c
trunk/reactos/boot/freeldr/freeldr/include/fs/ext2.h
Modified: trunk/reactos/boot/freeldr/freeldr/fs/ext2.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/fs/ex…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/fs/ext2.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/fs/ext2.c [iso-8859-1] Sun Aug 9 00:39:04 2009
@@ -45,13 +45,13 @@
BOOLEAN Ext2CopyDoubleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList,
ULONG BlockCount, ULONG DoubleIndirectBlock);
BOOLEAN Ext2CopyTripleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList,
ULONG BlockCount, ULONG TripleIndirectBlock);
-GEOMETRY Ext2DiskGeometry; // Ext2 file system disk geometry
+GEOMETRY Ext2DiskGeometry; // Ext2 file system disk geometry
PEXT2_SUPER_BLOCK Ext2SuperBlock = NULL; // Ext2 file system super block
PEXT2_GROUP_DESC Ext2GroupDescriptors = NULL; // Ext2 file system group descriptors
UCHAR Ext2DriveNumber = 0; // Ext2 file system drive number
-ULONGLONG Ext2VolumeStartSector = 0; // Ext2 file system starting sector
+ULONGLONG Ext2VolumeStartSector = 0; // Ext2 file system starting sector
ULONG Ext2BlockSizeInBytes = 0; // Block size in bytes
ULONG Ext2BlockSizeInSectors = 0; // Block size in sectors
ULONG Ext2FragmentSizeInBytes = 0; // Fragment size in bytes
@@ -106,13 +106,13 @@
{
EXT2_FILE_INFO TempExt2FileInfo;
PEXT2_FILE_INFO FileHandle;
- CHAR SymLinkPath[EXT3_NAME_LEN];
- CHAR FullPath[EXT3_NAME_LEN * 2];
- ULONG Index;
+ CHAR SymLinkPath[EXT2_NAME_LEN];
+ CHAR FullPath[EXT2_NAME_LEN * 2];
+ ULONG Index;
DPRINTM(DPRINT_FILESYSTEM, "Ext2OpenFile() FileName = %s\n", FileName);
- RtlZeroMemory(SymLinkPath, EXT3_NAME_LEN);
+ RtlZeroMemory(SymLinkPath, sizeof(SymLinkPath));
// Lookup the file in the file system
if (!Ext2LookupFile(FileName, &TempExt2FileInfo))
@@ -122,7 +122,7 @@
// If we got a symbolic link then fix up the path
// and re-call this function
- if ((TempExt2FileInfo.Inode.i_mode & EXT2_S_IFMT) == EXT2_S_IFLNK)
+ if ((TempExt2FileInfo.Inode.mode & EXT2_S_IFMT) == EXT2_S_IFLNK)
{
DPRINTM(DPRINT_FILESYSTEM, "File is a symbolic link\n");
@@ -207,12 +207,12 @@
*/
BOOLEAN Ext2LookupFile(PCSTR FileName, PEXT2_FILE_INFO Ext2FileInfoPointer)
{
- UINT32 i;
- ULONG NumberOfPathParts;
- CHAR PathPart[261];
- PVOID DirectoryBuffer;
- ULONG DirectoryInode = EXT3_ROOT_INO;
- EXT2_INODE InodeData;
+ UINT32 i;
+ ULONG NumberOfPathParts;
+ CHAR PathPart[261];
+ PVOID DirectoryBuffer;
+ ULONG DirectoryInode = EXT2_ROOT_INO;
+ EXT2_INODE InodeData;
EXT2_DIR_ENTRY DirectoryEntry;
DPRINTM(DPRINT_FILESYSTEM, "Ext2LookupFile() FileName = %s\n", FileName);
@@ -269,8 +269,8 @@
return FALSE;
}
- if (((InodeData.i_mode & EXT2_S_IFMT) != EXT2_S_IFREG) &&
- ((InodeData.i_mode & EXT2_S_IFMT) != EXT2_S_IFLNK))
+ if (((InodeData.mode & EXT2_S_IFMT) != EXT2_S_IFREG) &&
+ ((InodeData.mode & EXT2_S_IFMT) != EXT2_S_IFLNK))
{
FileSystemError("Inode is not a regular file or symbolic link.");
return FALSE;
@@ -282,8 +282,8 @@
// If it's a regular file or a regular symbolic link
// then get the block pointer list otherwise it must
// be a fast symbolic link which doesn't have a block list
- if (((InodeData.i_mode & EXT2_S_IFMT) == EXT2_S_IFREG) ||
- ((InodeData.i_mode & EXT2_S_IFMT) == EXT2_S_IFLNK && InodeData.i_size >
FAST_SYMLINK_MAX_NAME_SIZE))
+ if (((InodeData.mode & EXT2_S_IFMT) == EXT2_S_IFREG) ||
+ ((InodeData.mode & EXT2_S_IFMT) == EXT2_S_IFLNK && InodeData.size >
FAST_SYMLINK_MAX_NAME_SIZE))
{
Ext2FileInfoPointer->FileBlockList = Ext2ReadBlockPointerList(&InodeData);
@@ -306,7 +306,7 @@
BOOLEAN Ext2SearchDirectoryBufferForFile(PVOID DirectoryBuffer, ULONG DirectorySize,
PCHAR FileName, PEXT2_DIR_ENTRY DirectoryEntry)
{
- ULONG CurrentOffset;
+ ULONG CurrentOffset;
PEXT2_DIR_ENTRY CurrentDirectoryEntry;
DPRINTM(DPRINT_FILESYSTEM, "Ext2SearchDirectoryBufferForFile() DirectoryBuffer =
0x%x DirectorySize = %d FileName = %s\n", DirectoryBuffer, DirectorySize, FileName);
@@ -315,32 +315,32 @@
{
CurrentDirectoryEntry = (PEXT2_DIR_ENTRY)((ULONG_PTR)DirectoryBuffer + CurrentOffset);
- if (CurrentDirectoryEntry->rec_len == 0)
+ if (CurrentDirectoryEntry->direntlen == 0)
{
break;
}
- if ((CurrentDirectoryEntry->rec_len + CurrentOffset) > DirectorySize)
+ if ((CurrentDirectoryEntry->direntlen + CurrentOffset) > DirectorySize)
{
FileSystemError("Directory entry extends past end of directory file.");
return FALSE;
}
DPRINTM(DPRINT_FILESYSTEM, "Dumping directory entry at offset %d:\n",
CurrentOffset);
- DbgDumpBuffer(DPRINT_FILESYSTEM, CurrentDirectoryEntry,
CurrentDirectoryEntry->rec_len);
-
- if ((_strnicmp(FileName, CurrentDirectoryEntry->name,
CurrentDirectoryEntry->name_len) == 0) &&
- (strlen(FileName) == CurrentDirectoryEntry->name_len))
+ DbgDumpBuffer(DPRINT_FILESYSTEM, CurrentDirectoryEntry,
CurrentDirectoryEntry->direntlen);
+
+ if ((_strnicmp(FileName, CurrentDirectoryEntry->name,
CurrentDirectoryEntry->namelen) == 0) &&
+ (strlen(FileName) == CurrentDirectoryEntry->namelen))
{
RtlCopyMemory(DirectoryEntry, CurrentDirectoryEntry, sizeof(EXT2_DIR_ENTRY));
DPRINTM(DPRINT_FILESYSTEM, "EXT2 Directory Entry:\n");
DPRINTM(DPRINT_FILESYSTEM, "inode = %d\n", DirectoryEntry->inode);
- DPRINTM(DPRINT_FILESYSTEM, "rec_len = %d\n", DirectoryEntry->rec_len);
- DPRINTM(DPRINT_FILESYSTEM, "name_len = %d\n", DirectoryEntry->name_len);
- DPRINTM(DPRINT_FILESYSTEM, "file_type = %d\n",
DirectoryEntry->file_type);
+ DPRINTM(DPRINT_FILESYSTEM, "direntlen = %d\n",
DirectoryEntry->direntlen);
+ DPRINTM(DPRINT_FILESYSTEM, "namelen = %d\n", DirectoryEntry->namelen);
+ DPRINTM(DPRINT_FILESYSTEM, "filetype = %d\n", DirectoryEntry->filetype);
DPRINTM(DPRINT_FILESYSTEM, "name = ");
- for (CurrentOffset=0; CurrentOffset<DirectoryEntry->name_len; CurrentOffset++)
+ for (CurrentOffset=0; CurrentOffset<DirectoryEntry->namelen; CurrentOffset++)
{
DPRINTM(DPRINT_FILESYSTEM, "%c", DirectoryEntry->name[CurrentOffset]);
}
@@ -349,7 +349,7 @@
return TRUE;
}
- CurrentOffset += CurrentDirectoryEntry->rec_len;
+ CurrentOffset += CurrentDirectoryEntry->direntlen;
}
return FALSE;
@@ -380,7 +380,7 @@
{
// Block pointer list is NULL
// so this better be a fast symbolic link or else
- if (((Ext2FileInfo->Inode.i_mode & EXT2_S_IFMT) != EXT2_S_IFLNK) ||
+ if (((Ext2FileInfo->Inode.mode & EXT2_S_IFMT) != EXT2_S_IFLNK) ||
(Ext2FileInfo->FileSize > FAST_SYMLINK_MAX_NAME_SIZE))
{
FileSystemError("Block pointer list is NULL and file is not a fast symbolic
link.");
@@ -409,13 +409,13 @@
// Check if this is a fast symbolic link
// if so then the read is easy
- if (((Ext2FileInfo->Inode.i_mode & EXT2_S_IFMT) == EXT2_S_IFLNK) &&
+ if (((Ext2FileInfo->Inode.mode & EXT2_S_IFMT) == EXT2_S_IFLNK) &&
(Ext2FileInfo->FileSize <= FAST_SYMLINK_MAX_NAME_SIZE))
{
DPRINTM(DPRINT_FILESYSTEM, "Reading fast symbolic link data\n");
// Copy the data from the link
- RtlCopyMemory(Buffer, (PVOID)((ULONG_PTR)Ext2FileInfo->FilePointer +
Ext2FileInfo->Inode.i_block), BytesToRead);
+ RtlCopyMemory(Buffer, (PVOID)((ULONG_PTR)Ext2FileInfo->FilePointer +
Ext2FileInfo->Inode.symlink), BytesToRead);
if (BytesRead != NULL)
{
@@ -596,60 +596,47 @@
RtlCopyMemory(Ext2SuperBlock, (PVOID)((ULONG_PTR)DISKREADBUFFER + 1024), 1024);
DPRINTM(DPRINT_FILESYSTEM, "Dumping super block:\n");
-
- DPRINTM(DPRINT_FILESYSTEM, "s_inodes_count: %d\n",
Ext2SuperBlock->s_inodes_count);
- DPRINTM(DPRINT_FILESYSTEM, "s_blocks_count: %d\n",
Ext2SuperBlock->s_blocks_count);
- DPRINTM(DPRINT_FILESYSTEM, "s_r_blocks_count: %d\n",
Ext2SuperBlock->s_r_blocks_count);
- DPRINTM(DPRINT_FILESYSTEM, "s_free_blocks_count: %d\n",
Ext2SuperBlock->s_free_blocks_count);
- DPRINTM(DPRINT_FILESYSTEM, "s_free_inodes_count: %d\n",
Ext2SuperBlock->s_free_inodes_count);
- DPRINTM(DPRINT_FILESYSTEM, "s_first_data_block: %d\n",
Ext2SuperBlock->s_first_data_block);
- DPRINTM(DPRINT_FILESYSTEM, "s_log_block_size: %d\n",
Ext2SuperBlock->s_log_block_size);
- DPRINTM(DPRINT_FILESYSTEM, "s_log_frag_size: %d\n",
Ext2SuperBlock->s_log_frag_size);
- DPRINTM(DPRINT_FILESYSTEM, "s_blocks_per_group: %d\n",
Ext2SuperBlock->s_blocks_per_group);
- DPRINTM(DPRINT_FILESYSTEM, "s_frags_per_group: %d\n",
Ext2SuperBlock->s_frags_per_group);
- DPRINTM(DPRINT_FILESYSTEM, "s_inodes_per_group: %d\n",
Ext2SuperBlock->s_inodes_per_group);
- DPRINTM(DPRINT_FILESYSTEM, "s_mtime: %d\n", Ext2SuperBlock->s_mtime);
- DPRINTM(DPRINT_FILESYSTEM, "s_wtime: %d\n", Ext2SuperBlock->s_wtime);
- DPRINTM(DPRINT_FILESYSTEM, "s_mnt_count: %d\n",
Ext2SuperBlock->s_mnt_count);
- DPRINTM(DPRINT_FILESYSTEM, "s_max_mnt_count: %d\n",
Ext2SuperBlock->s_max_mnt_count);
- DPRINTM(DPRINT_FILESYSTEM, "s_magic: 0x%x\n", Ext2SuperBlock->s_magic);
- DPRINTM(DPRINT_FILESYSTEM, "s_state: %d\n", Ext2SuperBlock->s_state);
- DPRINTM(DPRINT_FILESYSTEM, "s_errors: %d\n", Ext2SuperBlock->s_errors);
- DPRINTM(DPRINT_FILESYSTEM, "s_minor_rev_level: %d\n",
Ext2SuperBlock->s_minor_rev_level);
- DPRINTM(DPRINT_FILESYSTEM, "s_lastcheck: %d\n",
Ext2SuperBlock->s_lastcheck);
- DPRINTM(DPRINT_FILESYSTEM, "s_checkinterval: %d\n",
Ext2SuperBlock->s_checkinterval);
- DPRINTM(DPRINT_FILESYSTEM, "s_creator_os: %d\n",
Ext2SuperBlock->s_creator_os);
- DPRINTM(DPRINT_FILESYSTEM, "s_rev_level: %d\n",
Ext2SuperBlock->s_rev_level);
- DPRINTM(DPRINT_FILESYSTEM, "s_def_resuid: %d\n",
Ext2SuperBlock->s_def_resuid);
- DPRINTM(DPRINT_FILESYSTEM, "s_def_resgid: %d\n",
Ext2SuperBlock->s_def_resgid);
- DPRINTM(DPRINT_FILESYSTEM, "s_first_ino: %d\n",
Ext2SuperBlock->s_first_ino);
- DPRINTM(DPRINT_FILESYSTEM, "s_inode_size: %d\n",
Ext2SuperBlock->s_inode_size);
- DPRINTM(DPRINT_FILESYSTEM, "s_block_group_nr: %d\n",
Ext2SuperBlock->s_block_group_nr);
- DPRINTM(DPRINT_FILESYSTEM, "s_feature_compat: 0x%x\n",
Ext2SuperBlock->s_feature_compat);
- DPRINTM(DPRINT_FILESYSTEM, "s_feature_incompat: 0x%x\n",
Ext2SuperBlock->s_feature_incompat);
- DPRINTM(DPRINT_FILESYSTEM, "s_feature_ro_compat: 0x%x\n",
Ext2SuperBlock->s_feature_ro_compat);
- DPRINTM(DPRINT_FILESYSTEM, "s_uuid[16] = 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x
0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", Ext2SuperBlock->s_uuid[0],
Ext2SuperBlock->s_uuid[1], Ext2SuperBlock->s_uuid[2], Ext2SuperBlock->s_uuid[3],
Ext2SuperBlock->s_uuid[4], Ext2SuperBlock->s_uuid[5], Ext2SuperBlock->s_uuid[6],
Ext2SuperBlock->s_uuid[7], Ext2SuperBlock->s_uuid[8], Ext2SuperBlock->s_uuid[9],
Ext2SuperBlock->s_uuid[10], Ext2SuperBlock->s_uuid[11],
Ext2SuperBlock->s_uuid[12], Ext2SuperBlock->s_uuid[13],
Ext2SuperBlock->s_uuid[14], Ext2SuperBlock->s_uuid[15]);
- DPRINTM(DPRINT_FILESYSTEM, "s_volume_name[16] =
'%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c'\n", Ext2SuperBlock->s_volume_name[0],
Ext2SuperBlock->s_volume_name[1], Ext2SuperBlock->s_volume_name[2],
Ext2SuperBlock->s_volume_name[3], Ext2SuperBlock->s_volume_name[4],
Ext2SuperBlock->s_volume_name[5], Ext2SuperBlock->s_volume_name[6],
Ext2SuperBlock->s_volume_name[7], Ext2SuperBlock->s_volume_name[8],
Ext2SuperBlock->s_volume_name[9], Ext2SuperBlock->s_volume_name[10],
Ext2SuperBlock->s_volume_name[11], Ext2SuperBlock->s_volume_name[12],
Ext2SuperBlock->s_volume_name[13], Ext2SuperBlock->s_volume_name[14],
Ext2SuperBlock->s_volume_name[15]);
- DPRINTM(DPRINT_FILESYSTEM,
"s_last_mounted[64]='%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c'\n",
Ext2SuperBlock->s_last_mounted[0], Ext2SuperBlock->s_last_mounted[1],
Ext2SuperBlock->s_last_mounted[2], Ext2SuperBlock->s_last_mounted[3],
Ext2SuperBlock->s_last_mounted[4], Ext2SuperBlock->s_last_mounted[5],
Ext2SuperBlock->s_last_mounted[6], Ext2SuperBlock->s_last_mounted[7],
Ext2SuperBlock->s_last_mounted[8], Ext2SuperBlock->s_last_mounted[9],
- Ext2SuperBlock->s_last_mounted[10], Ext2SuperBlock->s_last_mounted[11],
Ext2SuperBlock->s_last_mounted[12], Ext2SuperBlock->s_last_mounted[13],
Ext2SuperBlock->s_last_mounted[14], Ext2SuperBlock->s_last_mounted[15],
Ext2SuperBlock->s_last_mounted[16], Ext2SuperBlock->s_last_mounted[17],
Ext2SuperBlock->s_last_mounted[18], Ext2SuperBlock->s_last_mounted[19],
- Ext2SuperBlock->s_last_mounted[20], Ext2SuperBlock->s_last_mounted[21],
Ext2SuperBlock->s_last_mounted[22], Ext2SuperBlock->s_last_mounted[23],
Ext2SuperBlock->s_last_mounted[24], Ext2SuperBlock->s_last_mounted[25],
Ext2SuperBlock->s_last_mounted[26], Ext2SuperBlock->s_last_mounted[27],
Ext2SuperBlock->s_last_mounted[28], Ext2SuperBlock->s_last_mounted[29],
- Ext2SuperBlock->s_last_mounted[30], Ext2SuperBlock->s_last_mounted[31],
Ext2SuperBlock->s_last_mounted[32], Ext2SuperBlock->s_last_mounted[33],
Ext2SuperBlock->s_last_mounted[34], Ext2SuperBlock->s_last_mounted[35],
Ext2SuperBlock->s_last_mounted[36], Ext2SuperBlock->s_last_mounted[37],
Ext2SuperBlock->s_last_mounted[38], Ext2SuperBlock->s_last_mounted[39],
- Ext2SuperBlock->s_last_mounted[40], Ext2SuperBlock->s_last_mounted[41],
Ext2SuperBlock->s_last_mounted[42], Ext2SuperBlock->s_last_mounted[43],
Ext2SuperBlock->s_last_mounted[44], Ext2SuperBlock->s_last_mounted[45],
Ext2SuperBlock->s_last_mounted[46], Ext2SuperBlock->s_last_mounted[47],
Ext2SuperBlock->s_last_mounted[48], Ext2SuperBlock->s_last_mounted[49],
- Ext2SuperBlock->s_last_mounted[50], Ext2SuperBlock->s_last_mounted[51],
Ext2SuperBlock->s_last_mounted[52], Ext2SuperBlock->s_last_mounted[53],
Ext2SuperBlock->s_last_mounted[54], Ext2SuperBlock->s_last_mounted[55],
Ext2SuperBlock->s_last_mounted[56], Ext2SuperBlock->s_last_mounted[57],
Ext2SuperBlock->s_last_mounted[58], Ext2SuperBlock->s_last_mounted[59],
- Ext2SuperBlock->s_last_mounted[60], Ext2SuperBlock->s_last_mounted[61],
Ext2SuperBlock->s_last_mounted[62], Ext2SuperBlock->s_last_mounted[63]);
- DPRINTM(DPRINT_FILESYSTEM, "s_algorithm_usage_bitmap = 0x%x\n",
Ext2SuperBlock->s_algorithm_usage_bitmap);
- DPRINTM(DPRINT_FILESYSTEM, "s_prealloc_blocks = %d\n",
Ext2SuperBlock->s_prealloc_blocks);
- DPRINTM(DPRINT_FILESYSTEM, "s_prealloc_dir_blocks = %d\n",
Ext2SuperBlock->s_prealloc_dir_blocks);
- DPRINTM(DPRINT_FILESYSTEM, "s_padding1 = %d\n",
Ext2SuperBlock->s_padding1);
- DPRINTM(DPRINT_FILESYSTEM, "s_journal_uuid[16] = 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x
0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n",
Ext2SuperBlock->s_journal_uuid[0], Ext2SuperBlock->s_journal_uuid[1],
Ext2SuperBlock->s_journal_uuid[2], Ext2SuperBlock->s_journal_uuid[3],
Ext2SuperBlock->s_journal_uuid[4], Ext2SuperBlock->s_journal_uuid[5],
Ext2SuperBlock->s_journal_uuid[6], Ext2SuperBlock->s_journal_uuid[7],
Ext2SuperBlock->s_journal_uuid[8], Ext2SuperBlock->s_journal_uuid[9],
Ext2SuperBlock->s_journal_uuid[10], Ext2SuperBlock->s_journal_uuid[11],
Ext2SuperBlock->s_journal_uuid[12], Ext2SuperBlock->s_journal_uuid[13],
Ext2SuperBlock->s_journal_uuid[14], Ext2SuperBlock->s_journal_uuid[15]);
- DPRINTM(DPRINT_FILESYSTEM, "s_journal_inum = %d\n",
Ext2SuperBlock->s_journal_inum);
- DPRINTM(DPRINT_FILESYSTEM, "s_journal_dev = %d\n",
Ext2SuperBlock->s_journal_dev);
- DPRINTM(DPRINT_FILESYSTEM, "s_last_orphan = %d\n",
Ext2SuperBlock->s_last_orphan);
+ DPRINTM(DPRINT_FILESYSTEM, "total_inodes: %d\n",
Ext2SuperBlock->total_inodes);
+ DPRINTM(DPRINT_FILESYSTEM, "total_blocks: %d\n",
Ext2SuperBlock->total_blocks);
+ DPRINTM(DPRINT_FILESYSTEM, "reserved_blocks: %d\n",
Ext2SuperBlock->reserved_blocks);
+ DPRINTM(DPRINT_FILESYSTEM, "free_blocks: %d\n",
Ext2SuperBlock->free_blocks);
+ DPRINTM(DPRINT_FILESYSTEM, "free_inodes: %d\n",
Ext2SuperBlock->free_inodes);
+ DPRINTM(DPRINT_FILESYSTEM, "first_data_block: %d\n",
Ext2SuperBlock->first_data_block);
+ DPRINTM(DPRINT_FILESYSTEM, "log2_block_size: %d\n",
Ext2SuperBlock->log2_block_size);
+ DPRINTM(DPRINT_FILESYSTEM, "log2_fragment_size: %d\n",
Ext2SuperBlock->log2_fragment_size);
+ DPRINTM(DPRINT_FILESYSTEM, "blocks_per_group: %d\n",
Ext2SuperBlock->blocks_per_group);
+ DPRINTM(DPRINT_FILESYSTEM, "fragments_per_group: %d\n",
Ext2SuperBlock->fragments_per_group);
+ DPRINTM(DPRINT_FILESYSTEM, "inodes_per_group: %d\n",
Ext2SuperBlock->inodes_per_group);
+ DPRINTM(DPRINT_FILESYSTEM, "mtime: %d\n", Ext2SuperBlock->mtime);
+ DPRINTM(DPRINT_FILESYSTEM, "utime: %d\n", Ext2SuperBlock->utime);
+ DPRINTM(DPRINT_FILESYSTEM, "mnt_count: %d\n", Ext2SuperBlock->mnt_count);
+ DPRINTM(DPRINT_FILESYSTEM, "max_mnt_count: %d\n",
Ext2SuperBlock->max_mnt_count);
+ DPRINTM(DPRINT_FILESYSTEM, "magic: 0x%x\n", Ext2SuperBlock->magic);
+ DPRINTM(DPRINT_FILESYSTEM, "fs_state: %d\n", Ext2SuperBlock->fs_state);
+ DPRINTM(DPRINT_FILESYSTEM, "error_handling: %d\n",
Ext2SuperBlock->error_handling);
+ DPRINTM(DPRINT_FILESYSTEM, "minor_revision_level: %d\n",
Ext2SuperBlock->minor_revision_level);
+ DPRINTM(DPRINT_FILESYSTEM, "lastcheck: %d\n", Ext2SuperBlock->lastcheck);
+ DPRINTM(DPRINT_FILESYSTEM, "checkinterval: %d\n",
Ext2SuperBlock->checkinterval);
+ DPRINTM(DPRINT_FILESYSTEM, "creator_os: %d\n",
Ext2SuperBlock->creator_os);
+ DPRINTM(DPRINT_FILESYSTEM, "revision_level: %d\n",
Ext2SuperBlock->revision_level);
+ DPRINTM(DPRINT_FILESYSTEM, "uid_reserved: %d\n",
Ext2SuperBlock->uid_reserved);
+ DPRINTM(DPRINT_FILESYSTEM, "gid_reserved: %d\n",
Ext2SuperBlock->gid_reserved);
+ DPRINTM(DPRINT_FILESYSTEM, "first_inode: %d\n",
Ext2SuperBlock->first_inode);
+ DPRINTM(DPRINT_FILESYSTEM, "inode_size: %d\n",
Ext2SuperBlock->inode_size);
+ DPRINTM(DPRINT_FILESYSTEM, "block_group_number: %d\n",
Ext2SuperBlock->block_group_number);
+ DPRINTM(DPRINT_FILESYSTEM, "feature_compatibility: 0x%x\n",
Ext2SuperBlock->feature_compatibility);
+ DPRINTM(DPRINT_FILESYSTEM, "feature_incompat: 0x%x\n",
Ext2SuperBlock->feature_incompat);
+ DPRINTM(DPRINT_FILESYSTEM, "feature_ro_compat: 0x%x\n",
Ext2SuperBlock->feature_ro_compat);
+ DPRINTM(DPRINT_FILESYSTEM, "unique_id = { 0x%x, 0x%x, 0x%x, 0x%x }\n",
+ Ext2SuperBlock->unique_id[0], Ext2SuperBlock->unique_id[1],
Ext2SuperBlock->unique_id[2], Ext2SuperBlock->unique_id[3]);
+ DPRINTM(DPRINT_FILESYSTEM, "volume_name = '%.16s'\n",
Ext2SuperBlock->volume_name);
+ DPRINTM(DPRINT_FILESYSTEM, "last_mounted_on = '%.64s'\n",
Ext2SuperBlock->last_mounted_on);
+ DPRINTM(DPRINT_FILESYSTEM, "compression_info = 0x%x\n",
Ext2SuperBlock->compression_info);
//
// Check the super block magic
//
- if (Ext2SuperBlock->s_magic != EXT3_SUPER_MAGIC)
+ if (Ext2SuperBlock->magic != EXT2_MAGIC)
{
FileSystemError("Invalid super block magic (0xef53)");
return FALSE;
@@ -658,7 +645,7 @@
//
// Check the revision level
//
- if (Ext2SuperBlock->s_rev_level > EXT3_DYNAMIC_REV)
+ if (Ext2SuperBlock->revision_level > EXT2_DYNAMIC_REVISION)
{
FileSystemError("FreeLoader does not understand the revision of this EXT2/EXT3
filesystem.\nPlease update FreeLoader.");
return FALSE;
@@ -669,33 +656,33 @@
// Don't need to check the compatible or read-only compatible features
// because we only mount the filesystem as read-only
//
- if ((Ext2SuperBlock->s_rev_level >= EXT3_DYNAMIC_REV) &&
+ if ((Ext2SuperBlock->revision_level >= EXT2_DYNAMIC_REVISION) &&
(/*((Ext2SuperBlock->s_feature_compat & ~EXT3_FEATURE_COMPAT_SUPP) != 0) ||*/
/*((Ext2SuperBlock->s_feature_ro_compat & ~EXT3_FEATURE_RO_COMPAT_SUPP) != 0)
||*/
- ((Ext2SuperBlock->s_feature_incompat & ~EXT3_FEATURE_INCOMPAT_SUPP) != 0)))
+ ((Ext2SuperBlock->feature_incompat & ~EXT3_FEATURE_INCOMPAT_SUPP) != 0)))
{
FileSystemError("FreeLoader does not understand features of this EXT2/EXT3
filesystem.\nPlease update FreeLoader.");
return FALSE;
}
// Calculate the group count
- Ext2GroupCount = (Ext2SuperBlock->s_blocks_count -
Ext2SuperBlock->s_first_data_block + Ext2SuperBlock->s_blocks_per_group - 1) /
Ext2SuperBlock->s_blocks_per_group;
+ Ext2GroupCount = (Ext2SuperBlock->total_blocks - Ext2SuperBlock->first_data_block
+ Ext2SuperBlock->blocks_per_group - 1) / Ext2SuperBlock->blocks_per_group;
DPRINTM(DPRINT_FILESYSTEM, "Ext2GroupCount: %d\n", Ext2GroupCount);
// Calculate the block size
- Ext2BlockSizeInBytes = 1024 << Ext2SuperBlock->s_log_block_size;
+ Ext2BlockSizeInBytes = 1024 << Ext2SuperBlock->log2_block_size;
Ext2BlockSizeInSectors = Ext2BlockSizeInBytes / Ext2DiskGeometry.BytesPerSector;
DPRINTM(DPRINT_FILESYSTEM, "Ext2BlockSizeInBytes: %d\n",
Ext2BlockSizeInBytes);
DPRINTM(DPRINT_FILESYSTEM, "Ext2BlockSizeInSectors: %d\n",
Ext2BlockSizeInSectors);
// Calculate the fragment size
- if (Ext2SuperBlock->s_log_frag_size >= 0)
- {
- Ext2FragmentSizeInBytes = 1024 << Ext2SuperBlock->s_log_frag_size;
+ if (Ext2SuperBlock->log2_fragment_size >= 0)
+ {
+ Ext2FragmentSizeInBytes = 1024 << Ext2SuperBlock->log2_fragment_size;
}
else
{
- Ext2FragmentSizeInBytes = 1024 >> -(Ext2SuperBlock->s_log_frag_size);
+ Ext2FragmentSizeInBytes = 1024 >> -(Ext2SuperBlock->log2_fragment_size);
}
Ext2FragmentSizeInSectors = Ext2FragmentSizeInBytes / Ext2DiskGeometry.BytesPerSector;
DPRINTM(DPRINT_FILESYSTEM, "Ext2FragmentSizeInBytes: %d\n",
Ext2FragmentSizeInBytes);
@@ -709,11 +696,11 @@
}
// Calculate the number of inodes in one block
- Ext2InodesPerBlock = Ext2BlockSizeInBytes / EXT3_INODE_SIZE(Ext2SuperBlock);
+ Ext2InodesPerBlock = Ext2BlockSizeInBytes / EXT2_INODE_SIZE(Ext2SuperBlock);
DPRINTM(DPRINT_FILESYSTEM, "Ext2InodesPerBlock: %d\n", Ext2InodesPerBlock);
// Calculate the number of group descriptors in one block
- Ext2GroupDescPerBlock = EXT3_DESC_PER_BLOCK(Ext2SuperBlock);
+ Ext2GroupDescPerBlock = EXT2_DESC_PER_BLOCK(Ext2SuperBlock);
DPRINTM(DPRINT_FILESYSTEM, "Ext2GroupDescPerBlock: %d\n",
Ext2GroupDescPerBlock);
return TRUE;
@@ -754,7 +741,7 @@
// Now read the group descriptors
for (CurrentGroupDescBlock=0; CurrentGroupDescBlock<GroupDescBlockCount;
CurrentGroupDescBlock++)
{
- if (!Ext2ReadBlock(Ext2SuperBlock->s_first_data_block + 1 + CurrentGroupDescBlock,
(PVOID)FILESYSBUFFER))
+ if (!Ext2ReadBlock(Ext2SuperBlock->first_data_block + 1 + CurrentGroupDescBlock,
(PVOID)FILESYSBUFFER))
{
return FALSE;
}
@@ -778,7 +765,7 @@
}
// Make sure it is a directory inode
- if ((InodePointer->i_mode & EXT2_S_IFMT) != EXT2_S_IFDIR)
+ if ((InodePointer->mode & EXT2_S_IFMT) != EXT2_S_IFDIR)
{
FileSystemError("Inode is not a directory.");
return FALSE;
@@ -826,12 +813,12 @@
BOOLEAN Ext2ReadBlock(ULONG BlockNumber, PVOID Buffer)
{
- CHAR ErrorString[80];
+ CHAR ErrorString[80];
DPRINTM(DPRINT_FILESYSTEM, "Ext2ReadBlock() BlockNumber = %d Buffer = 0x%x\n",
BlockNumber, Buffer);
// Make sure its a valid block
- if (BlockNumber > Ext2SuperBlock->s_blocks_count)
+ if (BlockNumber > Ext2SuperBlock->total_blocks)
{
sprintf(ErrorString, "Error reading block %d - block out of range.", (int)
BlockNumber);
FileSystemError(ErrorString);
@@ -872,7 +859,7 @@
ULONG Ext2GetGroupDescBlockNumber(ULONG Group)
{
- return (((Group * sizeof(EXT2_GROUP_DESC)) / Ext2GroupDescPerBlock) +
Ext2SuperBlock->s_first_data_block + 1);
+ return (((Group * sizeof(EXT2_GROUP_DESC)) / Ext2GroupDescPerBlock) +
Ext2SuperBlock->first_data_block + 1);
}
ULONG Ext2GetGroupDescOffsetInBlock(ULONG Group)
@@ -882,31 +869,31 @@
ULONG Ext2GetInodeGroupNumber(ULONG Inode)
{
- return ((Inode - 1) / Ext2SuperBlock->s_inodes_per_group);
+ return ((Inode - 1) / Ext2SuperBlock->inodes_per_group);
}
ULONG Ext2GetInodeBlockNumber(ULONG Inode)
{
- return (((Inode - 1) % Ext2SuperBlock->s_inodes_per_group) / Ext2InodesPerBlock);
+ return (((Inode - 1) % Ext2SuperBlock->inodes_per_group) / Ext2InodesPerBlock);
}
ULONG Ext2GetInodeOffsetInBlock(ULONG Inode)
{
- return (((Inode - 1) % Ext2SuperBlock->s_inodes_per_group) % Ext2InodesPerBlock);
+ return (((Inode - 1) % Ext2SuperBlock->inodes_per_group) % Ext2InodesPerBlock);
}
BOOLEAN Ext2ReadInode(ULONG Inode, PEXT2_INODE InodeBuffer)
{
- ULONG InodeGroupNumber;
- ULONG InodeBlockNumber;
- ULONG InodeOffsetInBlock;
- CHAR ErrorString[80];
+ ULONG InodeGroupNumber;
+ ULONG InodeBlockNumber;
+ ULONG InodeOffsetInBlock;
+ CHAR ErrorString[80];
EXT2_GROUP_DESC GroupDescriptor;
DPRINTM(DPRINT_FILESYSTEM, "Ext2ReadInode() Inode = %d\n", Inode);
// Make sure its a valid inode
- if ((Inode < 1) || (Inode > Ext2SuperBlock->s_inodes_count))
+ if ((Inode < 1) || (Inode > Ext2SuperBlock->total_inodes))
{
sprintf(ErrorString, "Error reading inode %ld - inode out of range.",
Inode);
FileSystemError(ErrorString);
@@ -928,7 +915,7 @@
}
// Add the start block of the inode table to the inode block number
- InodeBlockNumber += GroupDescriptor.bg_inode_table;
+ InodeBlockNumber += GroupDescriptor.inode_table_id;
DPRINTM(DPRINT_FILESYSTEM, "InodeBlockNumber (after group desc correction) =
%d\n", InodeBlockNumber);
// Read the block
@@ -938,29 +925,34 @@
}
// Copy the data to their buffer
- RtlCopyMemory(InodeBuffer, (PVOID)((ULONG_PTR)FILESYSBUFFER + (InodeOffsetInBlock *
EXT3_INODE_SIZE(Ext2SuperBlock))), sizeof(EXT2_INODE));
+ RtlCopyMemory(InodeBuffer, (PVOID)((ULONG_PTR)FILESYSBUFFER + (InodeOffsetInBlock *
EXT2_INODE_SIZE(Ext2SuperBlock))), sizeof(EXT2_INODE));
DPRINTM(DPRINT_FILESYSTEM, "Dumping inode information:\n");
- DPRINTM(DPRINT_FILESYSTEM, "i_mode = 0x%x\n", InodeBuffer->i_mode);
- DPRINTM(DPRINT_FILESYSTEM, "i_uid = %d\n", InodeBuffer->i_uid);
- DPRINTM(DPRINT_FILESYSTEM, "i_size = %d\n", InodeBuffer->i_size);
- DPRINTM(DPRINT_FILESYSTEM, "i_atime = %d\n", InodeBuffer->i_atime);
- DPRINTM(DPRINT_FILESYSTEM, "i_ctime = %d\n", InodeBuffer->i_ctime);
- DPRINTM(DPRINT_FILESYSTEM, "i_mtime = %d\n", InodeBuffer->i_mtime);
- DPRINTM(DPRINT_FILESYSTEM, "i_dtime = %d\n", InodeBuffer->i_dtime);
- DPRINTM(DPRINT_FILESYSTEM, "i_gid = %d\n", InodeBuffer->i_gid);
- DPRINTM(DPRINT_FILESYSTEM, "i_links_count = %d\n",
InodeBuffer->i_links_count);
- DPRINTM(DPRINT_FILESYSTEM, "i_blocks = %d\n", InodeBuffer->i_blocks);
- DPRINTM(DPRINT_FILESYSTEM, "i_flags = 0x%x\n", InodeBuffer->i_flags);
- DPRINTM(DPRINT_FILESYSTEM, "i_block[EXT3_N_BLOCKS (%d)]
=\n%d,\n%d,\n%d,\n%d,\n%d,\n%d,\n%d,\n%d,\n%d,\n%d,\n%d,\n%d,\n%d,\n%d,\n%d\n",
EXT3_N_BLOCKS, InodeBuffer->i_block[0], InodeBuffer->i_block[1],
InodeBuffer->i_block[2], InodeBuffer->i_block[3], InodeBuffer->i_block[4],
InodeBuffer->i_block[5], InodeBuffer->i_block[6], InodeBuffer->i_block[7],
InodeBuffer->i_block[8], InodeBuffer->i_block[9], InodeBuffer->i_block[10],
InodeBuffer->i_block[11], InodeBuffer->i_block[12], InodeBuffer->i_block[13],
InodeBuffer->i_block[14]);
- DPRINTM(DPRINT_FILESYSTEM, "i_generation = %d\n",
InodeBuffer->i_generation);
- DPRINTM(DPRINT_FILESYSTEM, "i_file_acl = %d\n", InodeBuffer->i_file_acl);
- DPRINTM(DPRINT_FILESYSTEM, "i_dir_acl = %d\n", InodeBuffer->i_dir_acl);
- DPRINTM(DPRINT_FILESYSTEM, "i_faddr = %d\n", InodeBuffer->i_faddr);
- DPRINTM(DPRINT_FILESYSTEM, "l_i_frag = %d\n",
InodeBuffer->osd2.linux2.l_i_frag);
- DPRINTM(DPRINT_FILESYSTEM, "l_i_fsize = %d\n",
InodeBuffer->osd2.linux2.l_i_fsize);
- DPRINTM(DPRINT_FILESYSTEM, "l_i_uid_high = %d\n",
InodeBuffer->osd2.linux2.l_i_uid_high);
- DPRINTM(DPRINT_FILESYSTEM, "l_i_gid_high = %d\n",
InodeBuffer->osd2.linux2.l_i_gid_high);
+ DPRINTM(DPRINT_FILESYSTEM, "mode = 0x%x\n", InodeBuffer->mode);
+ DPRINTM(DPRINT_FILESYSTEM, "uid = %d\n", InodeBuffer->uid);
+ DPRINTM(DPRINT_FILESYSTEM, "size = %d\n", InodeBuffer->size);
+ DPRINTM(DPRINT_FILESYSTEM, "atime = %d\n", InodeBuffer->atime);
+ DPRINTM(DPRINT_FILESYSTEM, "ctime = %d\n", InodeBuffer->ctime);
+ DPRINTM(DPRINT_FILESYSTEM, "mtime = %d\n", InodeBuffer->mtime);
+ DPRINTM(DPRINT_FILESYSTEM, "dtime = %d\n", InodeBuffer->dtime);
+ DPRINTM(DPRINT_FILESYSTEM, "gid = %d\n", InodeBuffer->gid);
+ DPRINTM(DPRINT_FILESYSTEM, "nlinks = %d\n", InodeBuffer->nlinks);
+ DPRINTM(DPRINT_FILESYSTEM, "blockcnt = %d\n", InodeBuffer->blockcnt);
+ DPRINTM(DPRINT_FILESYSTEM, "flags = 0x%x\n", InodeBuffer->flags);
+ DPRINTM(DPRINT_FILESYSTEM, "osd1 = 0x%x\n", InodeBuffer->osd1);
+ DPRINTM(DPRINT_FILESYSTEM, "dir_blocks = { %u, %u, %u, %u, %u, %u, %u, %u, %u, %u,
%u, %u }\n",
+ InodeBuffer->blocks.dir_blocks[0], InodeBuffer->blocks.dir_blocks[1],
InodeBuffer->blocks.dir_blocks[ 2], InodeBuffer->blocks.dir_blocks[ 3],
+ InodeBuffer->blocks.dir_blocks[4], InodeBuffer->blocks.dir_blocks[5],
InodeBuffer->blocks.dir_blocks[ 6], InodeBuffer->blocks.dir_blocks[ 7],
+ InodeBuffer->blocks.dir_blocks[8], InodeBuffer->blocks.dir_blocks[9],
InodeBuffer->blocks.dir_blocks[10], InodeBuffer->blocks.dir_blocks[11]);
+ DPRINTM(DPRINT_FILESYSTEM, "indir_block = %u\n",
InodeBuffer->blocks.indir_block);
+ DPRINTM(DPRINT_FILESYSTEM, "double_indir_block = %u\n",
InodeBuffer->blocks.double_indir_block);
+ DPRINTM(DPRINT_FILESYSTEM, "tripple_indir_block = %u\n",
InodeBuffer->blocks.tripple_indir_block);
+ DPRINTM(DPRINT_FILESYSTEM, "version = %d\n", InodeBuffer->version);
+ DPRINTM(DPRINT_FILESYSTEM, "acl = %d\n", InodeBuffer->acl);
+ DPRINTM(DPRINT_FILESYSTEM, "dir_acl = %d\n", InodeBuffer->dir_acl);
+ DPRINTM(DPRINT_FILESYSTEM, "fragment_addr = %d\n",
InodeBuffer->fragment_addr);
+ DPRINTM(DPRINT_FILESYSTEM, "osd2 = { %d, %d, %d }\n",
+ InodeBuffer->osd2[0], InodeBuffer->osd2[1], InodeBuffer->osd2[2]);
return TRUE;
}
@@ -979,12 +971,12 @@
RtlCopyMemory(GroupBuffer, &Ext2GroupDescriptors[Group], sizeof(EXT2_GROUP_DESC));
DPRINTM(DPRINT_FILESYSTEM, "Dumping group descriptor:\n");
- DPRINTM(DPRINT_FILESYSTEM, "bg_block_bitmap = %d\n",
GroupBuffer->bg_block_bitmap);
- DPRINTM(DPRINT_FILESYSTEM, "bg_inode_bitmap = %d\n",
GroupBuffer->bg_inode_bitmap);
- DPRINTM(DPRINT_FILESYSTEM, "bg_inode_table = %d\n",
GroupBuffer->bg_inode_table);
- DPRINTM(DPRINT_FILESYSTEM, "bg_free_blocks_count = %d\n",
GroupBuffer->bg_free_blocks_count);
- DPRINTM(DPRINT_FILESYSTEM, "bg_free_inodes_count = %d\n",
GroupBuffer->bg_free_inodes_count);
- DPRINTM(DPRINT_FILESYSTEM, "bg_used_dirs_count = %d\n",
GroupBuffer->bg_used_dirs_count);
+ DPRINTM(DPRINT_FILESYSTEM, "block_id = %d\n", GroupBuffer->block_id);
+ DPRINTM(DPRINT_FILESYSTEM, "inode_id = %d\n", GroupBuffer->inode_id);
+ DPRINTM(DPRINT_FILESYSTEM, "inode_table_id = %d\n",
GroupBuffer->inode_table_id);
+ DPRINTM(DPRINT_FILESYSTEM, "free_blocks = %d\n",
GroupBuffer->free_blocks);
+ DPRINTM(DPRINT_FILESYSTEM, "free_inodes = %d\n",
GroupBuffer->free_inodes);
+ DPRINTM(DPRINT_FILESYSTEM, "used_dirs = %d\n", GroupBuffer->used_dirs);
return TRUE;
}
@@ -1017,19 +1009,19 @@
}
RtlZeroMemory(BlockList, BlockCount * sizeof(ULONG));
- CurrentBlockInList = 0;
// Copy the direct block pointers
- for (CurrentBlock=0; CurrentBlockInList<BlockCount &&
CurrentBlock<EXT3_NDIR_BLOCKS; CurrentBlock++)
- {
- BlockList[CurrentBlockInList] = Inode->i_block[CurrentBlock];
- CurrentBlockInList++;
+ for (CurrentBlockInList = CurrentBlock = 0;
+ CurrentBlockInList < BlockCount && CurrentBlock < INDIRECT_BLOCKS;
+ CurrentBlock++, CurrentBlockInList++)
+ {
+ BlockList[CurrentBlockInList] = Inode->blocks.dir_blocks[CurrentBlock];
}
// Copy the indirect block pointers
if (CurrentBlockInList < BlockCount)
{
- if (!Ext2CopyIndirectBlockPointers(BlockList, &CurrentBlockInList, BlockCount,
Inode->i_block[EXT3_IND_BLOCK]))
+ if (!Ext2CopyIndirectBlockPointers(BlockList, &CurrentBlockInList, BlockCount,
Inode->blocks.indir_block))
{
MmHeapFree(BlockList);
return FALSE;
@@ -1039,7 +1031,7 @@
// Copy the double indirect block pointers
if (CurrentBlockInList < BlockCount)
{
- if (!Ext2CopyDoubleIndirectBlockPointers(BlockList, &CurrentBlockInList,
BlockCount, Inode->i_block[EXT3_DIND_BLOCK]))
+ if (!Ext2CopyDoubleIndirectBlockPointers(BlockList, &CurrentBlockInList,
BlockCount, Inode->blocks.double_indir_block))
{
MmHeapFree(BlockList);
return FALSE;
@@ -1049,7 +1041,7 @@
// Copy the triple indirect block pointers
if (CurrentBlockInList < BlockCount)
{
- if (!Ext2CopyTripleIndirectBlockPointers(BlockList, &CurrentBlockInList,
BlockCount, Inode->i_block[EXT3_TIND_BLOCK]))
+ if (!Ext2CopyTripleIndirectBlockPointers(BlockList, &CurrentBlockInList,
BlockCount, Inode->blocks.tripple_indir_block))
{
MmHeapFree(BlockList);
return FALSE;
@@ -1061,21 +1053,21 @@
ULONGLONG Ext2GetInodeFileSize(PEXT2_INODE Inode)
{
- if ((Inode->i_mode & EXT2_S_IFMT) == EXT2_S_IFDIR)
- {
- return (ULONGLONG)(Inode->i_size);
+ if ((Inode->mode & EXT2_S_IFMT) == EXT2_S_IFDIR)
+ {
+ return (ULONGLONG)(Inode->size);
}
else
{
- return ((ULONGLONG)(Inode->i_size) | ((ULONGLONG)(Inode->i_dir_acl) <<
32));
+ return ((ULONGLONG)(Inode->size) | ((ULONGLONG)(Inode->dir_acl) << 32));
}
}
BOOLEAN Ext2CopyIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList, ULONG
BlockCount, ULONG IndirectBlock)
{
ULONG* BlockBuffer = (ULONG*)FILESYSBUFFER;
- ULONG CurrentBlock;
- ULONG BlockPointersPerBlock;
+ ULONG CurrentBlock;
+ ULONG BlockPointersPerBlock;
DPRINTM(DPRINT_FILESYSTEM, "Ext2CopyIndirectBlockPointers() BlockCount =
%d\n", BlockCount);
@@ -1098,8 +1090,8 @@
BOOLEAN Ext2CopyDoubleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList,
ULONG BlockCount, ULONG DoubleIndirectBlock)
{
ULONG* BlockBuffer;
- ULONG CurrentBlock;
- ULONG BlockPointersPerBlock;
+ ULONG CurrentBlock;
+ ULONG BlockPointersPerBlock;
DPRINTM(DPRINT_FILESYSTEM, "Ext2CopyDoubleIndirectBlockPointers() BlockCount =
%d\n", BlockCount);
@@ -1133,8 +1125,8 @@
BOOLEAN Ext2CopyTripleIndirectBlockPointers(ULONG* BlockList, ULONG* CurrentBlockInList,
ULONG BlockCount, ULONG TripleIndirectBlock)
{
ULONG* BlockBuffer;
- ULONG CurrentBlock;
- ULONG BlockPointersPerBlock;
+ ULONG CurrentBlock;
+ ULONG BlockPointersPerBlock;
DPRINTM(DPRINT_FILESYSTEM, "Ext2CopyTripleIndirectBlockPointers() BlockCount =
%d\n", BlockCount);
@@ -1289,7 +1281,7 @@
//
// Check if SuperBlock is valid. If yes, return Ext2 function table
//
- if (SuperBlock.s_magic == EXT3_SUPER_MAGIC)
+ if (SuperBlock.magic == EXT2_MAGIC)
{
//
// Compatibility hack as long as FS is not using underlying device DeviceId
Modified: trunk/reactos/boot/freeldr/freeldr/fs/fsrec.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/fs/fs…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/fs/fsrec.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/fs/fsrec.c [iso-8859-1] Sun Aug 9 00:39:04 2009
@@ -83,7 +83,7 @@
return FALSE;
}
- if (SuperBlock->s_magic == EXT3_SUPER_MAGIC)
+ if (SuperBlock->magic == EXT2_MAGIC)
{
return TRUE;
}
Modified: trunk/reactos/boot/freeldr/freeldr/include/fs/ext2.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/fs/ext2.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/fs/ext2.h [iso-8859-1] Sun Aug 9 00:39:04
2009
@@ -20,615 +20,182 @@
#ifndef __EXT2_H
#define __EXT2_H
-
/*
- * linux/include/linux/ext3_fs.h
- *
- * Copyright (C) 1992, 1993, 1994, 1995
- * Remy Card (card(a)masi.ibp.fr)
- * Laboratoire MASI - Institut Blaise Pascal
- * Universite Pierre et Marie Curie (Paris VI)
- *
- * from
- *
- * linux/include/linux/minix_fs.h
- *
- * Copyright (C) 1991, 1992 Linus Torvalds
+ * grub/fs/ext2.c
+ *
+ * GRUB -- GRand Unified Bootloader
+ * Copyright (C) 2003,2004,2005,2007 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _LINUX_EXT3_FS_H
-#define _LINUX_EXT3_FS_H
-
-//#include <linux/types.h>
+/* Magic value used to identify an ext2 filesystem. */
+#define EXT2_MAGIC 0xEF53
+/* Amount of indirect blocks in an inode. */
+#define INDIRECT_BLOCKS 12
+/* Maximum lenght of a pathname. */
+#define EXT2_PATH_MAX 4096
+/* Maximum nesting of symlinks, used to prevent a loop. */
+#define EXT2_MAX_SYMLINKCNT 8
+
+/* The good old revision and the default inode size. */
+#define EXT2_GOOD_OLD_REVISION 0
+#define EXT2_DYNAMIC_REVISION 1
+#define EXT2_GOOD_OLD_INODE_SIZE 128
+
+/* Filetype used in directory entry. */
+#define FILETYPE_UNKNOWN 0
+#define FILETYPE_REG 1
+#define FILETYPE_DIRECTORY 2
+#define FILETYPE_SYMLINK 7
+
+/* Filetype information as used in inodes. */
+#define FILETYPE_INO_MASK 0170000
+#define FILETYPE_INO_REG 0100000
+#define FILETYPE_INO_DIRECTORY 0040000
+#define FILETYPE_INO_SYMLINK 0120000
+
+/* The ext2 superblock. */
+struct ext2_sblock
+{
+ ULONG total_inodes;
+ ULONG total_blocks;
+ ULONG reserved_blocks;
+ ULONG free_blocks;
+ ULONG free_inodes;
+ ULONG first_data_block;
+ ULONG log2_block_size;
+ ULONG log2_fragment_size;
+ ULONG blocks_per_group;
+ ULONG fragments_per_group;
+ ULONG inodes_per_group;
+ ULONG mtime;
+ ULONG utime;
+ USHORT mnt_count;
+ USHORT max_mnt_count;
+ USHORT magic;
+ USHORT fs_state;
+ USHORT error_handling;
+ USHORT minor_revision_level;
+ ULONG lastcheck;
+ ULONG checkinterval;
+ ULONG creator_os;
+ ULONG revision_level;
+ USHORT uid_reserved;
+ USHORT gid_reserved;
+ ULONG first_inode;
+ USHORT inode_size;
+ USHORT block_group_number;
+ ULONG feature_compatibility;
+ ULONG feature_incompat;
+ ULONG feature_ro_compat;
+ ULONG unique_id[4];
+ char volume_name[16];
+ char last_mounted_on[64];
+ ULONG compression_info;
+};
+
+/* The ext2 blockgroup. */
+struct ext2_block_group
+{
+ ULONG block_id;
+ ULONG inode_id;
+ ULONG inode_table_id;
+ USHORT free_blocks;
+ USHORT free_inodes;
+ USHORT used_dirs;
+ USHORT pad;
+ ULONG reserved[3];
+};
+
+/* The ext2 inode. */
+struct ext2_inode
+{
+ USHORT mode;
+ USHORT uid;
+ ULONG size;
+ ULONG atime;
+ ULONG ctime;
+ ULONG mtime;
+ ULONG dtime;
+ USHORT gid;
+ USHORT nlinks;
+ ULONG blockcnt; /* Blocks of 512 bytes!! */
+ ULONG flags;
+ ULONG osd1;
+ union
+ {
+ struct datablocks
+ {
+ ULONG dir_blocks[INDIRECT_BLOCKS];
+ ULONG indir_block;
+ ULONG double_indir_block;
+ ULONG tripple_indir_block;
+ } blocks;
+ char symlink[60];
+ };
+ ULONG version;
+ ULONG acl;
+ ULONG dir_acl;
+ ULONG fragment_addr;
+ ULONG osd2[3];
+};
+
+/* The header of an ext2 directory entry. */
+#define EXT2_NAME_LEN 255
+
+struct ext2_dirent
+{
+ ULONG inode;
+ USHORT direntlen;
+ UCHAR namelen;
+ UCHAR filetype;
+ CHAR name[EXT2_NAME_LEN];
+};
/*
- * The second extended filesystem constants/structures
+ * End of code from grub/fs/ext2.c
*/
-/*
- * Define EXT3FS_DEBUG to produce debug messages
- */
-#undef EXT3FS_DEBUG
-
-/*
- * Define EXT3_PREALLOCATE to preallocate data blocks for expanding files
- */
-#undef EXT3_PREALLOCATE /* @@@ Fix this! */
-#define EXT3_DEFAULT_PREALLOC_BLOCKS 8
-
-/*
- * The second extended file system version
- */
-#define EXT3FS_DATE "10 Jan 2002"
-#define EXT3FS_VERSION "2.4-0.9.17"
-
-/*
- * Debug code
- */
-#ifdef EXT3FS_DEBUG
-#define ext3_debug(f, a...) \
- do { \
- printk (KERN_DEBUG "EXT3-fs DEBUG (%s, %d): %s:", \
- __FILE__, __LINE__, __FUNCTION__); \
- printk (KERN_DEBUG f, ## a); \
- } while (0)
-#else
- #ifdef __GNUC__
- #define ext3_debug(f, a...) do {} while (0)
- #else
- #define ext3_debug
- #endif
-#endif
-
-/*
- * Special inodes numbers
- */
-#define EXT3_BAD_INO 1 /* Bad blocks inode */
-#define EXT3_ROOT_INO 2 /* Root inode */
-#define EXT3_ACL_IDX_INO 3 /* ACL inode */
-#define EXT3_ACL_DATA_INO 4 /* ACL inode */
-#define EXT3_BOOT_LOADER_INO 5 /* Boot loader inode */
-#define EXT3_UNDEL_DIR_INO 6 /* Undelete directory inode */
-#define EXT3_RESIZE_INO 7 /* Reserved group descriptors inode */
-#define EXT3_JOURNAL_INO 8 /* Journal inode */
-
-/* First non-reserved inode for old ext3 filesystems */
-#define EXT3_GOOD_OLD_FIRST_INO 11
-
-/*
- * The second extended file system magic number
- */
-#define EXT3_SUPER_MAGIC 0xEF53
-
-/*
- * Maximal count of links to a file
- */
-#define EXT3_LINK_MAX 32000
-
-/*
- * Macro-instructions used to manage several block sizes
- */
-#define EXT3_MIN_BLOCK_SIZE 1024
-#define EXT3_MAX_BLOCK_SIZE 4096
-#define EXT3_MIN_BLOCK_LOG_SIZE 10
-#ifdef __KERNEL__
-# define EXT3_BLOCK_SIZE(s) ((s)->s_blocksize)
-#else
-# define EXT3_BLOCK_SIZE(s) (EXT3_MIN_BLOCK_SIZE << (s)->s_log_block_size)
-#endif
-#define EXT3_ACLE_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_acl_entry))
-#define EXT3_ADDR_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (ULONG))
-#ifdef __KERNEL__
-# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
-#else
-# define EXT3_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10)
-#endif
-#ifdef __KERNEL__
-#define EXT3_ADDR_PER_BLOCK_BITS(s) ((s)->u.ext3_sb.s_addr_per_block_bits)
-#define EXT3_INODE_SIZE(s) ((s)->u.ext3_sb.s_inode_size)
-#define EXT3_FIRST_INO(s) ((s)->u.ext3_sb.s_first_ino)
-#else
-#define EXT3_INODE_SIZE(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \
- EXT3_GOOD_OLD_INODE_SIZE : \
- (s)->s_inode_size)
-#define EXT3_FIRST_INO(s) (((s)->s_rev_level == EXT3_GOOD_OLD_REV) ? \
- EXT3_GOOD_OLD_FIRST_INO : \
- (s)->s_first_ino)
-#endif
-
-/*
- * Macro-instructions used to manage fragments
- */
-#define EXT3_MIN_FRAG_SIZE 1024
-#define EXT3_MAX_FRAG_SIZE 4096
-#define EXT3_MIN_FRAG_LOG_SIZE 10
-#ifdef __KERNEL__
-# define EXT3_FRAG_SIZE(s) ((s)->u.ext3_sb.s_frag_size)
-# define EXT3_FRAGS_PER_BLOCK(s) ((s)->u.ext3_sb.s_frags_per_block)
-#else
-# define EXT3_FRAG_SIZE(s) (EXT3_MIN_FRAG_SIZE << (s)->s_log_frag_size)
-# define EXT3_FRAGS_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / EXT3_FRAG_SIZE(s))
-#endif
-
-/*
- * ACL structures
- */
-struct ext3_acl_header /* Header of Access Control Lists */
-{
- ULONG aclh_size;
- ULONG aclh_file_count;
- ULONG aclh_acle_count;
- ULONG aclh_first_acle;
-};
-
-struct ext3_acl_entry /* Access Control List Entry */
-{
- ULONG acle_size;
- USHORT acle_perms; /* Access permissions */
- USHORT acle_type; /* Type of entry */
- USHORT acle_tag; /* User or group identity */
- USHORT acle_pad1;
- ULONG acle_next; /* Pointer on next entry for the */
- /* same inode or on next free entry */
-};
-
-/*
- * Structure of a blocks group descriptor
- */
-struct ext3_group_desc
-{
- ULONG bg_block_bitmap; /* Blocks bitmap block */
- ULONG bg_inode_bitmap; /* Inodes bitmap block */
- ULONG bg_inode_table; /* Inodes table block */
- USHORT bg_free_blocks_count; /* Free blocks count */
- USHORT bg_free_inodes_count; /* Free inodes count */
- USHORT bg_used_dirs_count; /* Directories count */
- USHORT bg_pad;
- ULONG bg_reserved[3];
-};
-
-/*
- * Macro-instructions used to manage group descriptors
- */
-#ifdef __KERNEL__
-# define EXT3_BLOCKS_PER_GROUP(s) ((s)->u.ext3_sb.s_blocks_per_group)
-# define EXT3_DESC_PER_BLOCK(s) ((s)->u.ext3_sb.s_desc_per_block)
-# define EXT3_INODES_PER_GROUP(s) ((s)->u.ext3_sb.s_inodes_per_group)
-# define EXT3_DESC_PER_BLOCK_BITS(s) ((s)->u.ext3_sb.s_desc_per_block_bits)
-#else
-# define EXT3_BLOCKS_PER_GROUP(s) ((s)->s_blocks_per_group)
-# define EXT3_DESC_PER_BLOCK(s) (EXT3_BLOCK_SIZE(s) / sizeof (struct ext3_group_desc))
-# define EXT3_INODES_PER_GROUP(s) ((s)->s_inodes_per_group)
-#endif
-
-/*
- * Constants relative to the data blocks
- */
-#define EXT3_NDIR_BLOCKS 12
-#define EXT3_IND_BLOCK EXT3_NDIR_BLOCKS
-#define EXT3_DIND_BLOCK (EXT3_IND_BLOCK + 1)
-#define EXT3_TIND_BLOCK (EXT3_DIND_BLOCK + 1)
-#define EXT3_N_BLOCKS (EXT3_TIND_BLOCK + 1)
-
-/*
- * Inode flags
- */
-#define EXT3_SECRM_FL 0x00000001 /* Secure deletion */
-#define EXT3_UNRM_FL 0x00000002 /* Undelete */
-#define EXT3_COMPR_FL 0x00000004 /* Compress file */
-#define EXT3_SYNC_FL 0x00000008 /* Synchronous updates */
-#define EXT3_IMMUTABLE_FL 0x00000010 /* Immutable file */
-#define EXT3_APPEND_FL 0x00000020 /* writes to file may only append */
-#define EXT3_NODUMP_FL 0x00000040 /* do not dump file */
-#define EXT3_NOATIME_FL 0x00000080 /* do not update atime */
-/* Reserved for compression usage... */
-#define EXT3_DIRTY_FL 0x00000100
-#define EXT3_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
-#define EXT3_NOCOMPR_FL 0x00000400 /* Don't compress */
-#define EXT3_ECOMPR_FL 0x00000800 /* Compression error */
-/* End compression flags --- maybe not all used */
-#define EXT3_INDEX_FL 0x00001000 /* hash-indexed directory */
-#define EXT3_IMAGIC_FL 0x00002000 /* AFS directory */
-#define EXT3_JOURNAL_DATA_FL 0x00004000 /* file data should be journaled */
-#define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
-
-#define EXT3_FL_USER_VISIBLE 0x00005FFF /* User visible flags */
-#define EXT3_FL_USER_MODIFIABLE 0x000000FF /* User modifiable flags */
-
-/*
- * Inode dynamic state flags
- */
-#define EXT3_STATE_JDATA 0x00000001 /* journaled data exists */
-#define EXT3_STATE_NEW 0x00000002 /* inode is newly created */
-
-/*
- * ioctl commands
- */
-#define EXT3_IOC_GETFLAGS _IOR('f', 1, long)
-#define EXT3_IOC_SETFLAGS _IOW('f', 2, long)
-#define EXT3_IOC_GETVERSION _IOR('f', 3, long)
-#define EXT3_IOC_SETVERSION _IOW('f', 4, long)
-#define EXT3_IOC_GETVERSION_OLD _IOR('v', 1, long)
-#define EXT3_IOC_SETVERSION_OLD _IOW('v', 2, long)
-#ifdef CONFIG_JBD_DEBUG
-#define EXT3_IOC_WAIT_FOR_READONLY _IOR('f', 99, long)
-#endif
-
-/*
- * Structure of an inode on the disk
- */
-struct ext3_inode {
- USHORT i_mode; /* File mode */
- USHORT i_uid; /* Low 16 bits of Owner Uid */
- ULONG i_size; /* Size in bytes */
- ULONG i_atime; /* Access time */
- ULONG i_ctime; /* Creation time */
- ULONG i_mtime; /* Modification time */
- ULONG i_dtime; /* Deletion Time */
- USHORT i_gid; /* Low 16 bits of Group Id */
- USHORT i_links_count; /* Links count */
- ULONG i_blocks; /* Blocks count */
- ULONG i_flags; /* File flags */
- union {
- struct {
- ULONG l_i_reserved1;
- } linux1;
- struct {
- ULONG h_i_translator;
- } hurd1;
- struct {
- ULONG m_i_reserved1;
- } masix1;
- } osd1; /* OS dependent 1 */
- ULONG i_block[EXT3_N_BLOCKS];/* Pointers to blocks */
- ULONG i_generation; /* File version (for NFS) */
- ULONG i_file_acl; /* File ACL */
- ULONG i_dir_acl; /* Directory ACL */
- ULONG i_faddr; /* Fragment address */
- union {
- struct {
- UCHAR l_i_frag; /* Fragment number */
- UCHAR l_i_fsize; /* Fragment size */
- USHORT i_pad1;
- USHORT l_i_uid_high; /* these 2 fields */
- USHORT l_i_gid_high; /* were reserved2[0] */
- ULONG l_i_reserved2;
- } linux2;
- struct {
- UCHAR h_i_frag; /* Fragment number */
- UCHAR h_i_fsize; /* Fragment size */
- USHORT h_i_mode_high;
- USHORT h_i_uid_high;
- USHORT h_i_gid_high;
- ULONG h_i_author;
- } hurd2;
- struct {
- UCHAR m_i_frag; /* Fragment number */
- UCHAR m_i_fsize; /* Fragment size */
- USHORT m_pad1;
- ULONG m_i_reserved2[2];
- } masix2;
- } osd2; /* OS dependent 2 */
-};
-
-#define i_size_high i_dir_acl
-
-#if defined(__KERNEL__) || defined(__linux__)
-#define i_reserved1 osd1.linux1.l_i_reserved1
-#define i_frag osd2.linux2.l_i_frag
-#define i_fsize osd2.linux2.l_i_fsize
-#define i_uid_low i_uid
-#define i_gid_low i_gid
-#define i_uid_high osd2.linux2.l_i_uid_high
-#define i_gid_high osd2.linux2.l_i_gid_high
-#define i_reserved2 osd2.linux2.l_i_reserved2
-
-#elif defined(__GNU__)
-
-#define i_translator osd1.hurd1.h_i_translator
-#define i_frag osd2.hurd2.h_i_frag;
-#define i_fsize osd2.hurd2.h_i_fsize;
-#define i_uid_high osd2.hurd2.h_i_uid_high
-#define i_gid_high osd2.hurd2.h_i_gid_high
-#define i_author osd2.hurd2.h_i_author
-
-#elif defined(__masix__)
-
-#define i_reserved1 osd1.masix1.m_i_reserved1
-#define i_frag osd2.masix2.m_i_frag
-#define i_fsize osd2.masix2.m_i_fsize
-#define i_reserved2 osd2.masix2.m_i_reserved2
-
-#endif /* defined(__KERNEL__) || defined(__linux__) */
-
-/*
- * File system states
- */
-#define EXT3_VALID_FS 0x0001 /* Unmounted cleanly */
-#define EXT3_ERROR_FS 0x0002 /* Errors detected */
-#define EXT3_ORPHAN_FS 0x0004 /* Orphans being recovered */
-
-/*
- * Mount flags
- */
-#define EXT3_MOUNT_CHECK 0x0001 /* Do mount-time checks */
-#define EXT3_MOUNT_GRPID 0x0004 /* Create files with directory's group */
-#define EXT3_MOUNT_DEBUG 0x0008 /* Some debugging messages */
-#define EXT3_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */
-#define EXT3_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */
-#define EXT3_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */
-#define EXT3_MOUNT_MINIX_DF 0x0080 /* Mimics the Minix statfs */
-#define EXT3_MOUNT_NOLOAD 0x0100 /* Don't use existing journal*/
-#define EXT3_MOUNT_ABORT 0x0200 /* Fatal error detected */
-#define EXT3_MOUNT_DATA_FLAGS 0x0C00 /* Mode for data writes: */
- #define EXT3_MOUNT_JOURNAL_DATA 0x0400 /* Write data to journal */
- #define EXT3_MOUNT_ORDERED_DATA 0x0800 /* Flush data before commit */
- #define EXT3_MOUNT_WRITEBACK_DATA 0x0C00 /* No data ordering */
-#define EXT3_MOUNT_UPDATE_JOURNAL 0x1000 /* Update the journal format */
-#define EXT3_MOUNT_NO_UID32 0x2000 /* Disable 32-bit UIDs */
-
-/* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
-#ifndef _LINUX_EXT2_FS_H
-#define clear_opt(o, opt) o &= ~EXT3_MOUNT_##opt
-#define set_opt(o, opt) o |= EXT3_MOUNT_##opt
-#define test_opt(sb, opt) ((sb)->u.ext3_sb.s_mount_opt & \
- EXT3_MOUNT_##opt)
-#else
-#define EXT2_MOUNT_NOLOAD EXT3_MOUNT_NOLOAD
-#define EXT2_MOUNT_ABORT EXT3_MOUNT_ABORT
-#endif
-
-#define ext3_set_bit ext2_set_bit
-#define ext3_clear_bit ext2_clear_bit
-#define ext3_test_bit ext2_test_bit
-#define ext3_find_first_zero_bit ext2_find_first_zero_bit
-#define ext3_find_next_zero_bit ext2_find_next_zero_bit
-
-/*
- * Maximal mount counts between two filesystem checks
- */
-#define EXT3_DFL_MAX_MNT_COUNT 20 /* Allow 20 mounts */
-#define EXT3_DFL_CHECKINTERVAL 0 /* Don't use interval check */
-
-/*
- * Behaviour when detecting errors
- */
-#define EXT3_ERRORS_CONTINUE 1 /* Continue execution */
-#define EXT3_ERRORS_RO 2 /* Remount fs read-only */
-#define EXT3_ERRORS_PANIC 3 /* Panic */
-#define EXT3_ERRORS_DEFAULT EXT3_ERRORS_CONTINUE
-
-/*
- * Structure of the super block
- */
-struct ext3_super_block {
-/*00*/ ULONG s_inodes_count; /* Inodes count */
- ULONG s_blocks_count; /* Blocks count */
- ULONG s_r_blocks_count; /* Reserved blocks count */
- ULONG s_free_blocks_count; /* Free blocks count */
-/*10*/ ULONG s_free_inodes_count; /* Free inodes count */
- ULONG s_first_data_block; /* First Data Block */
- ULONG s_log_block_size; /* Block size */
- LONG s_log_frag_size; /* Fragment size */
-/*20*/ ULONG s_blocks_per_group; /* # Blocks per group */
- ULONG s_frags_per_group; /* # Fragments per group */
- ULONG s_inodes_per_group; /* # Inodes per group */
- ULONG s_mtime; /* Mount time */
-/*30*/ ULONG s_wtime; /* Write time */
- USHORT s_mnt_count; /* Mount count */
- SHORT s_max_mnt_count; /* Maximal mount count */
- USHORT s_magic; /* Magic signature */
- USHORT s_state; /* File system state */
- USHORT s_errors; /* Behaviour when detecting errors */
- USHORT s_minor_rev_level; /* minor revision level */
-/*40*/ ULONG s_lastcheck; /* time of last check */
- ULONG s_checkinterval; /* max. time between checks */
- ULONG s_creator_os; /* OS */
- ULONG s_rev_level; /* Revision level */
-/*50*/ USHORT s_def_resuid; /* Default uid for reserved blocks */
- USHORT s_def_resgid; /* Default gid for reserved blocks */
- /*
- * These fields are for EXT3_DYNAMIC_REV superblocks only.
- *
- * Note: the difference between the compatible feature set and
- * the incompatible feature set is that if there is a bit set
- * in the incompatible feature set that the kernel doesn't
- * know about, it should refuse to mount the filesystem.
- *
- * e2fsck's requirements are more strict; if it doesn't know
- * about a feature in either the compatible or incompatible
- * feature set, it must abort and not try to meddle with
- * things it doesn't understand...
- */
- ULONG s_first_ino; /* First non-reserved inode */
- USHORT s_inode_size; /* size of inode structure */
- USHORT s_block_group_nr; /* block group # of this superblock */
- ULONG s_feature_compat; /* compatible feature set */
-/*60*/ ULONG s_feature_incompat; /* incompatible feature set */
- ULONG s_feature_ro_compat; /* readonly-compatible feature set */
-/*68*/ UCHAR s_uuid[16]; /* 128-bit uuid for volume */
-/*78*/ char s_volume_name[16]; /* volume name */
-/*88*/ char s_last_mounted[64]; /* directory where last mounted */
-/*C8*/ ULONG s_algorithm_usage_bitmap; /* For compression */
- /*
- * Performance hints. Directory preallocation should only
- * happen if the EXT3_FEATURE_COMPAT_DIR_PREALLOC flag is on.
- */
- UCHAR s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
- UCHAR s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
- USHORT s_padding1;
- /*
- * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
- */
-/*D0*/ UCHAR s_journal_uuid[16]; /* uuid of journal superblock */
-/*E0*/ ULONG s_journal_inum; /* inode number of journal file */
- ULONG s_journal_dev; /* device number of journal file */
- ULONG s_last_orphan; /* start of list of inodes to delete */
-
-/*EC*/ ULONG s_reserved[197]; /* Padding to the end of the block */
-};
-
-#ifdef __KERNEL__
-#define EXT3_SB(sb) (&((sb)->u.ext3_sb))
-#define EXT3_I(inode) (&((inode)->u.ext3_i))
-#else
-/* Assume that user mode programs are passing in an ext3fs superblock, not
- * a kernel struct super_block. This will allow us to call the feature-test
- * macros from user land. */
-#define EXT3_SB(sb) (sb)
-#endif
-
-#define NEXT_ORPHAN(inode) (inode)->u.ext3_i.i_dtime
-
-/*
- * Codes for operating systems
- */
-#define EXT3_OS_LINUX 0
-#define EXT3_OS_HURD 1
-#define EXT3_OS_MASIX 2
-#define EXT3_OS_FREEBSD 3
-#define EXT3_OS_LITES 4
-
-/*
- * Revision levels
- */
-#define EXT3_GOOD_OLD_REV 0 /* The good old (original) format */
-#define EXT3_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */
-
-#define EXT3_CURRENT_REV EXT3_GOOD_OLD_REV
-#define EXT3_MAX_SUPP_REV EXT3_DYNAMIC_REV
-
-#define EXT3_GOOD_OLD_INODE_SIZE 128
-
-/*
- * Feature set definitions
- */
-
-#define EXT3_HAS_COMPAT_FEATURE(sb,mask) \
- ( EXT3_SB(sb)->s_es->s_feature_compat & cpu_to_le32(mask) )
-#define EXT3_HAS_RO_COMPAT_FEATURE(sb,mask) \
- ( EXT3_SB(sb)->s_es->s_feature_ro_compat & cpu_to_le32(mask) )
-#define EXT3_HAS_INCOMPAT_FEATURE(sb,mask) \
- ( EXT3_SB(sb)->s_es->s_feature_incompat & cpu_to_le32(mask) )
-#define EXT3_SET_COMPAT_FEATURE(sb,mask) \
- EXT3_SB(sb)->s_es->s_feature_compat |= cpu_to_le32(mask)
-#define EXT3_SET_RO_COMPAT_FEATURE(sb,mask) \
- EXT3_SB(sb)->s_es->s_feature_ro_compat |= cpu_to_le32(mask)
-#define EXT3_SET_INCOMPAT_FEATURE(sb,mask) \
- EXT3_SB(sb)->s_es->s_feature_incompat |= cpu_to_le32(mask)
-#define EXT3_CLEAR_COMPAT_FEATURE(sb,mask) \
- EXT3_SB(sb)->s_es->s_feature_compat &= ~cpu_to_le32(mask)
-#define EXT3_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
- EXT3_SB(sb)->s_es->s_feature_ro_compat &= ~cpu_to_le32(mask)
-#define EXT3_CLEAR_INCOMPAT_FEATURE(sb,mask) \
- EXT3_SB(sb)->s_es->s_feature_incompat &= ~cpu_to_le32(mask)
-
-#define EXT3_FEATURE_COMPAT_DIR_PREALLOC 0x0001
-#define EXT3_FEATURE_COMPAT_IMAGIC_INODES 0x0002
-#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
-#define EXT3_FEATURE_COMPAT_EXT_ATTR 0x0008
-#define EXT3_FEATURE_COMPAT_RESIZE_INODE 0x0010
-#define EXT3_FEATURE_COMPAT_DIR_INDEX 0x0020
-
-#define EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
-#define EXT3_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
-#define EXT3_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
-
-#define EXT3_FEATURE_INCOMPAT_COMPRESSION 0x0001
-#define EXT3_FEATURE_INCOMPAT_FILETYPE 0x0002
-#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
-#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
-
-#define EXT3_FEATURE_COMPAT_SUPP 0
-/*#define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE| \
- EXT3_FEATURE_INCOMPAT_RECOVER)*/
-#define EXT3_FEATURE_INCOMPAT_SUPP (EXT3_FEATURE_INCOMPAT_FILETYPE)
-#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER| \
- EXT3_FEATURE_RO_COMPAT_LARGE_FILE| \
- EXT3_FEATURE_RO_COMPAT_BTREE_DIR)
-
-/*
- * Default values for user and/or group using reserved blocks
- */
-#define EXT3_DEF_RESUID 0
-#define EXT3_DEF_RESGID 0
-
-/*
- * Structure of a directory entry
- */
-#define EXT3_NAME_LEN 255
-
-struct ext3_dir_entry {
- ULONG inode; /* Inode number */
- USHORT rec_len; /* Directory entry length */
- USHORT name_len; /* Name length */
- CHAR name[EXT3_NAME_LEN]; /* File name */
-};
-
-/*
- * The new version of the directory entry. Since EXT3 structures are
- * stored in intel byte order, and the name_len field could never be
- * bigger than 255 chars, it's safe to reclaim the extra byte for the
- * file_type field.
- */
-struct ext3_dir_entry_2 {
- ULONG inode; /* Inode number */
- USHORT rec_len; /* Directory entry length */
- UCHAR name_len; /* Name length */
- UCHAR file_type;
- CHAR name[EXT3_NAME_LEN]; /* File name */
-};
-
-/*
- * Ext3 directory file types. Only the low 3 bits are used. The
- * other bits are reserved for now.
- */
-#define EXT3_FT_UNKNOWN 0
-#define EXT3_FT_REG_FILE 1
-#define EXT3_FT_DIR 2
-#define EXT3_FT_CHRDEV 3
-#define EXT3_FT_BLKDEV 4
-#define EXT3_FT_FIFO 5
-#define EXT3_FT_SOCK 6
-#define EXT3_FT_SYMLINK 7
-
-#define EXT3_FT_MAX 8
-
-/*
- * EXT3_DIR_PAD defines the directory entries boundaries
- *
- * NOTE: It must be a multiple of 4
- */
-#define EXT3_DIR_PAD 4
-#define EXT3_DIR_ROUND (EXT3_DIR_PAD - 1)
-#define EXT3_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT3_DIR_ROUND) & \
- ~EXT3_DIR_ROUND)
-
-#ifdef __KERNEL__
-/*
- * Describe an inode's exact location on disk and in memory
- */
-struct ext3_iloc
-{
- struct buffer_head *bh;
- struct ext3_inode *raw_inode;
- unsigned long block_group;
-};
-
-
-
-#endif /* __KERNEL__ */
-
-#endif /* _LINUX_EXT3_FS_H */
-
-
-
-typedef struct ext3_super_block EXT2_SUPER_BLOCK, *PEXT2_SUPER_BLOCK;
-typedef struct ext3_inode EXT2_INODE, *PEXT2_INODE;
-typedef struct ext3_group_desc EXT2_GROUP_DESC, *PEXT2_GROUP_DESC;
-typedef struct ext3_dir_entry_2 EXT2_DIR_ENTRY, *PEXT2_DIR_ENTRY;
-
-// EXT2_INODE::i_mode values
+typedef struct ext2_sblock EXT2_SUPER_BLOCK, *PEXT2_SUPER_BLOCK;
+typedef struct ext2_inode EXT2_INODE, *PEXT2_INODE;
+typedef struct ext2_block_group EXT2_GROUP_DESC, *PEXT2_GROUP_DESC;
+typedef struct ext2_dirent EXT2_DIR_ENTRY, *PEXT2_DIR_ENTRY;
+
+/* Special inode numbers. */
+#define EXT2_ROOT_INO 2
+
+/* Feature set definitions. */
+#define EXT3_FEATURE_INCOMPAT_SUPP 0x0002
+
+/* Log2 size of ext2 block in bytes. */
+#define LOG2_BLOCK_SIZE(sb) (sb->log2_block_size + 10)
+
+/* The size of an ext2 block in bytes. */
+#define EXT2_BLOCK_SIZE(sb) (1 << LOG2_BLOCK_SIZE(sb))
+
+/* The revision level. */
+#define EXT2_REVISION(sb) (sb->revision_level)
+
+/* The inode size. */
+#define EXT2_INODE_SIZE(sb) (EXT2_REVISION(sb) == EXT2_GOOD_OLD_REVISION \
+ ? EXT2_GOOD_OLD_INODE_SIZE \
+ : sb->inode_size)
+
+#define EXT2_DESC_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof(struct ext2_block_group))
+
+// EXT2_INODE::mode values
#define EXT2_S_IRWXO 0x0007 // Other mask
#define EXT2_S_IXOTH 0x0001 // ---------x execute
#define EXT2_S_IWOTH 0x0002 // --------w- write
@@ -657,15 +224,15 @@
#define EXT2_S_IFLNK 0xA000 // Symbolic link
#define EXT2_S_IFSOCK 0xC000 // Socket
-#define FAST_SYMLINK_MAX_NAME_SIZE (EXT3_N_BLOCKS * sizeof(ULONG)) /* 60 bytes */
+#define FAST_SYMLINK_MAX_NAME_SIZE 60
typedef struct
{
- ULONGLONG FileSize; // File size
- ULONGLONG FilePointer; // File pointer
+ ULONGLONG FileSize; // File size
+ ULONGLONG FilePointer; // File pointer
ULONG* FileBlockList; // File block list
- UCHAR DriveNumber; // Drive number of open file
- EXT2_INODE Inode; // File's inode
+ UCHAR DriveNumber; // Drive number of open file
+ EXT2_INODE Inode; // File's inode
} EXT2_FILE_INFO, * PEXT2_FILE_INFO;
const DEVVTBL* Ext2Mount(ULONG DeviceId);