Usage: mkfs.erofs -U<uuid> <imagefile> <srcdir> The filesystem UUID can now be optionally specified during filesystem creation. The default behavior is still to generate a random UUID.
This is useful for reproducible builds. Signed-off-by: Gao Xiang <hsiang...@redhat.com> --- man/mkfs.erofs.1 | 6 ++++++ mkfs/main.c | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/man/mkfs.erofs.1 b/man/mkfs.erofs.1 index 891c5a8..dcaf9d7 100644 --- a/man/mkfs.erofs.1 +++ b/man/mkfs.erofs.1 @@ -52,6 +52,12 @@ Forcely generate extended inodes (64-byte inodes) to output. Set all files to the given UNIX timestamp. Reproducible builds requires setting all to a specific one. .TP +.BI "\-U " UUID +Set the universally unique identifier (UUID) of the filesystem to +.IR UUID . +The format of the UUID is a series of hex digits separated by hyphens, +like this: "c1b9d5a2-f162-11cf-9ece-0020afc76f16". +.TP .BI "\-\-exclude-path=" path Ignore file that matches the exact literal path. You may give multiple `--exclude-path' options. diff --git a/mkfs/main.c b/mkfs/main.c index 0e17314..c63b274 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -66,6 +66,9 @@ static void usage(void) " -x# set xattr tolerance to # (< 0, disable xattrs; default 2)\n" " -EX[,...] X=extended options\n" " -T# set a fixed UNIX timestamp # to all files\n" +#ifdef HAVE_LIBUUID + " -UX use a given filesystem UUID\n" +#endif " --exclude-path=X avoid including file X (X = exact literal path)\n" " --exclude-regex=X avoid including files that match X (X = regular expression)\n" #ifdef HAVE_LIBSELINUX @@ -149,7 +152,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) char *endptr; int opt, i; - while((opt = getopt_long(argc, argv, "d:x:z:E:T:", + while((opt = getopt_long(argc, argv, "d:x:z:E:T:U:", long_options, NULL)) != -1) { switch (opt) { case 'z': @@ -200,6 +203,14 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) } cfg.c_timeinherit = TIMESTAMP_FIXED; break; +#ifdef HAVE_LIBUUID + case 'U': + if (uuid_parse(optarg, sbi.uuid)) { + erofs_err("invalid UUID %s", optarg); + return -EINVAL; + } + break; +#endif case 2: opt = erofs_parse_exclude_path(optarg, false); if (opt) { -- 2.18.1