erofs-utils: lib: fix chunk index reads from metabox
PATCH 1/1 erofs-utils: lib: fix chunk index reads from metabox
Chunk indexes stored in metabox are incorrectly read from the primary device, resulting in incorrect file contents.
Assisted-by Codex:gpt-6-astra
Signed-off-by Yifan Zhao <[email protected]>
--- lib/data.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/data.c +6 -6
@@ -72,7 +72,7 @@ int __erofs_map_blocks(struct erofs_inode *inode,struct erofs_sb_info *sbi = inode->sbi;unsigned int unit, blksz =1 << sbi->blkszbits;struct erofs_inode_chunk_index *idx; -u8 buf[EROFS_MAX_BLOCK_SIZE ]; +struct erofs_buf buf = __EROFS_BUF_INITIALIZER;erofs_blk_t startblk, addrmask, nblocks;bool tailpacking;erofs_off_t pos;
@@ -115,11 +115,10 @@ int __erofs_map_blocks(struct erofs_inode *inode, pos =roundup (erofs_iloc (vi) + vi->inode_isize + vi->xattr_isize, unit) + unit * chunknr; - err =erofs_blk_read (sbi,0 , buf,erofs_blknr (sbi, pos),1 ); -if (err <0 ) -return -EIO ; - - idx = (void *)buf +erofs_blkoff (sbi, pos); + idx =erofs_read_metabuf (&buf, sbi, pos, +erofs_inode_in_metabox (vi)); +if (IS_ERR (idx)) +return PTR_ERR (idx); map->m_la = chunknr << vi->u.chunkbits; map->m_llen =min_t (erofs_off_t,1ULL << vi->u.chunkbits,round_up (inode->i_size - map->m_la, blksz));
@@ -141,6 +140,7 @@ int __erofs_map_blocks(struct erofs_inode *inode, map->m_flags =EROFS_MAP_MAPPED ; } } +erofs_put_metabuf (&buf); out:if (!err) { map->m_plen = map->m_llen;
Signature · 1 line
2.55.0