diff --git a/dump/main.c b/dump/main.c index 860ee5a2..44f65dab 100644 --- a/dump/main.c +++ b/dump/main.c @@ -359,14 +359,6 @@ static int erofsdump_readdir(struct erofs_dir_context *ctx) return 0; } -static int erofsdump_map_blocks(struct erofs_inode *inode, - struct erofs_map_blocks *map, int flags) -{ - if (erofs_inode_is_data_compressed(inode->datalayout)) - return z_erofs_map_blocks_iter(inode, map, flags); - return erofs_map_blocks(inode, map, flags); -} - static void erofsdump_show_fileinfo(bool show_extent) { const char *ext_fmt[] = { @@ -461,8 +453,7 @@ static void erofsdump_show_fileinfo(bool show_extent) while (map.m_la < inode.i_size) { struct erofs_map_dev mdev; - err = erofsdump_map_blocks(&inode, &map, - EROFS_GET_BLOCKS_FIEMAP); + err = erofs_map_blocks(&inode, &map, EROFS_GET_BLOCKS_FIEMAP); if (err) { erofs_err("failed to get file blocks range"); return; diff --git a/fsck/main.c b/fsck/main.c index f20b767c..f56a8122 100644 --- a/fsck/main.c +++ b/fsck/main.c @@ -527,31 +527,12 @@ static int erofs_verify_inode_data(struct erofs_inode *inode, int outfd) erofs_dbg("verify data chunk of nid(%llu): type(%d)", inode->nid | 0ULL, inode->datalayout); - switch (inode->datalayout) { - case EROFS_INODE_FLAT_PLAIN: - case EROFS_INODE_FLAT_INLINE: - case EROFS_INODE_CHUNK_BASED: - compressed = false; - break; - case EROFS_INODE_COMPRESSED_FULL: - case EROFS_INODE_COMPRESSED_COMPACT: - compressed = true; - break; - default: - erofs_err("unknown datalayout"); - return -EINVAL; - } - + compressed = erofs_inode_is_data_compressed(inode->datalayout); while (pos < inode->i_size) { unsigned int alloc_rawsize; map.m_la = pos; - if (compressed) - ret = z_erofs_map_blocks_iter(inode, &map, - EROFS_GET_BLOCKS_FIEMAP); - else - ret = erofs_map_blocks(inode, &map, - EROFS_GET_BLOCKS_FIEMAP); + ret = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_FIEMAP); if (ret) goto out; diff --git a/lib/data.c b/lib/data.c index f37f8f09..80332081 100644 --- a/lib/data.c +++ b/lib/data.c @@ -62,8 +62,8 @@ static int erofs_map_blocks_flatmode(struct erofs_inode *inode, return err; } -int erofs_map_blocks(struct erofs_inode *inode, - struct erofs_map_blocks *map, int flags) +int __erofs_map_blocks(struct erofs_inode *inode, + struct erofs_map_blocks *map, int flags) { struct erofs_inode *vi = inode; struct erofs_sb_info *sbi = inode->sbi; @@ -132,6 +132,14 @@ int erofs_map_blocks(struct erofs_inode *inode, return err; } +int erofs_map_blocks(struct erofs_inode *inode, + struct erofs_map_blocks *map, int flags) +{ + if (erofs_inode_is_data_compressed(inode->datalayout)) + return z_erofs_map_blocks_iter(inode, map, flags); + return __erofs_map_blocks(inode, map, flags); +} + int erofs_map_dev(struct erofs_sb_info *sbi, struct erofs_map_dev *map) { struct erofs_device_info *dif;