Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang <xiang@kernel.org>
To: linux-erofs@lists.ozlabs.org
Cc: Gao Xiang <xiang@kernel.org>, Yifan Zhao <stopire@gmail.com>
Subject: [PATCH] erofs-utils: lib: fix packed pos in erofs_xattr_flush_name_prefixes()
Date: Tue,  3 Nov 2026 13:54:12 +0100	[thread overview]
Message-ID: <20261103125412.12594-1-xiang@kernel.org> (raw)

erofs_os_lseek() usage is no longer valid.

Fixes: bfc94a2580c0 ("erofs-utils: lib: track packed inode position explicitly")
Fixes: e2d8dde04abf ("erofs-utils: add native Windows support")
Reported-by: Yifan Zhao <stopire@gmail.com>
Closes: https://lore.kernel.org/r/6f29b317-9df0-4e96-94c0-e3c3858f41e5@gmail.com
Signed-off-by: Gao Xiang <xiang@kernel.org>
---
 lib/fragments.c          |  4 +++-
 lib/liberofs_fragments.h |  2 +-
 lib/xattr.c              | 11 +++++------
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/fragments.c b/lib/fragments.c
index 61577d2..d4e79b2 100644
--- a/lib/fragments.c
+++ b/lib/fragments.c
@@ -403,8 +403,10 @@ int erofs_flush_packed_inode(struct erofs_importer *im)
 	return 0;
 }
 
-int erofs_packedfile(struct erofs_sb_info *sbi)
+int erofs_packedfile(struct erofs_sb_info *sbi, erofs_off_t **ppos)
 {
+	if (ppos)
+		*ppos = &sbi->packedinode->pos;
 	return sbi->packedinode->fd;
 }
 
diff --git a/lib/liberofs_fragments.h b/lib/liberofs_fragments.h
index cf54936..57fe952 100644
--- a/lib/liberofs_fragments.h
+++ b/lib/liberofs_fragments.h
@@ -20,6 +20,6 @@ int erofs_fragment_pack(struct erofs_inode *inode, void *data,
 			erofs_off_t pos, erofs_off_t len, u32 tofh, bool tail);
 int erofs_fragment_commit(struct erofs_inode *inode, u32 tofh);
 int erofs_flush_packed_inode(struct erofs_importer *im);
-int erofs_packedfile(struct erofs_sb_info *sbi);
+int erofs_packedfile(struct erofs_sb_info *sbi, erofs_off_t **ppos);
 
 #endif
diff --git a/lib/xattr.c b/lib/xattr.c
index 93cfead..c670b12 100644
--- a/lib/xattr.c
+++ b/lib/xattr.c
@@ -885,6 +885,7 @@ int erofs_xattr_flush_name_prefixes(struct erofs_importer *im, bool plain)
 	struct erofs_buffer_head *bh = NULL;
 	struct erofs_vfile _vf;
 	struct ea_type_node *tnode;
+	erofs_off_t *ppos = NULL;
 	s64 start, offset = 0;
 	int err;
 
@@ -897,11 +898,9 @@ int erofs_xattr_flush_name_prefixes(struct erofs_importer *im, bool plain)
 			vf = bmgr->vf;
 		} else if (may_fragments) {
 			erofs_sb_set_fragments(sbi);
-			_vf = (struct erofs_vfile){ .fd = erofs_packedfile(sbi) };
+			_vf = (struct erofs_vfile){ .fd = erofs_packedfile(sbi, &ppos) };
 			vf = &_vf;
-			offset = erofs_os_lseek(vf->fd, 0, SEEK_CUR);
-			if (offset < 0)
-				return -errno;
+			offset = *ppos;
 			bmgr = NULL;
 		} else {
 			plain = true;
@@ -960,8 +959,8 @@ int erofs_xattr_flush_name_prefixes(struct erofs_importer *im, bool plain)
 		erofs_bdrop(bh, false);
 	} else {
 		DBG_BUGON(bmgr);
-		if (erofs_os_lseek(vf->fd, offset, SEEK_SET) < 0)
-			return -errno;
+		if (ppos)
+			*ppos = offset;
 	}
 	erofs_sb_set_xattr_prefixes(sbi);
 	return 0;
-- 
2.50.1 (Apple Git-155)



                 reply	other threads:[~2026-11-03 12:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261103125412.12594-1-xiang@kernel.org \
    --to=xiang@kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=stopire@gmail.com \
    /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