From: Gao Xiang Date: Fri, 12 Jul 2024 09:38:08 +0000 (+0800) Subject: erofs-utils: mkfs: fix -U option X-Git-Tag: v1.8~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=72be3dcb053afaf75ae8b48aa4ed7490860a3c3f;p=platform%2Fupstream%2Ferofs-utils.git erofs-utils: mkfs: fix -U option `-U ` option cannot work properly now. Fixes: 7550a30c332c ("erofs-utils: enable incremental builds") Signed-off-by: Gao Xiang Link: https://lore.kernel.org/r/20240712093808.2986196-2-hsiangkao@linux.alibaba.com --- diff --git a/mkfs/main.c b/mkfs/main.c index 117f8e3..20f12fc 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -231,6 +231,8 @@ enum { static unsigned int rebuild_src_count; static LIST_HEAD(rebuild_src_list); +static u8 fixeduuid[16]; +static bool valid_fixeduuid; static int erofs_mkfs_feat_set_legacy_compress(bool en, const char *val, unsigned int vallen) @@ -606,10 +608,11 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) cfg.c_timeinherit = TIMESTAMP_FIXED; break; case 'U': - if (erofs_uuid_parse(optarg, g_sbi.uuid)) { + if (erofs_uuid_parse(optarg, fixeduuid)) { erofs_err("invalid UUID %s", optarg); return -EINVAL; } + valid_fixeduuid = true; break; case 2: opt = erofs_parse_exclude_path(optarg, false); @@ -1255,8 +1258,6 @@ int main(int argc, char **argv) err = PTR_ERR(sb_bh); goto exit; } - /* generate new UUIDs for clean builds */ - erofs_uuid_generate(g_sbi.uuid); } else { union { struct stat st; @@ -1283,6 +1284,12 @@ int main(int argc, char **argv) sb_bh = NULL; } + /* Use the user-defined UUID or generate one for clean builds */ + if (valid_fixeduuid) + memcpy(g_sbi.uuid, fixeduuid, sizeof(g_sbi.uuid)); + else if (!incremental_mode) + erofs_uuid_generate(g_sbi.uuid); + if (tar_mode && !erofstar.index_mode) { err = erofs_diskbuf_init(1); if (err) {