mkswap: support -U {clear,random,time,uuid}
Let's follow -U from mkfs.ext4 and make it easy to fully control UUIDs for the swap area. Fixes: https://github.com/karelzak/util-linux/issues/1453 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
10fd91d389
commit
54ef08ed37
|
@ -56,7 +56,16 @@ Use exclusive BSD lock for device or file it operates. The optional argument _mo
|
|||
Specify the page _size_ (in bytes) to use. This option is usually unnecessary; *mkswap* reads the size from the kernel.
|
||||
|
||||
*-U*, *--uuid* _UUID_::
|
||||
Specify the _UUID_ to use. The default is to generate a UUID.
|
||||
Specify the _UUID_ to use. The default is to generate a UUID. The format of the UUID is a series of
|
||||
hex digits separated by hyphens, like this: "c1b9d5a2-f162-11cf-9ece-0020afc76f16". The UUID parameter
|
||||
may also be one of the following:
|
||||
+
|
||||
*clear*;;
|
||||
clear the filesystem UUID
|
||||
*random*;;
|
||||
generate a new randomly-generated UUID
|
||||
*time*;;
|
||||
generate a new time-based UUID
|
||||
|
||||
*-v*, *--swapversion 1*::
|
||||
Specify the swap-space version. (This option is currently pointless, as the old *-v 0* option has become obsolete and now only *-v 1* is supported. The kernel has not supported v0 swap-space format since 2.5.22 (June 2002). The new version v1 is supported since 2.1.117 (August 1998).)
|
||||
|
|
|
@ -172,6 +172,7 @@ static void __attribute__((__noreturn__)) usage(void)
|
|||
|
||||
fprintf(out,
|
||||
_(" --lock[=<mode>] use exclusive device lock (%s, %s or %s)\n"), "yes", "no", "nonblock");
|
||||
|
||||
printf(USAGE_HELP_OPTIONS(27));
|
||||
|
||||
printf(USAGE_MAN_TAIL("mkswap(8)"));
|
||||
|
@ -541,7 +542,13 @@ int main(int argc, char **argv)
|
|||
|
||||
#ifdef HAVE_LIBUUID
|
||||
if(opt_uuid) {
|
||||
if (uuid_parse(opt_uuid, uuid_dat) != 0)
|
||||
if (strcmp(opt_uuid, "clear") == 0)
|
||||
uuid_clear(uuid_dat);
|
||||
else if (strcmp(opt_uuid, "random") == 0)
|
||||
uuid_generate_random(uuid_dat);
|
||||
else if (strcmp(opt_uuid, "time") == 0)
|
||||
uuid_generate_time(uuid_dat);
|
||||
else if (uuid_parse(opt_uuid, uuid_dat) != 0)
|
||||
errx(EXIT_FAILURE, _("error: parsing UUID failed"));
|
||||
} else
|
||||
uuid_generate(uuid_dat);
|
||||
|
|
Loading…
Reference in New Issue