Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] erofs-utils: fsck: fix hole handling during extraction
@ 2026-09-17  3:53 Yifan Zhao
  2026-09-17  3:53 ` [PATCH 2/4] erofs-utils: mkfs: validate chunksize before computing chunkbits Yifan Zhao
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yifan Zhao @ 2026-09-17  3:53 UTC (permalink / raw)
  To: linux-erofs; +Cc: xiang, Yifan Zhao

Fix the following two issues in fsck.erofs --extract:

- Trailing holes leave extracted files too short.
- With --xattr-inode-digest, holes are hashed without advancing the
  output offset, so subsequent data is written at an earlier offset.

Assisted-by: Codex:gpt-6-astra
Signed-off-by: Yifan Zhao <stopire@gmail.com>
---
 fsck/main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fsck/main.c b/fsck/main.c
index b2d8f1a..55da9ea 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -569,7 +569,8 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd,
 						(const u8 *)zeros, chunk);
 					remain -= chunk;
 				}
-			} else if (outfd >= 0) {
+			}
+			if (outfd >= 0) {
 				ret = lseek(outfd, map.m_llen, SEEK_CUR);
 				if (ret < 0) {
 					ret = -errno;
@@ -855,6 +856,11 @@ again:
 	}
 
 	ret = erofsfsck_calc_inode_data(inode, fd);
+	if (!ret && ftruncate(fd, inode->i_size)) {
+		ret = -errno;
+		erofs_err("failed to set file size: %s (%s)",
+			  fsckcfg.extract_path, strerror(-ret));
+	}
 	close(fd);
 	return ret;
 }
-- 
2.55.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-17  3:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-17  3:53 [PATCH 1/4] erofs-utils: fsck: fix hole handling during extraction Yifan Zhao
2026-09-17  3:53 ` [PATCH 2/4] erofs-utils: mkfs: validate chunksize before computing chunkbits Yifan Zhao
2026-09-17  3:53 ` [PATCH 3/4] erofs-utils: lib: fix rebuilding empty chunk-based files Yifan Zhao
2026-09-17  3:53 ` [PATCH 4/4] erofs-utils: fsck: avoid truncating lseek() return values Yifan Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox