public inbox for linux-erofs@ozlabs.org
 help / color / mirror / Atom feed
From: Yuezhang Mo <Yuezhang.Mo@sony.com>
To: linux-erofs@lists.ozlabs.org
Cc: Yuezhang Mo <Yuezhang.Mo@sony.com>,
	Friendy Su <friendy.su@sony.com>,
	Daniel Palmer <daniel.palmer@sony.com>
Subject: [PATCH v1] erofs-utils: mkfs: fix fingerprint not set in certain modes
Date: Fri, 10 Apr 2026 14:05:40 +0800	[thread overview]
Message-ID: <20260410060539.417457-2-Yuezhang.Mo@sony.com> (raw)

In certain modes, such as "--tar=f --sort=none", data is written to
the image before fingerprint calculation. In this case, ->datasource
will be set to `EROFS_INODE_DATA_SOURCE_NONE`.

The original `erofs_set_inode_fingerprint()` function only attempts to
read data from a local file or disk buffer; it cannot handle the
`EROFS_INODE_DATA_SOURCE_NONE` case, causing fingerprint setting to be
skipped.

This patch adds handling for the `EROFS_INODE_DATA_SOURCE_NONE` case,
reading data from the image and calculating the fingerprint.

Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Friendy Su <friendy.su@sony.com>
Reviewed-by: Daniel Palmer <daniel.palmer@sony.com>
---
 lib/inode.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/lib/inode.c b/lib/inode.c
index 2cfc6c5..51d5266 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -1975,6 +1975,13 @@ static int erofs_set_inode_fingerprint(struct erofs_inode *inode, int fd,
 
 	if (!ishare_xattr_prefix_id)
 		return 0;
+
+	if (inode->datasource == EROFS_INODE_DATA_SOURCE_NONE) {
+		ret = erofs_iopen(&vf, inode);
+		if (ret)
+			return ret;
+	}
+
 	erofs_sha256_init(&md);
 	do {
 		u8 buf[32768];
@@ -2018,12 +2025,6 @@ static int erofs_mkfs_begin_nondirectory(const struct erofs_mkfs_btctx *btctx,
 			goto out;
 		}
 
-		if (S_ISREG(inode->i_mode) && inode->i_size) {
-			ret = erofs_set_inode_fingerprint(inode, ctx.fd, ctx.fpos);
-			if (ret < 0)
-				return ret;
-		}
-
 		if (inode->sbi->available_compr_algs &&
 		    erofs_file_is_compressible(im, inode)) {
 			ctx.ictx = erofs_prepare_compressed_file(im, inode);
@@ -2037,6 +2038,13 @@ static int erofs_mkfs_begin_nondirectory(const struct erofs_mkfs_btctx *btctx,
 		}
 	}
 out:
+	if (S_ISREG(inode->i_mode) && inode->i_size &&
+	    inode->datasource != EROFS_INODE_DATA_SOURCE_RESVSP) {
+		ret = erofs_set_inode_fingerprint(inode, ctx.fd, ctx.fpos);
+		if (ret < 0)
+			return ret;
+	}
+
 	return erofs_mkfs_go(btctx, EROFS_MKFS_JOB_NDIR, &ctx, sizeof(ctx));
 }
 
-- 
2.43.0



             reply	other threads:[~2026-04-10  6:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10  6:05 Yuezhang Mo [this message]
2026-04-10  6:53 ` [PATCH v1] erofs-utils: mkfs: fix fingerprint not set in certain modes Gao Xiang
2026-04-10  9:00   ` Yuezhang.Mo
2026-04-10  9:03     ` Gao Xiang

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=20260410060539.417457-2-Yuezhang.Mo@sony.com \
    --to=yuezhang.mo@sony.com \
    --cc=daniel.palmer@sony.com \
    --cc=friendy.su@sony.com \
    --cc=linux-erofs@lists.ozlabs.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