[PATCH v8 7/8] erofs-utils: mkfs: introduce rebuild mode

Gao Xiang hsiangkao at linux.alibaba.com
Thu Sep 14 17:49:38 AEST 2023



On 2023/9/13 20:03, Jingbo Xu wrote:
> Introduce a new EXPERIMENTAL rebuild mode, which can be used to
> generate a meta-only multidev manifest image with an overlayfs-like
> merged tree from multiple specific EROFS images either of
> 
> tarerofs index mode (--tar=i):
> 
>    mkfs.erofs --tar=i --aufs layer0.erofs layer0.tar
>    ...
>    mkfs.erofs --tar=i --aufs layerN.erofs layerN-1.tar
> 
> or mkfs.erofs uncompressed mode without inline data:
> 
>    mkfs.erofs --tar=f -Enoinline_data --aufs layer0.erofs layer0.tar
>    ...
>    mkfs.erofs --tar=f -Enoinline_data --aufs layerN-1.erofs layerN-1.tar
> 
> To merge these layers, just type:
>    mkfs.erofs merged.erofs layer0.erofs ... layerN-1.erofs
> 
> It doesn't support compression and/or flat inline datalayout yet.
> 
> Signed-off-by: Jingbo Xu <jefflexu at linux.alibaba.com>
> Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>

As Jingbo reported, applying the following diff to fix the device table:

diff --git a/mkfs/main.c b/mkfs/main.c
index 389bb1b..c5dda66 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -590,10 +590,9 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
  
  		if (rebuild_mode) {
  			char *srcpath = cfg.c_src_path;
+			struct erofs_sb_info *src;
  
  			do {
-				struct erofs_sb_info *src;
-
  				src = calloc(1, sizeof(struct erofs_sb_info));
  				if (!src) {
  					erofs_rebuild_cleanup();
@@ -823,7 +822,7 @@ static int erofs_rebuild_load_trees(struct erofs_inode *root)
  	struct erofs_sb_info *src;
  	unsigned int extra_devices = 0;
  	erofs_blk_t nblocks;
-	int ret, i = 0;
+	int ret;
  
  	list_for_each_entry(src, &rebuild_src_list, list) {
  		ret = erofs_rebuild_load_tree(root, src);
@@ -853,7 +852,7 @@ static int erofs_rebuild_load_trees(struct erofs_inode *root)
  			nblocks = src->devs[0].blocks;
  		else
  			nblocks = src->primarydevice_blocks;
-		sbi.devs[i++].blocks = nblocks;
+		sbi.devs[src->dev - 1].blocks = nblocks;
  	}
  	return 0;
  }
-- 
2.19.1.6.gb485710b


More information about the Linux-erofs mailing list