[PATCH 2/2] erofs-utils: mkfs: validate source and dataimport mode combinations

Gao Xiang xiang at kernel.org
Sat Feb 14 13:47:23 AEDT 2026


Hi Yifan,

On Fri, Feb 13, 2026 at 03:32:41PM +0800, Yifan Zhao wrote:
> This patch adds validation for all combinations of source mode and
> dataimport mode, and prints corresponding error/warning messages.
> It should have no impact on external behavior.
> 
> Signed-off-by: Yifan Zhao <zhaoyifan28 at huawei.com>
> ---
>  mkfs/main.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 131 insertions(+), 13 deletions(-)
> 
> diff --git a/mkfs/main.c b/mkfs/main.c
> index a948b2e..e369347 100644
> --- a/mkfs/main.c
> +++ b/mkfs/main.c
> @@ -169,7 +169,7 @@ static void usage(int argc, char **argv)
>  	}
>  	printf(
>  		" -C#                    specify the size of compress physical cluster in bytes\n"
> -		" -EX[,...]              X=extended options\n"
> +		" -EX[,...]              X=extended options, see mkfs.erofs(1) manual for details\n"
>  		" -L volume-label        set the volume label (maximum 15 bytes)\n"
>  		" -m#[:X]                enable metadata compression (# = physical cluster size in bytes;\n"
>  		"                                                     X = another compression algorithm for metadata)\n"
> @@ -300,6 +300,10 @@ static struct ocierofs_config ocicfg;
>  static bool mkfs_oci_tarindex_mode;
>  
>  enum {
> +	/* XXX: the "DEFAULT" mode is actually source-dependent,
> +	 * meaning BLOB_INDEX for rebuild mode and FULLDATA for others.
> +	 * Consider refactoring this...
> +	 */
>  	EROFS_MKFS_DATA_IMPORT_DEFAULT,
>  	EROFS_MKFS_DATA_IMPORT_FULLDATA,
>  	EROFS_MKFS_DATA_IMPORT_RVSP,
> @@ -314,6 +318,118 @@ static enum {
>  	EROFS_MKFS_SOURCE_REBUILD,
>  } source_mode;
>  
> +static int erofs_mkfs_validate_source_datamode(void)
> +{

Honestly, I don't like a unique place to deal with all arbitrary
combinations, but we could add test cases to test all valid
combinations.

Also I don't think I will treat this for the upcoming
erofs-utils since it may cause potential regression, let's address
this after erofs-utils 1.9 is out.

Thanks,
Gao Xiang


More information about the Linux-erofs mailing list