[PATCH] ext2fs: Fix build of new superblock fields on BE machines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <krisman@xxxxxxxxxxxxx>
---

I just noticed this today.  I don't see the patch that includes this
field already pushed to kernel.org, so if you want to squash this one to
that patch before pushing to make the result more bisectable in BE
machines, I am ok with that.

 lib/ext2fs/swapfs.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c
index b168a2f20208..a1560045d073 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);
 }
 
-- 
2.19.1




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux