erofs-utils: fix chunk-based image handling without real data
authorGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 31 Jan 2023 09:48:08 +0000 (17:48 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 31 Jan 2023 09:50:43 +0000 (17:50 +0800)
Otherwise it will report:
 <I> erofs: total metadata: 982 blocks
 <E> erofs:  Could not format the device : [Error 5] Input/output error

Fixes: 03cbf7b8f7f7 ("erofs-utils: mkfs: support chunk-based uncompressed files")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230131094808.67525-1-hsiangkao@linux.alibaba.com
lib/blobchunk.c

index 77b0c174beed2b717bdaf7348134db9553a628b3..2d967006444314c6d6bf2aee76e16465f1210a07 100644 (file)
@@ -237,6 +237,8 @@ int erofs_blob_remap(void)
                erofs_bdrop(bh_devt, false);
                return 0;
        }
+       if (!length)    /* bail out if there is no chunked data */
+               return 0;
        bh = erofs_balloc(DATA, length, 0, 0);
        if (IS_ERR(bh))
                return PTR_ERR(bh);