From: Yue Hu <[email protected]> Diretly call {z_}erofs_read_one_data() to avoid duplicated code. Accordingly, fragment and partial-referenced plusters are also supported after this change.
Signed-off-by: Yue Hu <[email protected]> --- fsck/main.c | 56 ++++++++++------------------------------------------- 1 file changed, 10 insertions(+), 46 deletions(-) diff --git a/fsck/main.c b/fsck/main.c index 2a9c501..a01ca76 100644 --- a/fsck/main.c +++ b/fsck/main.c @@ -366,7 +366,6 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd) struct erofs_map_blocks map = { .index = UINT_MAX, }; - struct erofs_map_dev mdev; int ret = 0; bool compressed; erofs_off_t pos = 0; @@ -427,54 +426,19 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd) BUG_ON(!raw); } - mdev = (struct erofs_map_dev) { - .m_deviceid = map.m_deviceid, - .m_pa = map.m_pa, - }; - ret = erofs_map_dev(&sbi, &mdev); - if (ret) { - erofs_err("failed to map device of m_pa %" PRIu64 ", m_deviceid %u @ nid %llu: %d", - map.m_pa, map.m_deviceid, inode->nid | 0ULL, - ret); - goto out; - } - - if (compressed && map.m_llen > buffer_size) { - buffer_size = map.m_llen; - buffer = realloc(buffer, buffer_size); - BUG_ON(!buffer); - } - - ret = dev_read(mdev.m_deviceid, raw, mdev.m_pa, map.m_plen); - if (ret < 0) { - erofs_err("failed to read data of m_pa %" PRIu64 ", m_plen %" PRIu64 " @ nid %llu: %d", - mdev.m_pa, map.m_plen, inode->nid | 0ULL, - ret); - goto out; - } - if (compressed) { - struct z_erofs_decompress_req rq = { - .in = raw, - .out = buffer, - .decodedskip = 0, - .interlaced_offset = - map.m_algorithmformat == Z_EROFS_COMPRESSION_INTERLACED ? - erofs_blkoff(map.m_la) : 0, - .inputsize = map.m_plen, - .decodedlength = map.m_llen, - .alg = map.m_algorithmformat, - .partial_decoding = 0 - }; - - ret = z_erofs_decompress(&rq); - if (ret < 0) { - erofs_err("failed to decompress data of m_pa %" PRIu64 ", m_plen %" PRIu64 " @ nid %llu: %s", - mdev.m_pa, map.m_plen, - inode->nid | 0ULL, strerror(-ret)); - goto out; + if (map.m_llen > buffer_size) { + buffer_size = map.m_llen; + buffer = realloc(buffer, buffer_size); + BUG_ON(!buffer); } + ret = z_erofs_read_one_data(inode, &map, raw, buffer, + 0, map.m_llen, false); + } else { + ret = erofs_read_one_data(&map, raw, 0, map.m_plen); } + if (ret) + goto out; if (outfd >= 0 && write(outfd, compressed ? buffer : raw, map.m_llen) < 0) { -- 2.17.1
