[PATCH] erofs-utils: fsck: extract chunk-based file with hole correctly

Gao Xiang hsiangkao at linux.alibaba.com
Mon Apr 22 20:28:29 AEST 2024



On 2024/4/22 18:05, Yifan Zhao wrote:
> 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>
> ---
>   fsck/main.c | 13 +++++++++----
>   1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/fsck/main.c b/fsck/main.c
> index e5c37be..c10b68e 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) {
> @@ -517,9 +517,14 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd)
>   				u64 count = min_t(u64, alloc_rawsize,
>   						  map.m_llen);
>   
> -				ret = erofs_read_one_data(inode, &map, raw, p, count);
> -				if (ret)
> -					goto out;
> +				if (!(map.m_flags & EROFS_MAP_MAPPED)) {
> +					memset(raw, 0, count);

I think we could use lseek instead of write
zeros explicitly..


Thanks,
Gao Xiang


More information about the Linux-erofs mailing list