wok-stable view busybox/stuff/busybox-1.12.0-mkswap.u @ rev 5087

phpldapadmin: typo in post_install
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Mar 15 14:58:37 2010 +0100 (2010-03-15)
parents
children
line source
1 Without label, Gparted call mkswap -L '' <device>
2 --- busybox-1.12.0/util-linux/mkswap.c
3 +++ busybox-1.12.0/util-linux/mkswap.c
4 @@ -92,14 +92,14 @@
5 {
6 int fd, pagesize;
7 off_t len;
8 + char *label = NULL;
10 - // No options supported.
11 -
12 - if (argc != 2) bb_show_usage();
13 + getopt32(argv, "L:", &label);
14 + argv += optind;
16 // Figure out how big the device is and announce our intentions.
18 - fd = xopen(argv[1], O_RDWR);
19 + fd = xopen(argv[0], O_RDWR);
20 /* fdlength was reported to be unreliable - use seek */
21 len = xlseek(fd, 0, SEEK_END);
22 #if ENABLE_SELINUX
23 @@ -119,6 +119,12 @@
25 xlseek(fd, 1024, SEEK_SET);
26 xwrite(fd, hdr, NWORDS * 4);
27 + if (label) {
28 + if (strlen(label) > 15)
29 + label[15] = 0;
30 + xlseek(fd, 1024 + 28, SEEK_SET);
31 + xwrite(fd, label, strlen(label));
32 + }
33 xlseek(fd, pagesize - 10, SEEK_SET);
34 xwrite(fd, SWAPSPACE2, 10);
35 fsync(fd);