[PATCH erofs-utils v2 1/2] erofs-utils: fix swapped hi/lo in 48-bit primary blocks read
Zhan Xusheng
zhanxusheng1024 at gmail.com
Sat Apr 4 00:05:45 AEDT 2026
erofs_read_superblock() combines the 48-bit primary device block count as:
(primarydevice_blocks << 32) | blocks_hi
This places blocks_lo in the upper 32 bits and blocks_hi in the lower
16 bits, which is reversed. The correct combination is:
primarydevice_blocks | ((u64)blocks_hi << 32)
This is the same bug that was fixed in the Linux kernel by commit
0b96d9bed324 ("erofs: fix block count report when 48-bit layout is
on"). Apply the equivalent fix to erofs-utils.
Fixes: f5b492b27e53 ("erofs-utils: add 48-bit block addressing support")
Signed-off-by: Zhan Xusheng <zhanxusheng at xiaomi.com>
---
lib/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/super.c b/lib/super.c
index 088c9a0..86d50a1 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -122,8 +122,8 @@ int erofs_read_superblock(struct erofs_sb_info *sbi)
sbi->xattr_prefix_count = dsb->xattr_prefix_count;
if (erofs_sb_has_48bit(sbi) && dsb->rootnid_8b) {
sbi->root_nid = le64_to_cpu(dsb->rootnid_8b);
- sbi->primarydevice_blocks = (sbi->primarydevice_blocks << 32) |
- le16_to_cpu(dsb->rb.blocks_hi);
+ sbi->primarydevice_blocks = sbi->primarydevice_blocks |
+ ((u64)le16_to_cpu(dsb->rb.blocks_hi) << 32);
} else {
sbi->root_nid = le16_to_cpu(dsb->rb.rootnid_2b);
}
--
2.43.0
More information about the Linux-erofs
mailing list