Many modern Linux installers use UUIDs rather than device names to identify devices. This works better if mkswap sets a UUID.
Signed-off-by: Colin Watson <[email protected]> --- Makefile | 1 + e2fsprogs/old_e2fsprogs/uuid/Kbuild | 1 + util-linux/Kbuild | 2 ++ util-linux/mkswap.c | 13 +++++++++++++ 4 files changed, 17 insertions(+), 0 deletions(-) diff --git a/Makefile b/Makefile index ffa6948..633711a 100644 --- a/Makefile +++ b/Makefile @@ -451,6 +451,7 @@ libs-y := \ coreutils/libcoreutils/ \ debianutils/ \ e2fsprogs/ \ + e2fsprogs/old_e2fsprogs/uuid/ \ editors/ \ findutils/ \ init/ \ diff --git a/e2fsprogs/old_e2fsprogs/uuid/Kbuild b/e2fsprogs/old_e2fsprogs/uuid/Kbuild index dde9818..4117486 100644 --- a/e2fsprogs/old_e2fsprogs/uuid/Kbuild +++ b/e2fsprogs/old_e2fsprogs/uuid/Kbuild @@ -8,6 +8,7 @@ NEEDED-$(CONFIG_E2FSCK) = y NEEDED-$(CONFIG_FSCK) = y NEEDED-$(CONFIG_MKE2FS) = y NEEDED-$(CONFIG_TUNE2FS) = y +NEEDED-$(CONFIG_MKSWAP) = y lib-y:= lib-$(NEEDED-y) += compare.o gen_uuid.o pack.o parse.o unpack.o unparse.o \ diff --git a/util-linux/Kbuild b/util-linux/Kbuild index eaad331..878d9a4 100644 --- a/util-linux/Kbuild +++ b/util-linux/Kbuild @@ -4,6 +4,8 @@ # # Licensed under the GPL v2, see the file LICENSE in this tarball. +CFLAGS_mkswap.o = -I$(srctree)/e2fsprogs/old_e2fsprogs + lib-y:= lib-$(CONFIG_ACPID) += acpid.o lib-$(CONFIG_BLKID) += blkid.o diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index 11c411b..2703a3f 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c @@ -6,6 +6,7 @@ * Licensed under GPL version 2, see file LICENSE in this tarball for details. */ +#include "uuid/uuid.h" #include "libbb.h" #if ENABLE_SELINUX @@ -51,6 +52,17 @@ static void mkswap_selinux_setcontext(int fd, const char *path) #define mkswap_selinux_setcontext(fd, path) ((void)0) #endif +static void mkswap_generate_uuid(void *buf) +{ + uuid_t uuid_dat; + char uuid_string[37]; + + uuid_generate(uuid_dat); + memcpy(buf, uuid_dat, sizeof(uuid_dat)); + uuid_unparse(uuid_dat, uuid_string); + printf("UUID=%s\n", uuid_string); +} + #if 0 /* from Linux 2.6.23 */ /* * Magic header for a swap area. The first part of the union is @@ -113,6 +125,7 @@ int mkswap_main(int argc, char **argv) // Make a header. hdr is zero-filled so far... hdr[0] = 1; hdr[1] = (len / pagesize) - 1; + mkswap_generate_uuid(&hdr[3]); // Write the header. Sync to disk because some kernel versions check // signature on disk (not in cache) during swapon. -- 1.6.3.1 _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
