[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#531572: busybox: mkswap should generate UUIDs



Package: busybox
Version: 1:1.13.3-1
Severity: wishlist
Tags: patch
User: ubuntu-devel@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch karmic

Since the rest of the installer is moving to UUIDs by default, busybox
mkswap needs to generate swap areas containing UUIDs in order that they
can be used. I've attached a patch to take care of this. (Yes, printing
the UUID to stdout is intentional, mirroring util-linux's mkswap.) Most
of the necessary code was already there.

Thanks,

-- 
Colin Watson                                       [cjwatson@ubuntu.com]
diff -u busybox-1.13.3/debian/patches/series busybox-1.13.3/debian/patches/series
--- busybox-1.13.3/debian/patches/series
+++ busybox-1.13.3/debian/patches/series
@@ -6,0 +7 @@
+mkswap-uuid.patch
only in patch2:
unchanged:
--- busybox-1.13.3.orig/debian/patches/mkswap-uuid.patch
+++ busybox-1.13.3/debian/patches/mkswap-uuid.patch
@@ -0,0 +1,77 @@
+Description: Set UUIDs on swap areas.
+
+Index: b/e2fsprogs/old_e2fsprogs/uuid/Kbuild
+===================================================================
+--- a/e2fsprogs/old_e2fsprogs/uuid/Kbuild
++++ b/e2fsprogs/old_e2fsprogs/uuid/Kbuild
+@@ -8,6 +8,7 @@
+ 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 \
+Index: b/util-linux/Kbuild
+===================================================================
+--- 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_BLKID)             += blkid.o
+ lib-$(CONFIG_DMESG)             += dmesg.o
+Index: b/util-linux/mkswap.c
+===================================================================
+--- 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 @@
+ #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 @@
+ 	// 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.
+Index: b/Makefile
+===================================================================
+--- a/Makefile
++++ b/Makefile
+@@ -450,6 +450,7 @@
+ 		coreutils/libcoreutils/ \
+ 		debianutils/ \
+ 		e2fsprogs/ \
++		e2fsprogs/old_e2fsprogs/uuid/ \
+ 		editors/ \
+ 		findutils/ \
+ 		init/ \

Reply to: