From: Yifan Zhao <stopire@gmail.com>
To: linux-erofs@lists.ozlabs.org, xiang@kernel.org
Cc: stopire@gmail.com
Subject: [PATCH v2] erofs-utils: fix incorrect field conversions
Date: Fri, 28 Aug 2026 16:29:30 +0800 [thread overview]
Message-ID: <20260828082930.1626829-1-stopire@gmail.com> (raw)
In-Reply-To: <20260827020629.1305900-1-stopire@gmail.com>
Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: Yifan Zhao <stopire@gmail.com>
Link: https://patch.msgid.link/20260827020629.1305900-1-stopire@gmail.com
Signed-off-by: Gao Xiang <xiang@kernel.org>
---
Changes since v1:
- v2 only adds the missing cpu_to_le16() conversion for the 16-bit
startblk_hi field in lib/blobchunk.c.
dump/main.c | 4 ++--
lib/blobchunk.c | 2 +-
lib/compress.c | 4 ++--
lib/gzran.c | 4 ++--
lib/inode.c | 2 +-
lib/namei.c | 2 +-
lib/super.c | 2 +-
7 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/dump/main.c b/dump/main.c
index 9eebcb8..28f104b 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -694,7 +694,7 @@ static void erofsdump_show_superblock(void)
for (i = 0; i < ARRAY_SIZE(feature_lists); i++) {
if (!feature_lists[i].compat)
continue;
- if (le32_to_cpu(g_sbi.feature_compat) & feature_lists[i].flag) {
+ if (g_sbi.feature_compat & feature_lists[i].flag) {
fprintf(stdout, "%s ", feature_lists[i].name);
if (feature_lists[i].lkver > minkver)
minkver = feature_lists[i].lkver;
@@ -704,7 +704,7 @@ static void erofsdump_show_superblock(void)
for (i = 0; i < ARRAY_SIZE(feature_lists); i++) {
if (feature_lists[i].compat)
continue;
- if (le32_to_cpu(g_sbi.feature_incompat) & feature_lists[i].flag) {
+ if (g_sbi.feature_incompat & feature_lists[i].flag) {
fprintf(stdout, "%s ", feature_lists[i].name);
if (feature_lists[i].lkver > minkver)
minkver = feature_lists[i].lkver;
diff --git a/lib/blobchunk.c b/lib/blobchunk.c
index d307a4f..f969cf2 100644
--- a/lib/blobchunk.c
+++ b/lib/blobchunk.c
@@ -245,7 +245,7 @@ int erofs_write_chunk_indexes(struct erofs_inode *inode, struct erofs_vfile *vf,
startblk &= addrmask;
idx.device_id = cpu_to_le16(chunk->device_id);
idx.startblk_lo = cpu_to_le32(startblk);
- idx.startblk_hi = cpu_to_le32(startblk >> 32);
+ idx.startblk_hi = cpu_to_le16(startblk >> 32);
DBG_BUGON(!_48bit && idx.startblk_hi);
if (unit == EROFS_BLOCK_MAP_ENTRY_SIZE)
diff --git a/lib/compress.c b/lib/compress.c
index 9262afa..9bbb127 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -2153,9 +2153,9 @@ static int z_erofs_build_compr_cfgs(struct erofs_importer *im,
} __packed zalg = {
.size = cpu_to_le16(sizeof(struct z_erofs_deflate_cfgs)),
.z = {
- .windowbits = cpu_to_le32(ilog2(
+ .windowbits = ilog2(
max_dict_size
- [Z_EROFS_COMPRESSION_DEFLATE])),
+ [Z_EROFS_COMPRESSION_DEFLATE]),
}
};
diff --git a/lib/gzran.c b/lib/gzran.c
index 3973c1f..a75756c 100644
--- a/lib/gzran.c
+++ b/lib/gzran.c
@@ -208,7 +208,7 @@ struct erofs_gzran_iostream {
struct erofs_vfile *vin;
struct erofs_gzran_cutpoint *cp;
u32 entries;
- u32 span_size;
+ u64 span_size;
};
static void erofs_gzran_ios_vfclose(struct erofs_vfile *vf)
@@ -346,7 +346,7 @@ struct erofs_vfile *erofs_gzran_zinfo_open(struct erofs_vfile *vin,
ios = (struct erofs_gzran_iostream *)vf->payload;
h = zinfo_buf;
ios->entries = le32_to_cpu(h->have);
- ios->span_size = le32_to_cpu(h->span_size);
+ ios->span_size = le64_to_cpu(h->span_size);
v2_size = sizeof(*c) * ios->entries + sizeof(*h);
if (!len || v2_size == len) {
diff --git a/lib/inode.c b/lib/inode.c
index 0547b60..a69439c 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -851,7 +851,7 @@ int erofs_iflush(struct erofs_inode *inode)
u.dic.i_uid = cpu_to_le16((u16)inode->i_uid);
u.dic.i_gid = cpu_to_le16((u16)inode->i_gid);
- u.dic.i_mtime = cpu_to_le64(inode->i_mtime - sbi->epoch);
+ u.dic.i_mtime = cpu_to_le32(inode->i_mtime - sbi->epoch);
u.dic.i_u = u1;
if (nlink_1) {
diff --git a/lib/namei.c b/lib/namei.c
index f19e4b1..9d04693 100644
--- a/lib/namei.c
+++ b/lib/namei.c
@@ -96,7 +96,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
vi->i_nlink = le32_to_cpu(die->i_nlink);
vi->i_mtime = le64_to_cpu(die->i_mtime);
- vi->i_mtime_nsec = le64_to_cpu(die->i_mtime_nsec);
+ vi->i_mtime_nsec = le32_to_cpu(die->i_mtime_nsec);
vi->i_size = le64_to_cpu(die->i_size);
break;
case EROFS_INODE_LAYOUT_COMPACT:
diff --git a/lib/super.c b/lib/super.c
index 25116fe..98e1711 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -222,7 +222,7 @@ int erofs_writesb(struct erofs_sb_info *sbi)
.rb.rootnid_2b = cpu_to_le16(sbi->root_nid),
.inos = cpu_to_le64(sbi->inos),
.epoch = cpu_to_le64(sbi->epoch),
- .build_time = cpu_to_le64(sbi->build_time),
+ .build_time = cpu_to_le32(sbi->build_time),
.fixed_nsec = cpu_to_le32(sbi->fixed_nsec),
.meta_blkaddr = cpu_to_le32(sbi->meta_blkaddr),
.xattr_blkaddr = cpu_to_le32(sbi->xattr_blkaddr),
--
2.55.0
prev parent reply other threads:[~2026-08-28 8:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 2:06 [PATCH] erofs-utils: fix incorrect field conversions Yifan Zhao
2026-08-28 8:29 ` Yifan Zhao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260828082930.1626829-1-stopire@gmail.com \
--to=stopire@gmail.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=xiang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox