From c6fed65e250142fce23b578f545c4686f6667fc5 Mon Sep 17 00:00:00 2001 From: Waldemar Kozaczuk Date: Sun, 17 Mar 2024 20:42:55 -0400 Subject: [PATCH] dir_idx: initialize entry inode before calculating csum Signed-off-by: Waldemar Kozaczuk --- src/ext4_dir_idx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ext4_dir_idx.c b/src/ext4_dir_idx.c index f916cc6..120cb9f 100644 --- a/src/ext4_dir_idx.c +++ b/src/ext4_dir_idx.c @@ -433,6 +433,8 @@ int ext4_dir_dx_init(struct ext4_inode_ref *dir, struct ext4_inode_ref *parent) /* Fill the whole block with empty entry */ struct ext4_dir_en *be = (void *)new_block.data; + ext4_dir_en_set_inode(be, 0); + if (ext4_sb_feature_ro_com(sb, EXT4_FRO_COM_METADATA_CSUM)) { uint16_t len = block_size - sizeof(struct ext4_dir_entry_tail); ext4_dir_en_set_entry_len(be, len); @@ -444,8 +446,6 @@ int ext4_dir_dx_init(struct ext4_inode_ref *dir, struct ext4_inode_ref *parent) ext4_dir_en_set_entry_len(be, block_size); } - ext4_dir_en_set_inode(be, 0); - ext4_trans_set_block_dirty(new_block.buf); rc = ext4_block_set(dir->fs->bdev, &new_block); if (rc != EOK) {