wok rev 2574

busybox/mkswap: gparted needs -L support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Apr 04 09:09:10 2009 +0000 (2009-04-04)
parents 32d8dad532d8
children 14035be80a59
files busybox-pam/receipt busybox/receipt busybox/stuff/busybox-1.12.0-mkswap.u
line diff
     1.1 --- a/busybox-pam/receipt	Wed Apr 01 18:21:58 2009 +0000
     1.2 +++ b/busybox-pam/receipt	Sat Apr 04 09:09:10 2009 +0000
     1.3 @@ -33,6 +33,7 @@
     1.4  modinfo.u
     1.5  modprobe.u
     1.6  paths.u
     1.7 +mkswap.u
     1.8  EOT
     1.9      cp $WOK/busybox/stuff/$SOURCE-$VERSION.config .config
    1.10      sed -i 's/# CONFIG_PAM is not set/CONFIG_PAM=y/' .config
     2.1 --- a/busybox/receipt	Wed Apr 01 18:21:58 2009 +0000
     2.2 +++ b/busybox/receipt	Sat Apr 04 09:09:10 2009 +0000
     2.3 @@ -31,6 +31,7 @@
     2.4  modinfo.u
     2.5  modprobe.u
     2.6  paths.u
     2.7 +mkswap.u
     2.8  EOT
     2.9      cp ../stuff/$PACKAGE-$VERSION.config .config
    2.10      make oldconfig
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/busybox/stuff/busybox-1.12.0-mkswap.u	Sat Apr 04 09:09:10 2009 +0000
     3.3 @@ -0,0 +1,35 @@
     3.4 +Without label, Gparted call mkswap -L '' <device> 
     3.5 +--- busybox-1.12.0/util-linux/mkswap.c
     3.6 ++++ busybox-1.12.0/util-linux/mkswap.c
     3.7 +@@ -92,14 +92,14 @@
     3.8 + {
     3.9 + 	int fd, pagesize;
    3.10 + 	off_t len;
    3.11 ++	char *label = NULL;
    3.12 + 
    3.13 +-	// No options supported.
    3.14 +-
    3.15 +-	if (argc != 2) bb_show_usage();
    3.16 ++	getopt32(argv, "L:", &label);
    3.17 ++	argv += optind;
    3.18 + 
    3.19 + 	// Figure out how big the device is and announce our intentions.
    3.20 + 
    3.21 +-	fd = xopen(argv[1], O_RDWR);
    3.22 ++	fd = xopen(argv[0], O_RDWR);
    3.23 + 	/* fdlength was reported to be unreliable - use seek */
    3.24 + 	len = xlseek(fd, 0, SEEK_END);
    3.25 + #if ENABLE_SELINUX
    3.26 +@@ -119,6 +119,12 @@
    3.27 + 
    3.28 + 	xlseek(fd, 1024, SEEK_SET);
    3.29 + 	xwrite(fd, hdr, NWORDS * 4);
    3.30 ++	if (label) {
    3.31 ++		if (strlen(label) > 15)
    3.32 ++			label[15] = 0;
    3.33 ++		xlseek(fd, 1024 + 28, SEEK_SET);
    3.34 ++		xwrite(fd, label, strlen(label));
    3.35 ++	}
    3.36 + 	xlseek(fd, pagesize - 10, SEEK_SET);
    3.37 + 	xwrite(fd, SWAPSPACE2, 10);
    3.38 + 	fsync(fd);