.SH NAME
mkswap \- set up a Linux swap area
.SH SYNOPSIS
-.BI "mkswap [\-c] [\-v" N "] [\-f] [\-p " PSZ "] [\-L " label "] " device " [" size "]"
+.BI "mkswap [\-c] [\-v" N "] [\-f] [\-p " PSZ "] [\-L " label "] [\-U " uuid "] " device " [" size "]"
.SH DESCRIPTION
.B mkswap
sets up a Linux swap area on a device or in a file.
Version 0 (-v0) swap space format is no longer supported in 2.5+ kernels.
+.TP
+.B \-U uuid
+Specify the uuid to use. The default is to generate UUIDs.
+
.SH "SEE ALSO"
.BR fdisk (8),
.BR swapon (8)
static void
usage(void) {
fprintf(stderr,
- _("Usage: %s [-c] [-v0|-v1] [-pPAGESZ] [-L label] /dev/name [blocks]\n"),
+ _("Usage: %s [-c] [-v0|-v1] [-pPAGESZ] [-L label] [-U UUID] /dev/name [blocks]\n"),
program_name);
exit(1);
}
char *opt_label = NULL;
unsigned char *uuid = NULL;
#ifdef HAVE_LIBUUID
+ unsigned char *opt_uuid = NULL;
uuid_t uuid_dat;
#endif
case 'v':
version = atoi(argv[i]+2);
break;
+ case 'U':
+#ifdef HAVE_LIBUUID
+ opt_uuid = argv[i]+2;
+ if (!*opt_uuid && i+1 < argc)
+ opt_uuid = argv[++i];
+#else
+ fprintf(stderr, _("%1$s: warning: ignore -U (UUIDs are unsupported by %1$s)\n"),
+ program_name);
+#endif
+ break;
default:
usage();
}
}
#ifdef HAVE_LIBUUID
- uuid_generate(uuid_dat);
+ if(opt_uuid) {
+ if (uuid_parse(opt_uuid, uuid_dat) != 0)
+ die(_("error: UUID parsing failed"));
+ } else
+ uuid_generate(uuid_dat);
uuid = uuid_dat;
#endif