Skip to contentSkip to conversation

erofs-utils: mkfs: add `-U <clear|random>` support

PATCH New Gao Xiang 1 participant 1 message Dec 11, 2024

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: mkfs: add `-U <clear|random>` support

To match mke2fs.

---
 man/mkfs.erofs.1 | 11 +++++++++++
 mkfs/main.c      |  7 ++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
man/mkfs.erofs.1 +11 -0
index e7da588..ee84163 100644
@@ -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.
mkfs/main.c +6 -1
index c92f408..6a5dc66 100644
@@ -620,7 +620,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;
 			}
Signature · 1 line
2.43.5