linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext2fs: Fix build of new superblock fields on BE machines
@ 2018-11-21  0:11 Gabriel Krisman Bertazi
  2018-11-21 16:24 ` Theodore Y. Ts'o
  2018-11-21 23:19 ` Theodore Y. Ts'o
  0 siblings, 2 replies; 4+ messages in thread
From: Gabriel Krisman Bertazi @ 2018-11-21  0:11 UTC (permalink / raw)
  To: tytso; +Cc: kernel, linux-ext4, Gabriel Krisman Bertazi

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@collabora.com>
---

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-11-22  9:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-21  0:11 [PATCH] ext2fs: Fix build of new superblock fields on BE machines Gabriel Krisman Bertazi
2018-11-21 16:24 ` Theodore Y. Ts'o
2018-11-21 18:27   ` Gabriel Krisman Bertazi
2018-11-21 23:19 ` Theodore Y. Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).