diff options
author | Gao Xiang <hsiangkao@redhat.com> | 2020-10-30 20:30:20 +0800 |
---|---|---|
committer | Gao Xiang <hsiangkao@redhat.com> | 2020-11-01 23:44:29 +0800 |
commit | 1fbd7c8bc4bd02091d8d5785128604f7c9627dbf (patch) | |
tree | 6acc4c4f8d37a4b16f933fd1cdc00945222aa62c | |
parent | 9d90d5a34718a003edcfaceac1b80617fdbb87b0 (diff) |
mkfs: add option to use a pre-defined UUID
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.
Link: https://lore.kernel.org/r/20201030123020.133084-4-hsiangkao@redhat.com
Reviewed-by: Li Guifu <bluce.lee@aliyun.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
-rw-r--r-- | man/mkfs.erofs.1 | 6 | ||||
-rw-r--r-- | mkfs/main.c | 13 |
2 files changed, 18 insertions, 1 deletions
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) { |