[PATCH] erofs-utils: introduce fsck.erofs

Daeho Jeong daeho43 at gmail.com
Fri Oct 29 04:10:03 AEDT 2021


> > 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,
                                .alg = algorithmformat,
                                .partial_decoding = 0
                                 });


More information about the Linux-erofs mailing list