mirror of
https://github.com/bobranten/Ext4Fsd.git
synced 2025-10-30 05:18:31 -05:00
inode checksums is implemented
This commit is contained in:
@@ -505,8 +505,8 @@ BOOLEAN
|
||||
Ext2LoadInode (IN PEXT2_VCB Vcb,
|
||||
IN struct inode *Inode)
|
||||
{
|
||||
struct ext4_inode ext3i = {0};
|
||||
struct ext4_inode_info ei = {0};
|
||||
struct ext4_inode* ext4i;
|
||||
struct ext4_inode_info unused = {0};
|
||||
LONGLONG offset;
|
||||
|
||||
if (!Ext2GetInodeLba(Vcb, Inode->i_ino, &offset)) {
|
||||
@@ -514,16 +514,22 @@ Ext2LoadInode (IN PEXT2_VCB Vcb,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!Ext2LoadBuffer(NULL, Vcb, offset, sizeof(ext3i), &ext3i)) {
|
||||
ext4i = (struct ext4_inode*) Ext2AllocatePool(NonPagedPool, EXT4_INODE_SIZE(Inode->i_sb), EXT2_INODE_MAGIC);
|
||||
if (!ext4i) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Ext2DecodeInode(Inode, &ext3i);
|
||||
|
||||
if (!ext4_inode_csum_verify(Inode, &ext3i, &ei)) {
|
||||
//DbgPrint("inod %d checksum invalid\n", Inode->i_ino);
|
||||
if (!Ext2LoadBuffer(NULL, Vcb, offset, EXT4_INODE_SIZE(Inode->i_sb), ext4i)) {
|
||||
ExFreePool(ext4i);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Ext2DecodeInode(Inode, ext4i);
|
||||
|
||||
ext4_inode_csum_verify(Inode, ext4i, &unused);
|
||||
|
||||
ExFreePool(ext4i);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -555,42 +561,44 @@ Ext2SaveInode ( IN PEXT2_IRP_CONTEXT IrpContext,
|
||||
IN PEXT2_VCB Vcb,
|
||||
IN struct inode *Inode)
|
||||
{
|
||||
struct ext4_inode ext4i = {0};
|
||||
struct ext4_inode_info ei = {0};
|
||||
|
||||
LONGLONG Offset = 0;
|
||||
ULONG InodeSize = sizeof(ext4i);
|
||||
struct ext4_inode* ext4i;
|
||||
struct ext4_inode_info unused = {0};
|
||||
LONGLONG offset;
|
||||
BOOLEAN rc = 0;
|
||||
|
||||
DEBUG(DL_INF, ( "Ext2SaveInode: Saving Inode %xh: Mode=%xh Size=%xh\n",
|
||||
Inode->i_ino, Inode->i_mode, Inode->i_size));
|
||||
rc = Ext2GetInodeLba(Vcb, Inode->i_ino, &Offset);
|
||||
rc = Ext2GetInodeLba(Vcb, Inode->i_ino, &offset);
|
||||
if (!rc) {
|
||||
DEBUG(DL_ERR, ( "Ext2SaveInode: failed inode %u.\n", Inode->i_ino));
|
||||
goto errorout;
|
||||
}
|
||||
|
||||
rc = Ext2LoadBuffer(NULL, Vcb, Offset, InodeSize, &ext4i);
|
||||
ext4i = (struct ext4_inode*) Ext2AllocatePool(NonPagedPool, EXT4_INODE_SIZE(Inode->i_sb), EXT2_INODE_MAGIC);
|
||||
if (!ext4i) {
|
||||
rc = FALSE;
|
||||
goto errorout;
|
||||
}
|
||||
|
||||
rc = Ext2LoadBuffer(NULL, Vcb, offset, EXT4_INODE_SIZE(Inode->i_sb), ext4i);
|
||||
if (!rc) {
|
||||
DEBUG(DL_ERR, ( "Ext2SaveInode: failed reading inode %u.\n", Inode->i_ino));
|
||||
goto errorout;;
|
||||
ExFreePool(ext4i);
|
||||
goto errorout;
|
||||
}
|
||||
|
||||
Ext2EncodeInode(&ext4i, Inode);
|
||||
Ext2EncodeInode(ext4i, Inode);
|
||||
|
||||
ext4_inode_csum_set(Inode, &ext4i, &ei);
|
||||
ext4_inode_csum_set(Inode, ext4i, &unused);
|
||||
|
||||
if (InodeSize > Vcb->InodeSize)
|
||||
{
|
||||
DbgPrint("InodeSize > Vcb->InodeSize\n");
|
||||
InodeSize = Vcb->InodeSize;
|
||||
}
|
||||
rc = Ext2SaveBuffer(IrpContext, Vcb, Offset, InodeSize, &ext4i);
|
||||
rc = Ext2SaveBuffer(IrpContext, Vcb, offset, EXT4_INODE_SIZE(Inode->i_sb), ext4i);
|
||||
|
||||
if (rc && IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK)) {
|
||||
Ext2StartFloppyFlushDpc(Vcb, NULL, NULL);
|
||||
}
|
||||
|
||||
ExFreePool(ext4i);
|
||||
|
||||
errorout:
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ void ext4_inode_csum_set(struct inode *inode, struct ext4_inode *raw,
|
||||
if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE &&
|
||||
offsetof(struct ext4_inode, i_checksum_hi) + sizeof(raw->i_checksum_hi) <= EXT4_GOOD_OLD_INODE_SIZE + raw->i_extra_isize)
|
||||
raw->i_checksum_hi = cpu_to_le16(csum >> 16);
|
||||
DbgPrint("set checksum on inode %u: csum == %lx\n", inode->i_ino, csum);
|
||||
//DbgPrint("set checksum on inode %u: csum == %lx\n", inode->i_ino, csum);
|
||||
ext4_inode_csum_verify(inode, raw, unused);
|
||||
}
|
||||
|
||||
|
||||
@@ -280,6 +280,7 @@ Ext2ClearFlag(PULONG Flags, ULONG FlagBit)
|
||||
#define EXT2_DIRSP_MAGIC 'SD2E'
|
||||
#define EXT2_SB_MAGIC 'BS2E'
|
||||
#define EXT2_GD_MAGIC 'DG2E'
|
||||
#define EXT2_INODE_MAGIC 'EI2E'
|
||||
#define EXT2_FLIST_MAGIC 'LF2E'
|
||||
#define EXT2_PARAM_MAGIC 'PP2E'
|
||||
#define EXT2_RWC_MAGIC 'WR2E'
|
||||
|
||||
@@ -7,8 +7,9 @@ About
|
||||
and Visual Studio 2019. This is work in progress. If you need a stable driver you should get the
|
||||
latest official release from http://www.ext2fsd.com. If you want to try this branch you should
|
||||
still install the oficial release and then copy this driver over the old in \windows\system32\drivers.
|
||||
The current status of the development is that metadata checksums is implemented but there is an
|
||||
calculation error in the inode checksums that must be investigated before I start with jbd2.
|
||||
The current status of the development is that all metadata checksums is implemented. To make a
|
||||
filesystem to test this run mkfs.ext4 with the options -O "metadata_csum,^64bit".
|
||||
This work is dedicated to my mother Berit Ingegerd Branten.
|
||||
Bo Branten.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user