From: Theodore Ts'o Date: Wed, 4 Dec 2024 04:03:13 +0000 (-0500) Subject: e2fsck: fix big-endian support for orphan_file file systems X-Git-Tag: v1.47.2-wc1~134 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=16534ff59444f35625666fc85aa69df3afd707d9;p=tools%2Fe2fsprogs.git e2fsck: fix big-endian support for orphan_file file systems Signed-off-by: Theodore Ts'o --- diff --git a/e2fsck/super.c b/e2fsck/super.c index 04d6dde..d6bbb63 100644 --- a/e2fsck/super.c +++ b/e2fsck/super.c @@ -605,8 +605,9 @@ return_abort: * Update checksum to match expected buffer contents with * appropriate block number. */ - tail->ob_checksum = ext2fs_do_orphan_file_block_csum(fs, - pd->ino, pd->generation, blk, pd->buf); + tail->ob_checksum = + ext2fs_cpu_to_le32(ext2fs_do_orphan_file_block_csum(fs, + pd->ino, pd->generation, blk, pd->buf)); } if (!pd->clear) { pd->errcode = io_channel_read_blk64(fs->io, blk, 1, diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index 586141f..3a5eb73 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -1122,8 +1122,8 @@ static inline unsigned int ext2fs_dir_rec_len(__u8 name_len, /* Structure at the tail of orphan block */ struct ext4_orphan_block_tail { - __u32 ob_magic; - __u32 ob_checksum; + __le32 ob_magic; + __le32 ob_checksum; }; /* diff --git a/lib/ext2fs/orphan.c b/lib/ext2fs/orphan.c index 913eb9a..e256fd2 100644 --- a/lib/ext2fs/orphan.c +++ b/lib/ext2fs/orphan.c @@ -58,7 +58,7 @@ __u32 ext2fs_do_orphan_file_block_csum(ext2_filsys fs, ext2_ino_t ino, crc = ext2fs_crc32c_le(crc, (unsigned char *)buf, inodes_per_ob * sizeof(__u32)); - return ext2fs_cpu_to_le32(crc); + return crc; } struct mkorphan_info { @@ -101,8 +101,9 @@ static int mkorphan_proc(ext2_filsys fs, struct ext4_orphan_block_tail *tail; tail = ext2fs_orphan_block_tail(fs, oi->buf); - tail->ob_checksum = ext2fs_do_orphan_file_block_csum(fs, - oi->ino, oi->generation, new_blk, oi->buf); + tail->ob_checksum = + ext2fs_cpu_to_le32(ext2fs_do_orphan_file_block_csum(fs, + oi->ino, oi->generation, new_blk, oi->buf)); } err = io_channel_write_blk64(fs->io, new_blk, 1, oi->buf); } else /* zerobuf is used to initialize new indirect blocks... */ @@ -249,13 +250,14 @@ errcode_t ext2fs_orphan_file_block_csum_set(ext2_filsys fs, ext2_ino_t ino, blk64_t blk, char *buf) { struct ext4_orphan_block_tail *tail; + __u32 crc; if (!ext2fs_has_feature_metadata_csum(fs->super)) return 0; tail = ext2fs_orphan_block_tail(fs, buf); - return ext2fs_orphan_file_block_csum(fs, ino, blk, buf, - &tail->ob_checksum); + return ext2fs_orphan_file_block_csum(fs, ino, blk, buf, &crc); + tail->ob_checksum = ext2fs_cpu_to_le32(crc); } int ext2fs_orphan_file_block_csum_verify(ext2_filsys fs, ext2_ino_t ino,