1
0
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:
Bo Brantén
2020-02-07 00:40:00 +01:00
parent 11149fa115
commit 89892ad2f3
4 changed files with 38 additions and 28 deletions

View File

@@ -505,25 +505,31 @@ BOOLEAN
Ext2LoadInode (IN PEXT2_VCB Vcb, Ext2LoadInode (IN PEXT2_VCB Vcb,
IN struct inode *Inode) IN struct inode *Inode)
{ {
struct ext4_inode ext3i = {0}; struct ext4_inode* ext4i;
struct ext4_inode_info ei = {0}; struct ext4_inode_info unused = {0};
LONGLONG offset; LONGLONG offset;
if (!Ext2GetInodeLba(Vcb, Inode->i_ino, &offset)) { if (!Ext2GetInodeLba(Vcb, Inode->i_ino, &offset)) {
DEBUG(DL_ERR, ("Ext2LoadInode: failed inode %u.\n", Inode->i_ino)); DEBUG(DL_ERR, ("Ext2LoadInode: failed inode %u.\n", Inode->i_ino));
return FALSE; 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; return FALSE;
} }
Ext2DecodeInode(Inode, &ext3i); if (!Ext2LoadBuffer(NULL, Vcb, offset, EXT4_INODE_SIZE(Inode->i_sb), ext4i)) {
ExFreePool(ext4i);
if (!ext4_inode_csum_verify(Inode, &ext3i, &ei)) { return FALSE;
//DbgPrint("inod %d checksum invalid\n", Inode->i_ino);
} }
Ext2DecodeInode(Inode, ext4i);
ext4_inode_csum_verify(Inode, ext4i, &unused);
ExFreePool(ext4i);
return TRUE; return TRUE;
} }
@@ -555,42 +561,44 @@ Ext2SaveInode ( IN PEXT2_IRP_CONTEXT IrpContext,
IN PEXT2_VCB Vcb, IN PEXT2_VCB Vcb,
IN struct inode *Inode) IN struct inode *Inode)
{ {
struct ext4_inode ext4i = {0}; struct ext4_inode* ext4i;
struct ext4_inode_info ei = {0}; struct ext4_inode_info unused = {0};
LONGLONG offset;
LONGLONG Offset = 0; BOOLEAN rc = 0;
ULONG InodeSize = sizeof(ext4i);
BOOLEAN rc = 0;
DEBUG(DL_INF, ( "Ext2SaveInode: Saving Inode %xh: Mode=%xh Size=%xh\n", DEBUG(DL_INF, ( "Ext2SaveInode: Saving Inode %xh: Mode=%xh Size=%xh\n",
Inode->i_ino, Inode->i_mode, Inode->i_size)); 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) { if (!rc) {
DEBUG(DL_ERR, ( "Ext2SaveInode: failed inode %u.\n", Inode->i_ino)); DEBUG(DL_ERR, ( "Ext2SaveInode: failed inode %u.\n", Inode->i_ino));
goto errorout; 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) { if (!rc) {
DEBUG(DL_ERR, ( "Ext2SaveInode: failed reading inode %u.\n", Inode->i_ino)); 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) rc = Ext2SaveBuffer(IrpContext, Vcb, offset, EXT4_INODE_SIZE(Inode->i_sb), ext4i);
{
DbgPrint("InodeSize > Vcb->InodeSize\n");
InodeSize = Vcb->InodeSize;
}
rc = Ext2SaveBuffer(IrpContext, Vcb, Offset, InodeSize, &ext4i);
if (rc && IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK)) { if (rc && IsFlagOn(Vcb->Flags, VCB_FLOPPY_DISK)) {
Ext2StartFloppyFlushDpc(Vcb, NULL, NULL); Ext2StartFloppyFlushDpc(Vcb, NULL, NULL);
} }
ExFreePool(ext4i);
errorout: errorout:
return rc; return rc;
} }

View File

@@ -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 && 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) 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); 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); ext4_inode_csum_verify(inode, raw, unused);
} }

View File

@@ -280,6 +280,7 @@ Ext2ClearFlag(PULONG Flags, ULONG FlagBit)
#define EXT2_DIRSP_MAGIC 'SD2E' #define EXT2_DIRSP_MAGIC 'SD2E'
#define EXT2_SB_MAGIC 'BS2E' #define EXT2_SB_MAGIC 'BS2E'
#define EXT2_GD_MAGIC 'DG2E' #define EXT2_GD_MAGIC 'DG2E'
#define EXT2_INODE_MAGIC 'EI2E'
#define EXT2_FLIST_MAGIC 'LF2E' #define EXT2_FLIST_MAGIC 'LF2E'
#define EXT2_PARAM_MAGIC 'PP2E' #define EXT2_PARAM_MAGIC 'PP2E'
#define EXT2_RWC_MAGIC 'WR2E' #define EXT2_RWC_MAGIC 'WR2E'

View File

@@ -7,8 +7,9 @@ About
and Visual Studio 2019. This is work in progress. If you need a stable driver you should get the 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 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. 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 The current status of the development is that all metadata checksums is implemented. To make a
calculation error in the inode checksums that must be investigated before I start with jbd2. 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. Bo Branten.