mirror of
https://github.com/reactos/reactos.git
synced 2024-07-14 00:25:05 +00:00
Fix ext2lib compilation
svn path=/trunk/; revision=32285
This commit is contained in:
parent
a3445ec1e4
commit
3b8ed580d8
|
@ -1,6 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd">
|
||||
<group xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<directory name="ext2lib">
|
||||
<xi:include href="ext2lib/ext2lib.rbuild" />
|
||||
</directory>
|
||||
<directory name="vfatlib">
|
||||
<xi:include href="vfatlib/vfatlib.rbuild" />
|
||||
</directory>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
/* INCLUDES **************************************************************/
|
||||
|
||||
#include "Mke2fs.h"
|
||||
#include <debug.h>
|
||||
|
||||
/* DEFINITIONS ***********************************************************/
|
||||
|
||||
|
@ -102,11 +103,11 @@ bool ext2_allocate_block_bitmap(PEXT2_FILESYS Ext2Sys)
|
|||
|
||||
PEXT2_SUPER_BLOCK pExt2Sb = Ext2Sys->ext2_sb;
|
||||
Ext2Sys->block_map = (PEXT2_BLOCK_BITMAP)
|
||||
RtlAllocateHeap(GetProcessHeap(), 0, sizeof(EXT2_BLOCK_BITMAP));
|
||||
RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(EXT2_BLOCK_BITMAP));
|
||||
|
||||
if (!Ext2Sys->block_map)
|
||||
{
|
||||
KdPrint(("Mke2fs: error allocating block bitmap...\n"));
|
||||
DPRINT1("Mke2fs: error allocating block bitmap...\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -120,13 +121,13 @@ bool ext2_allocate_block_bitmap(PEXT2_FILESYS Ext2Sys)
|
|||
size = (((Ext2Sys->block_map->real_end - Ext2Sys->block_map->start) / 8) + 1);
|
||||
|
||||
Ext2Sys->block_map->bitmap =
|
||||
(char *)RtlAllocateHeap(GetProcessHeap(), 0, size);
|
||||
(char *)RtlAllocateHeap(RtlGetProcessHeap(), 0, size);
|
||||
|
||||
if (!Ext2Sys->block_map->bitmap)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, Ext2Sys->block_map);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Ext2Sys->block_map);
|
||||
Ext2Sys->block_map = NULL;
|
||||
KdPrint(("Mke2fs: error allocating block bitmap...\n"));
|
||||
DPRINT1("Mke2fs: error allocating block bitmap...\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -143,11 +144,11 @@ bool ext2_allocate_inode_bitmap(PEXT2_FILESYS Ext2Sys)
|
|||
PEXT2_SUPER_BLOCK pExt2Sb = Ext2Sys->ext2_sb;
|
||||
|
||||
Ext2Sys->inode_map = (PEXT2_INODE_BITMAP)
|
||||
RtlAllocateHeap(GetProcessHeap(), 0, sizeof(EXT2_INODE_BITMAP));
|
||||
RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(EXT2_INODE_BITMAP));
|
||||
|
||||
if (!Ext2Sys->inode_map)
|
||||
{
|
||||
KdPrint(("Mke2fs: error allocating inode bitmap...\n"));
|
||||
DPRINT1("Mke2fs: error allocating inode bitmap...\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -161,13 +162,13 @@ bool ext2_allocate_inode_bitmap(PEXT2_FILESYS Ext2Sys)
|
|||
size = (((Ext2Sys->inode_map->real_end - Ext2Sys->inode_map->start) / 8) + 1);
|
||||
|
||||
Ext2Sys->inode_map->bitmap =
|
||||
(char *)RtlAllocateHeap(GetProcessHeap(), 0, size);
|
||||
(char *)RtlAllocateHeap(RtlGetProcessHeap(), 0, size);
|
||||
|
||||
if (!Ext2Sys->inode_map->bitmap)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, Ext2Sys->inode_map);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Ext2Sys->inode_map);
|
||||
Ext2Sys->inode_map = NULL;
|
||||
KdPrint(("Mke2fs: error allocating block bitmap...\n"));
|
||||
DPRINT1("Mke2fs: error allocating block bitmap...\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -183,11 +184,11 @@ void ext2_free_generic_bitmap(PEXT2_GENERIC_BITMAP bitmap)
|
|||
|
||||
if (bitmap->bitmap)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, bitmap->bitmap);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, bitmap->bitmap);
|
||||
bitmap->bitmap = 0;
|
||||
}
|
||||
|
||||
RtlFreeHeap(GetProcessHeap(), 0, bitmap);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, bitmap);
|
||||
}
|
||||
|
||||
void ext2_free_inode_bitmap(PEXT2_FILESYS Ext2Sys)
|
||||
|
@ -226,7 +227,7 @@ bool ext2_write_inode_bitmap(PEXT2_FILESYS fs)
|
|||
|
||||
nbytes = (size_t) ((EXT2_INODES_PER_GROUP(fs->ext2_sb)+7) / 8);
|
||||
|
||||
bitmap_block = (char *)RtlAllocateHeap(GetProcessHeap(), 0, fs->blocksize);
|
||||
bitmap_block = (char *)RtlAllocateHeap(RtlGetProcessHeap(), 0, fs->blocksize);
|
||||
if (!bitmap_block) return false;
|
||||
|
||||
memset(bitmap_block, 0xff, fs->blocksize);
|
||||
|
@ -253,7 +254,7 @@ bool ext2_write_inode_bitmap(PEXT2_FILESYS fs)
|
|||
|
||||
if (!retval)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, bitmap_block);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, bitmap_block);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -261,7 +262,7 @@ bool ext2_write_inode_bitmap(PEXT2_FILESYS fs)
|
|||
inode_bitmap += nbytes;
|
||||
}
|
||||
|
||||
RtlFreeHeap(GetProcessHeap(), 0, bitmap_block);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, bitmap_block);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -282,7 +283,7 @@ bool ext2_write_block_bitmap (PEXT2_FILESYS fs)
|
|||
|
||||
nbytes = EXT2_BLOCKS_PER_GROUP(fs->ext2_sb) / 8;
|
||||
|
||||
bitmap_block = (char *)RtlAllocateHeap(GetProcessHeap(), 0, fs->blocksize);
|
||||
bitmap_block = (char *)RtlAllocateHeap(RtlGetProcessHeap(), 0, fs->blocksize);
|
||||
if (!bitmap_block)
|
||||
return false;
|
||||
|
||||
|
@ -325,7 +326,7 @@ bool ext2_write_block_bitmap (PEXT2_FILESYS fs)
|
|||
|
||||
if (!retval)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, bitmap_block);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, bitmap_block);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +334,7 @@ bool ext2_write_block_bitmap (PEXT2_FILESYS fs)
|
|||
block_bitmap += nbytes;
|
||||
}
|
||||
|
||||
RtlFreeHeap(GetProcessHeap(), 0, bitmap_block);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, bitmap_block);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -465,13 +466,13 @@ cleanup:
|
|||
|
||||
if (do_block)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, fs->block_map);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, fs->block_map);
|
||||
fs->block_map = NULL;
|
||||
}
|
||||
|
||||
if (do_inode)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, fs->inode_map);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, fs->inode_map);
|
||||
fs->inode_map = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
/* INCLUDES **************************************************************/
|
||||
|
||||
#include "Mke2fs.h"
|
||||
#include <debug.h>
|
||||
|
||||
/* DEFINITIONS ***********************************************************/
|
||||
|
||||
|
@ -15,7 +16,7 @@
|
|||
|
||||
/* FUNCTIONS *************************************************************/
|
||||
|
||||
PUCHAR
|
||||
PCCHAR
|
||||
Ext2StatusToString ( IN NTSTATUS Status )
|
||||
{
|
||||
switch (Status)
|
||||
|
@ -1001,7 +1002,7 @@ Ext2ReadDisk( PEXT2_FILESYS Ext2Sys,
|
|||
AlignedLength += ((ULONG)(Offset - Address.QuadPart) + SECTOR_SIZE - 1)
|
||||
& (~(SECTOR_SIZE - 1));
|
||||
|
||||
NonPagedBuffer = RtlAllocateHeap(GetProcessHeap(), 0, AlignedLength);
|
||||
NonPagedBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, AlignedLength);
|
||||
if (!NonPagedBuffer)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -1031,7 +1032,7 @@ Ext2ReadDisk( PEXT2_FILESYS Ext2Sys,
|
|||
errorout:
|
||||
|
||||
if (NonPagedBuffer)
|
||||
RtlFreeHeap(GetProcessHeap(), 0, NonPagedBuffer);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, NonPagedBuffer);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -1096,7 +1097,7 @@ Ext2WriteDisk( PEXT2_FILESYS Ext2Sys,
|
|||
AlignedLength += ((ULONG)(Offset - Address.QuadPart) + SECTOR_SIZE - 1)
|
||||
& (~(SECTOR_SIZE - 1));
|
||||
|
||||
NonPagedBuffer = RtlAllocateHeap(GetProcessHeap(), 0, AlignedLength);
|
||||
NonPagedBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, AlignedLength);
|
||||
if (!NonPagedBuffer)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
@ -1138,7 +1139,7 @@ Ext2WriteDisk( PEXT2_FILESYS Ext2Sys,
|
|||
errorout:
|
||||
|
||||
if (NonPagedBuffer)
|
||||
RtlFreeHeap(GetProcessHeap(), 0, NonPagedBuffer);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, NonPagedBuffer);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -1221,8 +1222,8 @@ Ext2LockVolume( PEXT2_FILESYS Ext2Sys )
|
|||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
KdPrint(("Mke2fs: Error when locking volume: Status = %lxh %s...\n",
|
||||
Status, Ext2StatusToString(Status)));
|
||||
DPRINT1("Mke2fs: Error when locking volume: Status = %lxh %s...\n",
|
||||
Status, Ext2StatusToString(Status));
|
||||
|
||||
goto errorout;
|
||||
}
|
||||
|
@ -1246,7 +1247,7 @@ Ext2UnLockVolume( PEXT2_FILESYS Ext2Sys )
|
|||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
KdPrint(("Mke2fs: Error when unlocking volume ...\n"));
|
||||
DPRINT1("Mke2fs: Error when unlocking volume ...\n");
|
||||
goto errorout;
|
||||
}
|
||||
|
||||
|
@ -1269,7 +1270,7 @@ Ext2DisMountVolume( PEXT2_FILESYS Ext2Sys )
|
|||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
KdPrint(("Mke2fs: Error when dismounting volume ...\n"));
|
||||
DPRINT1("Mke2fs: Error when dismounting volume ...\n");
|
||||
goto errorout;
|
||||
}
|
||||
|
||||
|
@ -1318,7 +1319,7 @@ Ext2OpenDevice( PEXT2_FILESYS Ext2Sys,
|
|||
//
|
||||
if( !NT_SUCCESS(Status) )
|
||||
{
|
||||
KdPrint(("Mke2fs: Create system service failed status = 0x%lx\n", Status));
|
||||
DPRINT1("Mke2fs: Create system service failed status = 0x%lx\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -1328,7 +1329,7 @@ Ext2OpenDevice( PEXT2_FILESYS Ext2Sys,
|
|||
//
|
||||
if(!NT_SUCCESS(Iosb.Status) )
|
||||
{
|
||||
KdPrint(("Mke2fs: Create failed with status = 0x%lx\n",Iosb.Status));
|
||||
DPRINT1("Mke2fs: Create failed with status = 0x%lx\n",Iosb.Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ bool ext2_allocate_group_desc(PEXT2_FILESYS Ext2Sys)
|
|||
size = Ext2Sys->desc_blocks * Ext2Sys->blocksize;
|
||||
|
||||
Ext2Sys->group_desc =
|
||||
(PEXT2_GROUP_DESC)RtlAllocateHeap(GetProcessHeap(), 0, size);
|
||||
(PEXT2_GROUP_DESC)RtlAllocateHeap(RtlGetProcessHeap(), 0, size);
|
||||
|
||||
if (Ext2Sys->group_desc)
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ void ext2_free_group_desc(PEXT2_FILESYS Ext2Sys)
|
|||
{
|
||||
if (Ext2Sys->group_desc)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, Ext2Sys->group_desc);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Ext2Sys->group_desc);
|
||||
Ext2Sys->group_desc = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
/* INCLUDES **************************************************************/
|
||||
|
||||
#include "Mke2fs.h"
|
||||
#include <debug.h>
|
||||
|
||||
/* DEFINITIONS ***********************************************************/
|
||||
|
||||
|
@ -23,8 +24,8 @@ bool ext2_get_inode_lba(PEXT2_FILESYS Ext2Sys, ULONG no, LONGLONG *offset)
|
|||
|
||||
if (no < 1 || no > pExt2Sb->s_inodes_count)
|
||||
{
|
||||
KdPrint(("Mke2fs: Inode value %lu was out of range in load_inode.(1-%ld)\n",
|
||||
no, pExt2Sb->s_inodes_count));
|
||||
DPRINT1("Mke2fs: Inode value %lu was out of range in load_inode.(1-%ld)\n",
|
||||
no, pExt2Sb->s_inodes_count);
|
||||
*offset = 0;
|
||||
return false;
|
||||
}
|
||||
|
@ -138,7 +139,7 @@ bool ext2_expand_block( PEXT2_FILESYS Ext2Sys, PEXT2_INODE Inode,
|
|||
|
||||
PEXT2_SUPER_BLOCK pExt2Sb = Ext2Sys->ext2_sb;
|
||||
|
||||
pData = (ULONG *)RtlAllocateHeap(GetProcessHeap(), 0, Ext2Sys->blocksize);
|
||||
pData = (ULONG *)RtlAllocateHeap(RtlGetProcessHeap(), 0, Ext2Sys->blocksize);
|
||||
|
||||
if (!pData)
|
||||
{
|
||||
|
@ -186,7 +187,7 @@ bool ext2_expand_block( PEXT2_FILESYS Ext2Sys, PEXT2_INODE Inode,
|
|||
if (!ext2_expand_block(Ext2Sys, Inode, dwBlk, j, layer - 1, bDirty, &dwNewBlk, &Offset))
|
||||
{
|
||||
bRet = false;
|
||||
KdPrint(("Mke2fs: ext2_expand_block: ... error recuise...\n"));
|
||||
DPRINT1("Mke2fs: ext2_expand_block: ... error recuise...\n");
|
||||
goto errorout;
|
||||
}
|
||||
}
|
||||
|
@ -200,7 +201,7 @@ bool ext2_expand_block( PEXT2_FILESYS Ext2Sys, PEXT2_INODE Inode,
|
|||
errorout:
|
||||
|
||||
if (pData)
|
||||
RtlFreeHeap(GetProcessHeap(), 0, pData);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, pData);
|
||||
|
||||
if (bRet && dwRet)
|
||||
*dwRet = dwNewBlk;
|
||||
|
@ -233,7 +234,7 @@ bool ext2_expand_inode( PEXT2_FILESYS Ext2Sys,
|
|||
|
||||
if (Index >= dwTotal)
|
||||
{
|
||||
KdPrint(("Mke2fs: ext2_expand_inode: beyond the maxinum size of an inode.\n"));
|
||||
DPRINT1("Mke2fs: ext2_expand_inode: beyond the maxinum size of an inode.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -300,7 +301,7 @@ bool ext2_get_block(PEXT2_FILESYS Ext2Sys, ULONG dwContent, ULONG Index, int lay
|
|||
Offset = (LONGLONG) dwContent;
|
||||
Offset = Offset * Ext2Sys->blocksize;
|
||||
|
||||
pData = (ULONG *)RtlAllocateHeap(GetProcessHeap(), 0, Ext2Sys->blocksize);
|
||||
pData = (ULONG *)RtlAllocateHeap(RtlGetProcessHeap(), 0, Ext2Sys->blocksize);
|
||||
|
||||
if (!pData)
|
||||
{
|
||||
|
@ -329,7 +330,7 @@ bool ext2_get_block(PEXT2_FILESYS Ext2Sys, ULONG dwContent, ULONG Index, int lay
|
|||
if (!ext2_get_block(Ext2Sys, pData[i], j, layer - 1, &dwBlk))
|
||||
{
|
||||
bRet = false;
|
||||
KdPrint(("Mke2fs: ext2_get_block: ... error recuise...\n"));
|
||||
DPRINT1("Mke2fs: ext2_get_block: ... error recuise...\n");
|
||||
goto errorout;
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +338,7 @@ bool ext2_get_block(PEXT2_FILESYS Ext2Sys, ULONG dwContent, ULONG Index, int lay
|
|||
errorout:
|
||||
|
||||
if (pData)
|
||||
RtlFreeHeap(GetProcessHeap(), 0, pData);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, pData);
|
||||
|
||||
if (bRet && dwRet)
|
||||
*dwRet = dwBlk;
|
||||
|
@ -363,7 +364,7 @@ bool ext2_block_map(PEXT2_FILESYS Ext2Sys, PEXT2_INODE inode, ULONG block, ULONG
|
|||
|
||||
if (Index >= inode->i_blocks / (Ext2Sys->blocksize / SECTOR_SIZE))
|
||||
{
|
||||
KdPrint(("Mke2fs: ext2_block_map: beyond the size of the inode.\n"));
|
||||
DPRINT1("Mke2fs: ext2_block_map: beyond the size of the inode.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -409,7 +410,7 @@ ULONG ext2_build_bdl(PEXT2_FILESYS Ext2Sys,
|
|||
|
||||
if (offset >= ext2_inode->i_size)
|
||||
{
|
||||
KdPrint(("Mke2fs: ext2_build_bdl: beyond the file range.\n"));
|
||||
DPRINT1("Mke2fs: ext2_build_bdl: beyond the file range.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -428,7 +429,7 @@ ULONG ext2_build_bdl(PEXT2_FILESYS Ext2Sys,
|
|||
if (nBlocks > 0)
|
||||
{
|
||||
ext2bdl = (PEXT2_BDL)
|
||||
RtlAllocateHeap(GetProcessHeap(), 0, sizeof(EXT2_BDL) * nBlocks);
|
||||
RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(EXT2_BDL) * nBlocks);
|
||||
|
||||
if (ext2bdl)
|
||||
{
|
||||
|
@ -486,7 +487,7 @@ ULONG ext2_build_bdl(PEXT2_FILESYS Ext2Sys,
|
|||
fail:
|
||||
|
||||
if (ext2bdl)
|
||||
RtlFreeHeap(GetProcessHeap(), 0, ext2bdl);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, ext2bdl);
|
||||
|
||||
// Error
|
||||
return 0;
|
||||
|
@ -534,7 +535,7 @@ bool ext2_read_inode(PEXT2_FILESYS Ext2Sys,
|
|||
*dwReturn = dwTotal;
|
||||
|
||||
if (ext2_bdl)
|
||||
RtlFreeHeap(GetProcessHeap(), 0, ext2_bdl);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, ext2_bdl);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
@ -612,7 +613,7 @@ bool ext2_write_inode (PEXT2_FILESYS Ext2Sys,
|
|||
errorout:
|
||||
|
||||
if (ext2_bdl)
|
||||
RtlFreeHeap(GetProcessHeap(), 0, ext2_bdl);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, ext2_bdl);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
@ -636,7 +637,7 @@ ext2_add_entry( PEXT2_FILESYS Ext2Sys,
|
|||
return false;
|
||||
}
|
||||
|
||||
buf = (char *)RtlAllocateHeap(GetProcessHeap(), 0, parent_inode.i_size);
|
||||
buf = (char *)RtlAllocateHeap(RtlGetProcessHeap(), 0, parent_inode.i_size);
|
||||
|
||||
if (!ext2_read_inode(Ext2Sys, parent, 0, buf, parent_inode.i_size, &dwRet))
|
||||
{
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
/* INCLUDES **************************************************************/
|
||||
|
||||
#include "Mke2fs.h"
|
||||
#include <debug.h>
|
||||
|
||||
/* DEFINITIONS ***********************************************************/
|
||||
|
||||
|
@ -232,9 +233,9 @@ bool write_inode_tables(PEXT2_FILESYS fs)
|
|||
retval = zero_blocks(fs, blk, num, &blk, &num);
|
||||
if (!retval)
|
||||
{
|
||||
KdPrint(("\nMke2fs: Could not write %lu blocks "
|
||||
DPRINT1("\nMke2fs: Could not write %lu blocks "
|
||||
"in inode table starting at %lu.\n",
|
||||
num, blk));
|
||||
num, blk);
|
||||
|
||||
zero_blocks(0, 0, 0, 0, 0);
|
||||
return false;
|
||||
|
@ -296,7 +297,7 @@ bool ext2_alloc_block(PEXT2_FILESYS fs, ULONG goal, ULONG *ret)
|
|||
ULONG block;
|
||||
char *buf = NULL;
|
||||
|
||||
buf = (char *)RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, fs->blocksize);
|
||||
buf = (char *)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, fs->blocksize);
|
||||
if (!buf)
|
||||
return false;
|
||||
|
||||
|
@ -327,7 +328,7 @@ bool ext2_alloc_block(PEXT2_FILESYS fs, ULONG goal, ULONG *ret)
|
|||
|
||||
if (buf)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, buf);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, buf);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -336,7 +337,7 @@ fail:
|
|||
|
||||
if (buf)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, buf);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, buf);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -354,7 +355,7 @@ bool ext2_new_dir_block(PEXT2_FILESYS fs, ULONG dir_ino,
|
|||
int rec_len;
|
||||
int filetype = 0;
|
||||
|
||||
buf = (char *)RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, fs->blocksize);
|
||||
buf = (char *)RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, fs->blocksize);
|
||||
if (!buf)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
/* INCLUDES **************************************************************/
|
||||
|
||||
#include "Mke2fs.h"
|
||||
#include <fmifs.h>
|
||||
#include <debug.h>
|
||||
|
||||
/* GLOBALS ***************************************************************/
|
||||
|
||||
|
@ -126,7 +126,7 @@ bool zero_blocks(PEXT2_FILESYS fs, ULONG blk, ULONG num,
|
|||
{
|
||||
if (buf)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, buf);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, buf);
|
||||
buf = 0;
|
||||
}
|
||||
return true;
|
||||
|
@ -138,10 +138,10 @@ bool zero_blocks(PEXT2_FILESYS fs, ULONG blk, ULONG num,
|
|||
if (!buf)
|
||||
{
|
||||
buf = (unsigned char *)
|
||||
RtlAllocateHeap(GetProcessHeap(), 0, fs->blocksize * STRIDE_LENGTH);
|
||||
RtlAllocateHeap(RtlGetProcessHeap(), 0, fs->blocksize * STRIDE_LENGTH);
|
||||
if (!buf)
|
||||
{
|
||||
KdPrint(("Mke2fs: while allocating zeroizing buffer"));
|
||||
DPRINT1("Mke2fs: while allocating zeroizing buffer");
|
||||
return false;
|
||||
}
|
||||
memset(buf, 0, fs->blocksize * STRIDE_LENGTH);
|
||||
|
@ -188,11 +188,11 @@ bool zap_sector(PEXT2_FILESYS Ext2Sys, int sect, int nsect)
|
|||
ULONG *magic;
|
||||
|
||||
buf = (unsigned char *)
|
||||
RtlAllocateHeap(GetProcessHeap(), 0, SECTOR_SIZE*nsect);
|
||||
RtlAllocateHeap(RtlGetProcessHeap(), 0, SECTOR_SIZE*nsect);
|
||||
if (!buf)
|
||||
{
|
||||
KdPrint(("Mke2fs: Out of memory erasing sectors %d-%d\n",
|
||||
sect, sect + nsect - 1));
|
||||
DPRINT1("Mke2fs: Out of memory erasing sectors %d-%d\n",
|
||||
sect, sect + nsect - 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ bool zap_sector(PEXT2_FILESYS Ext2Sys, int sect, int nsect)
|
|||
|
||||
clean_up:
|
||||
|
||||
RtlFreeHeap(GetProcessHeap(), 0, buf);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, buf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ cleanup:
|
|||
|
||||
if (block)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, block);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, block);
|
||||
block = NULL;
|
||||
}
|
||||
|
||||
|
@ -368,7 +368,7 @@ bool create_root_dir(PEXT2_FILESYS fs)
|
|||
|
||||
if (!retval)
|
||||
{
|
||||
KdPrint(("Mke2fs: while creating root dir"));
|
||||
DPRINT1("Mke2fs: while creating root dir");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,7 @@ bool create_root_dir(PEXT2_FILESYS fs)
|
|||
retval = ext2_save_inode(fs, EXT2_ROOT_INO, &inode);
|
||||
if (!retval)
|
||||
{
|
||||
KdPrint(("Mke2fs: while setting root inode ownership"));
|
||||
DPRINT1("Mke2fs: while setting root inode ownership");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ bool create_lost_and_found(PEXT2_FILESYS Ext2Sys)
|
|||
|
||||
char * buf;
|
||||
|
||||
buf = (char *)RtlAllocateHeap(GetProcessHeap(), 0, Ext2Sys->blocksize);
|
||||
buf = (char *)RtlAllocateHeap(RtlGetProcessHeap(), 0, Ext2Sys->blocksize);
|
||||
if (!buf)
|
||||
{
|
||||
bExt = FALSE;
|
||||
|
@ -419,7 +419,7 @@ bool create_lost_and_found(PEXT2_FILESYS Ext2Sys)
|
|||
|
||||
if (!retval)
|
||||
{
|
||||
KdPrint(("Mke2fs: while creating /lost+found.\n"));
|
||||
DPRINT1("Mke2fs: while creating /lost+found.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -437,14 +437,14 @@ bool create_lost_and_found(PEXT2_FILESYS Ext2Sys)
|
|||
|
||||
if (! retval)
|
||||
{
|
||||
KdPrint(("Mke2fs: create_lost_and_found: error alloc block.\n"));
|
||||
DPRINT1("Mke2fs: create_lost_and_found: error alloc block.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
retval = ext2_expand_inode(Ext2Sys, &inode, dwBlk);
|
||||
if (!retval)
|
||||
{
|
||||
KdPrint(("Mke2fs: errors when expanding /lost+found.\n"));
|
||||
DPRINT1("Mke2fs: errors when expanding /lost+found.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -471,7 +471,7 @@ errorout:
|
|||
|
||||
if (buf)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, buf);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, buf);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -658,11 +658,11 @@ bool create_journal_dev(PEXT2_FILESYS fs)
|
|||
|
||||
if (!retval)
|
||||
{
|
||||
KdPrint(("Mke2fs: ext2_create_journal_dev: while initializing journal superblock.\n"));
|
||||
DPRINT1("Mke2fs: ext2_create_journal_dev: while initializing journal superblock.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
KdPrint(("Mke2fs: Zeroing journal device: \n"));
|
||||
DPRINT("Mke2fs: Zeroing journal device: \n");
|
||||
|
||||
retval = zero_blocks(fs, 0, fs->ext2_sb->s_blocks_count,
|
||||
&blk, &count);
|
||||
|
@ -671,8 +671,8 @@ bool create_journal_dev(PEXT2_FILESYS fs)
|
|||
|
||||
if (!retval)
|
||||
{
|
||||
KdPrint(("Mke2fs: create_journal_dev: while zeroing journal device (block %lu, count %lu).\n",
|
||||
blk, count));
|
||||
DPRINT1("Mke2fs: create_journal_dev: while zeroing journal device (block %lu, count %lu).\n",
|
||||
blk, count);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -683,7 +683,7 @@ bool create_journal_dev(PEXT2_FILESYS fs)
|
|||
|
||||
if (!retval)
|
||||
{
|
||||
KdPrint(("Mke2fs: create_journal_dev: while writing journal superblock.\n"));
|
||||
DPRINT1("Mke2fs: create_journal_dev: while writing journal superblock.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -812,29 +812,29 @@ Ext2Format(PUNICODE_STRING DriveRoot,
|
|||
EXT2_FILESYS FileSys;
|
||||
ULONG Percent;
|
||||
|
||||
KdPrint(("%s:%d\n", __FILE__, __LINE__));
|
||||
CHECKPOINT;
|
||||
|
||||
Callback(PROGRESS, 0, (PVOID)&Percent);
|
||||
|
||||
KdPrint(("%s:%d\n", __FILE__, __LINE__));
|
||||
|
||||
CHECKPOINT;
|
||||
|
||||
RtlZeroMemory(&Ext2Sb, sizeof(EXT2_SUPER_BLOCK));
|
||||
RtlZeroMemory(&FileSys, sizeof(EXT2_FILESYS));
|
||||
FileSys.ext2_sb = &Ext2Sb;
|
||||
|
||||
KdPrint(("%s:%d\n", __FILE__, __LINE__));
|
||||
CHECKPOINT;
|
||||
|
||||
if (!NT_SUCCESS(Ext2OpenDevice(&FileSys, DriveRoot)))
|
||||
{
|
||||
KdPrint(("Mke2fs: Volume %wZ does not exist, ...\n", DriveRoot));
|
||||
DPRINT1("Mke2fs: Volume %wZ does not exist, ...\n", DriveRoot);
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
KdPrint(("%s:%d\n", __FILE__, __LINE__));
|
||||
CHECKPOINT;
|
||||
|
||||
if (!NT_SUCCESS(Ext2GetMediaInfo(&FileSys)))
|
||||
{
|
||||
KdPrint(("Mke2fs: Can't get media information\n"));
|
||||
DPRINT1("Mke2fs: Can't get media information\n");
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
|
@ -843,7 +843,7 @@ Ext2Format(PUNICODE_STRING DriveRoot,
|
|||
Ext2Sb.s_blocks_count = FileSys.PartInfo.PartitionLength.QuadPart /
|
||||
EXT2_BLOCK_SIZE(&Ext2Sb);
|
||||
|
||||
KdPrint(("%s:%d\n", __FILE__, __LINE__));
|
||||
CHECKPOINT;
|
||||
|
||||
/*
|
||||
* Calculate number of inodes based on the inode ratio
|
||||
|
@ -856,7 +856,7 @@ Ext2Format(PUNICODE_STRING DriveRoot,
|
|||
*/
|
||||
Ext2Sb.s_r_blocks_count = (Ext2Sb.s_blocks_count * 5) / 100;
|
||||
|
||||
KdPrint(("%s:%d\n", __FILE__, __LINE__));
|
||||
CHECKPOINT;
|
||||
|
||||
Status = Ext2LockVolume(&FileSys);
|
||||
if (NT_SUCCESS(Status))
|
||||
|
@ -864,16 +864,16 @@ Ext2Format(PUNICODE_STRING DriveRoot,
|
|||
bLocked = TRUE;
|
||||
}
|
||||
|
||||
KdPrint(("%s:%d\n", __FILE__, __LINE__));
|
||||
CHECKPOINT;
|
||||
|
||||
// Initialize
|
||||
if (!ext2_initialize_sb(&FileSys))
|
||||
{
|
||||
KdPrint(("Mke2fs: error...\n"));
|
||||
DPRINT1("Mke2fs: error...\n");
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
KdPrint(("%s:%d\n", __FILE__, __LINE__));
|
||||
CHECKPOINT;
|
||||
|
||||
zap_sector(&FileSys, 2, 6);
|
||||
|
||||
|
@ -946,7 +946,7 @@ Ext2Format(PUNICODE_STRING DriveRoot,
|
|||
|
||||
if (!bRet)
|
||||
{
|
||||
KdPrint(("Mke2fs: zeroing block %lu at end of filesystem", ret_blk));
|
||||
DPRINT1("Mke2fs: zeroing block %lu at end of filesystem", ret_blk);
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
|
@ -959,21 +959,21 @@ Ext2Format(PUNICODE_STRING DriveRoot,
|
|||
|
||||
create_bad_block_inode(&FileSys, NULL);
|
||||
|
||||
KdPrint(("Mke2fs: Writing superblocks and filesystem accounting information ... \n"));
|
||||
DPRINT("Mke2fs: Writing superblocks and filesystem accounting information ... \n");
|
||||
|
||||
if (!QuickFormat)
|
||||
{
|
||||
KdPrint(("Mke2fs: Slow format not supported yet\n"));
|
||||
DPRINT1("Mke2fs: Slow format not supported yet\n");
|
||||
}
|
||||
|
||||
if (!ext2_flush(&FileSys))
|
||||
{
|
||||
bRet = false;
|
||||
KdPrint(("Mke2fs: Warning, had trouble writing out superblocks.\n"));
|
||||
DPRINT1("Mke2fs: Warning, had trouble writing out superblocks.\n");
|
||||
goto clean_up;
|
||||
}
|
||||
|
||||
KdPrint(("Mke2fs: Writing superblocks and filesystem accounting information done!\n"));
|
||||
DPRINT("Mke2fs: Writing superblocks and filesystem accounting information done!\n");
|
||||
|
||||
bRet = true;
|
||||
Status = STATUS_SUCCESS;
|
||||
|
@ -998,13 +998,13 @@ clean_up:
|
|||
}
|
||||
}
|
||||
|
||||
KdPrint(("%s:%d\n", __FILE__, __LINE__));
|
||||
CHECKPOINT;
|
||||
Ext2CloseDevice(&FileSys);
|
||||
KdPrint(("%s:%d\n", __FILE__, __LINE__));
|
||||
CHECKPOINT;
|
||||
|
||||
KdPrint(("%s:%d\n", __FILE__, __LINE__));
|
||||
CHECKPOINT;
|
||||
Callback(DONE, 0, (PVOID)&bRet);
|
||||
KdPrint(("%s:%d\n", __FILE__, __LINE__));
|
||||
CHECKPOINT;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
|
|
@ -12,16 +12,12 @@
|
|||
/* INCLUDES **************************************************************/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ntddk.h>
|
||||
#include <ntdddisk.h>
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
#define NTOS_MODE_USER
|
||||
#include <ndk/ntndk.h>
|
||||
#include <fmifs/fmifs.h>
|
||||
|
||||
#include <napi/teb.h>
|
||||
|
||||
#include "time.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "ctype.h"
|
||||
|
||||
|
@ -30,8 +26,6 @@
|
|||
|
||||
#include "getopt.h"
|
||||
|
||||
#define NTSYSAPI
|
||||
|
||||
/* DEFINITIONS ***********************************************************/
|
||||
|
||||
#define SECTOR_SIZE (Ext2Sys->DiskGeometry.BytesPerSector)
|
||||
|
@ -224,466 +218,6 @@ typedef struct _EXT2_BDL {
|
|||
bool create_bad_block_inode(PEXT2_FILESYS fs, PEXT2_BADBLK_LIST bb_list);
|
||||
|
||||
|
||||
//
|
||||
// Definitions
|
||||
//
|
||||
|
||||
#define FSCTL_REQUEST_OPLOCK_LEVEL_1 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 0, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_REQUEST_OPLOCK_LEVEL_2 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_REQUEST_BATCH_OPLOCK CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_OPBATCH_ACK_CLOSE_PENDING CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_OPLOCK_BREAK_NOTIFY CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 5, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_LOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_UNLOCK_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_DISMOUNT_VOLUME CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
// decommissioned fsctl value 9
|
||||
#define FSCTL_IS_VOLUME_MOUNTED CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_IS_PATHNAME_VALID CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, FILE_ANY_ACCESS) // PATHNAME_BUFFER,
|
||||
#define FSCTL_MARK_VOLUME_DIRTY CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
// decommissioned fsctl value 13
|
||||
#define FSCTL_QUERY_RETRIEVAL_POINTERS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 14, METHOD_NEITHER, FILE_ANY_ACCESS)
|
||||
#define FSCTL_GET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_SET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
|
||||
// decommissioned fsctl value 17
|
||||
// decommissioned fsctl value 18
|
||||
#define FSCTL_MARK_AS_SYSTEM_HIVE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 19, METHOD_NEITHER, FILE_ANY_ACCESS)
|
||||
#define FSCTL_OPLOCK_BREAK_ACK_NO_2 CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_INVALIDATE_VOLUMES CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_QUERY_FAT_BPB CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, FILE_ANY_ACCESS) // , FSCTL_QUERY_FAT_BPB_BUFFER
|
||||
#define FSCTL_REQUEST_FILTER_OPLOCK CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
#define FSCTL_FILESYSTEM_GET_STATISTICS CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, FILE_ANY_ACCESS) // , FILESYSTEM_STATISTICS
|
||||
|
||||
|
||||
//
|
||||
// Disk I/O Routines
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NtReadFile(HANDLE FileHandle,
|
||||
HANDLE Event OPTIONAL,
|
||||
PIO_APC_ROUTINE ApcRoutine OPTIONAL,
|
||||
PVOID ApcContext OPTIONAL,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
PLARGE_INTEGER ByteOffset OPTIONAL,
|
||||
PULONG Key OPTIONAL);
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NtWriteFile(HANDLE FileHandle,
|
||||
HANDLE Event OPTIONAL,
|
||||
PIO_APC_ROUTINE ApcRoutine OPTIONAL,
|
||||
PVOID ApcContext OPTIONAL,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
PLARGE_INTEGER ByteOffset OPTIONAL,
|
||||
PULONG Key OPTIONAL);
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NtClose(HANDLE Handle);
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NtCreateFile(PHANDLE FileHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PLARGE_INTEGER AllocationSize OPTIONAL,
|
||||
ULONG FileAttributes,
|
||||
ULONG ShareAccess,
|
||||
ULONG CreateDisposition,
|
||||
ULONG CreateOptions,
|
||||
PVOID EaBuffer OPTIONAL,
|
||||
ULONG EaLength);
|
||||
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NtDeviceIoControlFile(
|
||||
IN HANDLE FileHandle,
|
||||
IN HANDLE Event,
|
||||
IN PIO_APC_ROUTINE ApcRoutine,
|
||||
IN PVOID ApcContext,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG IoControlCode,
|
||||
IN PVOID InputBuffer,
|
||||
IN ULONG InputBufferLength,
|
||||
OUT PVOID OutputBuffer,
|
||||
OUT ULONG OutputBufferLength
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NtFsControlFile(
|
||||
IN HANDLE FileHandle,
|
||||
IN HANDLE Event OPTIONAL,
|
||||
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
|
||||
IN PVOID ApcContext OPTIONAL,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG FsControlCode,
|
||||
IN PVOID InputBuffer OPTIONAL,
|
||||
IN ULONG InputBufferLength,
|
||||
OUT PVOID OutputBuffer OPTIONAL,
|
||||
IN ULONG OutputBufferLength
|
||||
);
|
||||
|
||||
|
||||
NTSYSAPI
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
NtQueryInformationFile(
|
||||
IN HANDLE FileHandle,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
OUT PVOID FileInformation,
|
||||
IN ULONG Length,
|
||||
IN FILE_INFORMATION_CLASS FileInformationClass
|
||||
);
|
||||
|
||||
//
|
||||
// Bitmap Routines
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// BitMap routines. The following structure, routines, and macros are
|
||||
// for manipulating bitmaps. The user is responsible for allocating a bitmap
|
||||
// structure (which is really a header) and a buffer (which must be longword
|
||||
// aligned and multiple longwords in size).
|
||||
//
|
||||
|
||||
//
|
||||
// The following routine initializes a new bitmap. It does not alter the
|
||||
// data currently in the bitmap. This routine must be called before
|
||||
// any other bitmap routine/macro.
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
VOID
|
||||
NTAPI
|
||||
RtlInitializeBitMap (
|
||||
PRTL_BITMAP BitMapHeader,
|
||||
PULONG BitMapBuffer,
|
||||
ULONG SizeOfBitMap
|
||||
);
|
||||
|
||||
//
|
||||
// The following two routines either clear or set all of the bits
|
||||
// in a bitmap.
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
VOID
|
||||
NTAPI
|
||||
RtlClearAllBits (
|
||||
PRTL_BITMAP BitMapHeader
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
VOID
|
||||
NTAPI
|
||||
RtlSetAllBits (
|
||||
PRTL_BITMAP BitMapHeader
|
||||
);
|
||||
|
||||
//
|
||||
// The following two routines locate a contiguous region of either
|
||||
// clear or set bits within the bitmap. The region will be at least
|
||||
// as large as the number specified, and the search of the bitmap will
|
||||
// begin at the specified hint index (which is a bit index within the
|
||||
// bitmap, zero based). The return value is the bit index of the located
|
||||
// region (zero based) or -1 (i.e., 0xffffffff) if such a region cannot
|
||||
// be located
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlFindClearBits (
|
||||
PRTL_BITMAP BitMapHeader,
|
||||
ULONG NumberToFind,
|
||||
ULONG HintIndex
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlFindSetBits (
|
||||
PRTL_BITMAP BitMapHeader,
|
||||
ULONG NumberToFind,
|
||||
ULONG HintIndex
|
||||
);
|
||||
|
||||
//
|
||||
// The following two routines locate a contiguous region of either
|
||||
// clear or set bits within the bitmap and either set or clear the bits
|
||||
// within the located region. The region will be as large as the number
|
||||
// specified, and the search for the region will begin at the specified
|
||||
// hint index (which is a bit index within the bitmap, zero based). The
|
||||
// return value is the bit index of the located region (zero based) or
|
||||
// -1 (i.e., 0xffffffff) if such a region cannot be located. If a region
|
||||
// cannot be located then the setting/clearing of the bitmap is not performed.
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlFindClearBitsAndSet (
|
||||
PRTL_BITMAP BitMapHeader,
|
||||
ULONG NumberToFind,
|
||||
ULONG HintIndex
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlFindSetBitsAndClear (
|
||||
PRTL_BITMAP BitMapHeader,
|
||||
ULONG NumberToFind,
|
||||
ULONG HintIndex
|
||||
);
|
||||
|
||||
//
|
||||
// The following two routines clear or set bits within a specified region
|
||||
// of the bitmap. The starting index is zero based.
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
VOID
|
||||
NTAPI
|
||||
RtlClearBits (
|
||||
PRTL_BITMAP BitMapHeader,
|
||||
ULONG StartingIndex,
|
||||
ULONG NumberToClear
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
VOID
|
||||
NTAPI
|
||||
RtlSetBits (
|
||||
PRTL_BITMAP BitMapHeader,
|
||||
ULONG StartingIndex,
|
||||
ULONG NumberToSet
|
||||
);
|
||||
|
||||
//
|
||||
// The following routine locates a set of contiguous regions of clear
|
||||
// bits within the bitmap. The caller specifies whether to return the
|
||||
// longest runs or just the first found lcoated. The following structure is
|
||||
// used to denote a contiguous run of bits. The two routines return an array
|
||||
// of this structure, one for each run located.
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlFindClearRuns (
|
||||
PRTL_BITMAP BitMapHeader,
|
||||
PRTL_BITMAP_RUN RunArray,
|
||||
ULONG SizeOfRunArray,
|
||||
BOOLEAN LocateLongestRuns
|
||||
);
|
||||
//
|
||||
// The following routine locates the longest contiguous region of
|
||||
// clear bits within the bitmap. The returned starting index value
|
||||
// denotes the first contiguous region located satisfying our requirements
|
||||
// The return value is the length (in bits) of the longest region found.
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlFindLongestRunClear (
|
||||
PRTL_BITMAP BitMapHeader,
|
||||
PULONG StartingIndex
|
||||
);
|
||||
|
||||
//
|
||||
// The following routine locates the first contiguous region of
|
||||
// clear bits within the bitmap. The returned starting index value
|
||||
// denotes the first contiguous region located satisfying our requirements
|
||||
// The return value is the length (in bits) of the region found.
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlFindFirstRunClear (
|
||||
PRTL_BITMAP BitMapHeader,
|
||||
PULONG StartingIndex
|
||||
);
|
||||
|
||||
//
|
||||
// The following macro returns the value of the bit stored within the
|
||||
// bitmap at the specified location. If the bit is set a value of 1 is
|
||||
// returned otherwise a value of 0 is returned.
|
||||
//
|
||||
// ULONG
|
||||
// RtlCheckBit (
|
||||
// PRTL_BITMAP BitMapHeader,
|
||||
// ULONG BitPosition
|
||||
// );
|
||||
//
|
||||
//
|
||||
// To implement CheckBit the macro retrieves the longword containing the
|
||||
// bit in question, shifts the longword to get the bit in question into the
|
||||
// low order bit position and masks out all other bits.
|
||||
//
|
||||
|
||||
#define RtlCheckBit(BMH,BP) ((((BMH)->Buffer[(BP) / 32]) >> ((BP) % 32)) & 0x1)
|
||||
|
||||
//
|
||||
// The following two procedures return to the caller the total number of
|
||||
// clear or set bits within the specified bitmap.
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlNumberOfClearBits (
|
||||
PRTL_BITMAP BitMapHeader
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlNumberOfSetBits (
|
||||
PRTL_BITMAP BitMapHeader
|
||||
);
|
||||
|
||||
//
|
||||
// The following two procedures return to the caller a boolean value
|
||||
// indicating if the specified range of bits are all clear or set.
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
RtlAreBitsClear (
|
||||
PRTL_BITMAP BitMapHeader,
|
||||
ULONG StartingIndex,
|
||||
ULONG Length
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
RtlAreBitsSet (
|
||||
PRTL_BITMAP BitMapHeader,
|
||||
ULONG StartingIndex,
|
||||
ULONG Length
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlFindNextForwardRunClear (
|
||||
IN PRTL_BITMAP BitMapHeader,
|
||||
IN ULONG FromIndex,
|
||||
IN PULONG StartingRunIndex
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlFindLastBackwardRunClear (
|
||||
IN PRTL_BITMAP BitMapHeader,
|
||||
IN ULONG FromIndex,
|
||||
IN PULONG StartingRunIndex
|
||||
);
|
||||
|
||||
//
|
||||
// The following two procedures return to the caller a value indicating
|
||||
// the position within a ULONGLONG of the most or least significant non-zero
|
||||
// bit. A value of zero results in a return value of -1.
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
CCHAR
|
||||
NTAPI
|
||||
RtlFindLeastSignificantBit (
|
||||
IN ULONGLONG Set
|
||||
);
|
||||
|
||||
NTSYSAPI
|
||||
CCHAR
|
||||
NTAPI
|
||||
RtlFindMostSignificantBit (
|
||||
IN ULONGLONG Set
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// Random routines ...
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
ULONG
|
||||
NTAPI
|
||||
RtlRandom(
|
||||
IN OUT PULONG Seed
|
||||
);
|
||||
|
||||
//
|
||||
// Time routines ...
|
||||
//
|
||||
|
||||
NTSYSAPI
|
||||
CCHAR
|
||||
NTAPI
|
||||
NtQuerySystemTime(
|
||||
OUT PLARGE_INTEGER CurrentTime
|
||||
);
|
||||
|
||||
|
||||
NTSYSAPI
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
RtlTimeToSecondsSince1970(
|
||||
IN PLARGE_INTEGER Time,
|
||||
OUT PULONG ElapsedSeconds
|
||||
);
|
||||
|
||||
|
||||
NTSYSAPI
|
||||
VOID
|
||||
NTAPI
|
||||
RtlSecondsSince1970ToTime(
|
||||
IN ULONG ElapsedSeconds,
|
||||
OUT PLARGE_INTEGER Time
|
||||
);
|
||||
|
||||
//
|
||||
// Heap routines...
|
||||
//
|
||||
|
||||
#define GetProcessHeap() (NtCurrentTeb()->Peb->ProcessHeap)
|
||||
|
||||
PVOID STDCALL
|
||||
RtlAllocateHeap (
|
||||
HANDLE Heap,
|
||||
ULONG Flags,
|
||||
ULONG Size
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
STDCALL
|
||||
RtlFreeHeap (
|
||||
HANDLE Heap,
|
||||
ULONG Flags,
|
||||
PVOID Address
|
||||
);
|
||||
|
||||
/*
|
||||
* Bitmap.c
|
||||
*/
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
/* INCLUDES **************************************************************/
|
||||
|
||||
#include "Mke2fs.h"
|
||||
#include <debug.h>
|
||||
|
||||
/* DEFINITIONS ***********************************************************/
|
||||
|
||||
|
@ -20,50 +21,49 @@ void ext2_print_super(PEXT2_SUPER_BLOCK pExt2Sb)
|
|||
{
|
||||
int i;
|
||||
|
||||
KdPrint(("\nExt2 Super Block Details ...\n\n"));
|
||||
KdPrint((" Inode Count: %lu\n", pExt2Sb->s_inodes_count));
|
||||
KdPrint((" Block Count: %lu\n", pExt2Sb->s_blocks_count));
|
||||
KdPrint((" Reserved Block Count: %lu\n", pExt2Sb->s_r_blocks_count));
|
||||
KdPrint((" Free Blocks: %lu\n", pExt2Sb->s_free_blocks_count));
|
||||
KdPrint((" Free Inodes: %lu\n", pExt2Sb->s_free_inodes_count));
|
||||
KdPrint((" First Data Block: %lu\n", pExt2Sb->s_first_data_block));
|
||||
KdPrint((" Log Block Size: %lu\n", pExt2Sb->s_log_block_size));
|
||||
KdPrint((" Log Frag Size: %ld\n", pExt2Sb->s_log_frag_size));
|
||||
KdPrint((" Blocks per Group: %lu\n", pExt2Sb->s_blocks_per_group));
|
||||
KdPrint((" Fragments per Group: %lu\n", pExt2Sb->s_frags_per_group));
|
||||
KdPrint((" Inodes per Group: %lu\n", pExt2Sb->s_inodes_per_group));
|
||||
// KdPrint((" Mount Time: %s", ctime((time_t *) & (pExt2Sb->s_mtime))));
|
||||
// KdPrint((" Write Time: %s", ctime((time_t *) & (pExt2Sb->s_wtime))));
|
||||
KdPrint((" Mount Count: %u\n", pExt2Sb->s_mnt_count));
|
||||
KdPrint((" Max Mount Count: %d\n", pExt2Sb->s_max_mnt_count));
|
||||
KdPrint((" Magic Number: %X (%s)\n", pExt2Sb->s_magic,
|
||||
pExt2Sb->s_magic == EXT2_SUPER_MAGIC ? "OK" : "BAD"));
|
||||
KdPrint((" File System State: %X\n", pExt2Sb->s_state));
|
||||
KdPrint((" Error Behaviour: %X\n", pExt2Sb->s_errors));
|
||||
KdPrint((" Minor rev: %u\n", pExt2Sb->s_minor_rev_level));
|
||||
// KdPrint((" Last Check: %s", ctime((time_t *) & (pExt2Sb->s_lastcheck))));
|
||||
KdPrint((" Check Interval: %lu\n", pExt2Sb->s_checkinterval));
|
||||
KdPrint((" Creator OS: %lu\n", pExt2Sb->s_creator_os));
|
||||
KdPrint((" Revision Level: %lu\n", pExt2Sb->s_rev_level));
|
||||
KdPrint((" Reserved Block Default UID: %u\n", pExt2Sb->s_def_resuid));
|
||||
KdPrint((" Reserved Block Default GID: %u\n", pExt2Sb->s_def_resgid));
|
||||
KdPrint((" uuid = "));
|
||||
DPRINT("\nExt2 Super Block Details ...\n\n");
|
||||
DPRINT(" Inode Count: %lu\n", pExt2Sb->s_inodes_count);
|
||||
DPRINT(" Block Count: %lu\n", pExt2Sb->s_blocks_count);
|
||||
DPRINT(" Reserved Block Count: %lu\n", pExt2Sb->s_r_blocks_count);
|
||||
DPRINT(" Free Blocks: %lu\n", pExt2Sb->s_free_blocks_count);
|
||||
DPRINT(" Free Inodes: %lu\n", pExt2Sb->s_free_inodes_count);
|
||||
DPRINT(" First Data Block: %lu\n", pExt2Sb->s_first_data_block);
|
||||
DPRINT(" Log Block Size: %lu\n", pExt2Sb->s_log_block_size);
|
||||
DPRINT(" Log Frag Size: %ld\n", pExt2Sb->s_log_frag_size);
|
||||
DPRINT(" Blocks per Group: %lu\n", pExt2Sb->s_blocks_per_group);
|
||||
DPRINT(" Fragments per Group: %lu\n", pExt2Sb->s_frags_per_group);
|
||||
DPRINT(" Inodes per Group: %lu\n", pExt2Sb->s_inodes_per_group);
|
||||
// DPRINT(" Mount Time: %s", ctime((time_t *) & (pExt2Sb->s_mtime)));
|
||||
// DPRINT(" Write Time: %s", ctime((time_t *) & (pExt2Sb->s_wtime)));
|
||||
DPRINT(" Mount Count: %u\n", pExt2Sb->s_mnt_count);
|
||||
DPRINT(" Max Mount Count: %d\n", pExt2Sb->s_max_mnt_count);
|
||||
DPRINT(" Magic Number: %X (%s)\n", pExt2Sb->s_magic,
|
||||
pExt2Sb->s_magic == EXT2_SUPER_MAGIC ? "OK" : "BAD");
|
||||
DPRINT(" File System State: %X\n", pExt2Sb->s_state);
|
||||
DPRINT(" Error Behaviour: %X\n", pExt2Sb->s_errors);
|
||||
DPRINT(" Minor rev: %u\n", pExt2Sb->s_minor_rev_level);
|
||||
// DPRINT(" Last Check: %s", ctime((time_t *) & (pExt2Sb->s_lastcheck)));
|
||||
DPRINT(" Check Interval: %lu\n", pExt2Sb->s_checkinterval);
|
||||
DPRINT(" Creator OS: %lu\n", pExt2Sb->s_creator_os);
|
||||
DPRINT(" Revision Level: %lu\n", pExt2Sb->s_rev_level);
|
||||
DPRINT(" Reserved Block Default UID: %u\n", pExt2Sb->s_def_resuid);
|
||||
DPRINT(" Reserved Block Default GID: %u\n", pExt2Sb->s_def_resgid);
|
||||
DPRINT(" uuid = ");
|
||||
for (i=0; i < 16; i++)
|
||||
KdPrint(("%x ", pExt2Sb->s_uuid[i]));
|
||||
KdPrint(("\n"));
|
||||
DbgPrint("%x ", pExt2Sb->s_uuid[i]);
|
||||
DbgPrint("\n");
|
||||
|
||||
KdPrint((" volume label name: "));
|
||||
DPRINT(" volume label name: ");
|
||||
for (i=0; i < 16; i++)
|
||||
{
|
||||
if (pExt2Sb->s_volume_name[i] == 0)
|
||||
break;
|
||||
KdPrint(("%c", pExt2Sb->s_volume_name[i]));
|
||||
DbgPrint("%c", pExt2Sb->s_volume_name[i]);
|
||||
}
|
||||
KdPrint(("\n"));
|
||||
DbgPrint("\n");
|
||||
|
||||
KdPrint(("\n\n"));
|
||||
DPRINT("\n\n");
|
||||
}
|
||||
|
||||
|
||||
#define set_field(field, default) if (!pExt2Sb->field) pExt2Sb->field = (default);
|
||||
|
||||
|
|
Loading…
Reference in a new issue