From: Gabriel Krisman Bertazi Date: Wed, 21 Nov 2018 00:11:27 +0000 (-0500) Subject: ext2fs: add byte swapping of new superblock fields for BE machines X-Git-Tag: v1.45.0~31 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=80c1d01a99a340c4f7bafa9e86971e6633704744;p=tools%2Fe2fsprogs.git ext2fs: add byte swapping of new superblock fields for BE machines New superblock fields must be byte swapped before being accessed in Big Endian machines. Not tested on an actual BE machine. Signed-off-by: Gabriel Krisman Bertazi Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c index b168a2f..a156004 100644 --- a/lib/ext2fs/swapfs.c +++ b/lib/ext2fs/swapfs.c @@ -129,8 +129,11 @@ void ext2fs_swap_super(struct ext2_super_block * sb) sb->s_lpf_ino = ext2fs_swab32(sb->s_lpf_ino); sb->s_prj_quota_inum = ext2fs_swab32(sb->s_prj_quota_inum); sb->s_checksum_seed = ext2fs_swab32(sb->s_checksum_seed); + /* s_*_time_hi are __u8 and does not need swabbing */ + sb->s_encoding = ext2fs_swab16(sb->s_encoding); + sb->s_encoding_flags = ext2fs_swab16(sb->s_encoding_flags); /* catch when new fields are used from s_reserved */ - EXT2FS_BUILD_BUG_ON(sizeof(sb->s_reserved) != 98 * sizeof(__le32)); + EXT2FS_BUILD_BUG_ON(sizeof(sb->s_reserved) != 95 * sizeof(__le32)); sb->s_checksum = ext2fs_swab32(sb->s_checksum); }