Whamcloud - gitweb
e2fsck: fix big-endian support for orphan_file file systems
authorTheodore Ts'o <tytso@mit.edu>
Wed, 4 Dec 2024 04:03:13 +0000 (23:03 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 4 Dec 2024 04:03:13 +0000 (23:03 -0500)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/super.c
lib/ext2fs/ext2_fs.h
lib/ext2fs/orphan.c

index 04d6dde..d6bbb63 100644 (file)
@@ -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,
index 586141f..3a5eb73 100644 (file)
@@ -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;
 };
 
 /*
index 913eb9a..e256fd2 100644 (file)
@@ -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,