On Thu, Oct 28, 2021 at 3:20 PM Gao Xiang <[email protected]> wrote: > > On Thu, Oct 28, 2021 at 10:10:03AM -0700, Daeho Jeong wrote: > > > > In fact, I wanted to decompress the whole data here. We can't check > > > > the data integrity, > > > > so I just wanted to check the layout of the file and that is the > > > > reason why I used z_erofs_map_blocks_iter() directly. > > > > > > Yeah, z_erofs_map_blocks_iter() here is good, yet I think we could > > > add a follow-up z_erofs_decompress() as well, at least it can verify > > > obvious compressed data corruption. > > > > Could you enlighten me what is wrong with the below flow? > > z_erofs_decompress fails with -EIO or -EUCLEAN. > > > > raw = malloc(pchunk_len); > > BUG_ON(!raw); > > buffer = malloc(inode->i_size); > > BUG_ON(!buffer); > > > > ret = dev_read(raw, 0, pchunk_len); > > if (ret < 0) { > > erofs_err("an error occurred when reading compressed data " > > "of nid(%llu): errno(%d)", inode->nid | 0ULL, > > ret); > > goto out; > > } > > > > ret = z_erofs_decompress(&(struct z_erofs_decompress_req) { > > .in = raw, > > .out = buffer, > > .decodedskip = 0, > > .inputsize = pchunk_len, > > .decodedlength = inode->i_size, > > I guess try to pass map.m_llen here? since we need to decode pcluster > one-by-one....
Oh, I had to decompress them by cluster, not the whole file. Got it. Thanks, > > Thanks, > Gao Xiang > > > .alg = algorithmformat, > > .partial_decoding = 0 > > });
