erofs-utils: mkfs: add `-U <clear|random>` support
authorGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 11 Dec 2024 09:27:04 +0000 (17:27 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 11 Dec 2024 10:00:03 +0000 (18:00 +0800)
To match `mke2fs`.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20241211092704.4008111-1-hsiangkao@linux.alibaba.com
man/mkfs.erofs.1
mkfs/main.c

index abdd9b9d3fe0d7d25e5557a2a7f368fac83ec66c..0093839390724058db09ebfbc2efeb6b6a38a689 100644 (file)
@@ -110,6 +110,17 @@ 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".
+The
+.I UUID
+parameter may also be one of the following:
+.RS 1.2i
+.TP
+.I clear
+clear the file system UUID
+.TP
+.I random
+generate a new randomly-generated UUID
+.RE
 .TP
 .B \-\-all-root
 Make all files owned by root.
index d42278716db9a2d469bb9531c3cd420d65e7769a..17b1f46b6a68502b0559437dcec6db919cb8f6e6 100644 (file)
@@ -617,7 +617,12 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
                        has_timestamp = true;
                        break;
                case 'U':
-                       if (erofs_uuid_parse(optarg, fixeduuid)) {
+                       if (!strcmp(optarg, "clear")) {
+                               memset(fixeduuid, 0, 16);
+                       } else if (!strcmp(optarg, "random")) {
+                               valid_fixeduuid = false;
+                               break;
+                       } else if (erofs_uuid_parse(optarg, fixeduuid)) {
                                erofs_err("invalid UUID %s", optarg);
                                return -EINVAL;
                        }