Whamcloud - gitweb
libext2fs: add missing swab for superblock, add checks
authorAndreas Dilger <adilger@dilger.ca>
Wed, 13 Dec 2017 23:47:14 +0000 (16:47 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 14 Dec 2017 03:40:40 +0000 (22:40 -0500)
commit75f6ef19a73228fea8e507d6c884b099fb1b7e64
tree2bae8821cc69c53d18cdaa2093664441249304a3
parent07b11a7ba394fec6063f416fe8aa21cf43461098
libext2fs: add missing swab for superblock, add checks

Several recently-added fields in struct ext2_super_block were
not being swabbed in ext2fs_swap_super(), in particular:

   s_raid_stride, s_raid_stripe_width, s_{first,last}_error_*
   s_lpf_ino, s_prj_quota_inum

Add swabbing for these missing fields.  Reorder the swabbing
on other fields so that they are in struct order, and add
comments for fields that do not need swabbing, so it is easier
to see that all fields are being handled.

Since this seems to be a fairly common occurrence, add compile
time checks to ext2fs_swap_super(), ext2fs_swap_inode_large(),
and ext2fs_swap_group_desc2() via a new EXT2FS_BUILD_BUG_ON()
macro to cause a compile warning if fields are used from these
structs without a corresponding change to the swab functions.

Lustre-bug: https://jira.hpdd.intel.com/browse/LU-9309
Reported-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/ext2fsP.h
lib/ext2fs/swapfs.c