wok-6.x view busybox/stuff/busybox-1.12.0-mkswap.u @ rev 3210
busybox/su: remove su fix
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu May 28 11:02:39 2009 +0200 (2009-05-28) |
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);