[PATCH] erofs-utils: mkfs: fix the endianness of erofs_super_block

Jingbo Xu jefflexu at linux.alibaba.com
Mon May 22 12:48:48 AEST 2023


Add the missing cpu_to_le[16|32]() conversion when initializing
erofs_super_block.

Fixes: 0a94653c56b2 ("erofs-utils: introduce mkfs support")
Fixes: 116ac0a254fc ("erofs-utils: introduce shared xattr support")
Fixes: a70f35adc1b0 ("erofs-utils: introduce ondisk compression cfgs")
Signed-off-by: Jingbo Xu <jefflexu at linux.alibaba.com>
---
 mkfs/main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mkfs/main.c b/mkfs/main.c
index 61387b3..3ec4903 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -577,8 +577,8 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,
 		.build_time = cpu_to_le64(sbi.build_time),
 		.build_time_nsec = cpu_to_le32(sbi.build_time_nsec),
 		.blocks = 0,
-		.meta_blkaddr  = sbi.meta_blkaddr,
-		.xattr_blkaddr = sbi.xattr_blkaddr,
+		.meta_blkaddr  = cpu_to_le32(sbi.meta_blkaddr),
+		.xattr_blkaddr = cpu_to_le32(sbi.xattr_blkaddr),
 		.xattr_prefix_count = sbi.xattr_prefix_count,
 		.xattr_prefix_start = cpu_to_le32(sbi.xattr_prefix_start),
 		.feature_incompat = cpu_to_le32(sbi.feature_incompat),
@@ -599,7 +599,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,
 	memcpy(sb.volume_name, sbi.volume_name, sizeof(sb.volume_name));
 
 	if (erofs_sb_has_compr_cfgs())
-		sb.u1.available_compr_algs = sbi.available_compr_algs;
+		sb.u1.available_compr_algs = cpu_to_le16(sbi.available_compr_algs);
 	else
 		sb.u1.lz4_max_distance = cpu_to_le16(sbi.lz4_max_distance);
 
-- 
2.19.1.6.gb485710b



More information about the Linux-erofs mailing list