[PATCH v2] erofs-utils: fsck: extract chunk-based file with hole correctly
Yifan Zhao
zhaoyifan at sjtu.edu.cn
Mon Apr 22 21:31:32 AEST 2024
Currently fsck skips file extraction if it finds that EROFS_MAP_MAPPED
is unset, which is not the case for chunk-based files with hole. This
patch handles the corner case correctly.
Signed-off-by: Yifan Zhao <zhaoyifan at sjtu.edu.cn>
---
changelog since v1:
- use lseek instead of write zero to the hole
fsck/main.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/fsck/main.c b/fsck/main.c
index e5c37be..249ccd4 100644
--- a/fsck/main.c
+++ b/fsck/main.c
@@ -470,7 +470,7 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd)
pos += map.m_llen;
/* should skip decomp? */
- if (!(map.m_flags & EROFS_MAP_MAPPED) || !fsckcfg.check_decomp)
+ if (map.m_la >= inode->i_size || !fsckcfg.check_decomp)
continue;
if (map.m_plen > Z_EROFS_PCLUSTER_MAX_SIZE) {
@@ -513,6 +513,15 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd)
} else {
u64 p = 0;
+ if (!(map.m_flags & EROFS_MAP_MAPPED)) {
+ ret = lseek(outfd, map.m_llen, SEEK_CUR);
+ if (ret < 0) {
+ ret = -errno;
+ goto out;
+ }
+ continue;
+ }
+
do {
u64 count = min_t(u64, alloc_rawsize,
map.m_llen);
--
2.44.0
More information about the Linux-erofs
mailing list