wok annotate busybox/stuff/busybox-1.12.0-mkswap.u @ 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
children
rev   line source
pascal@2574 1 Without label, Gparted call mkswap -L '' <device>
pascal@2574 2 --- busybox-1.12.0/util-linux/mkswap.c
pascal@2574 3 +++ busybox-1.12.0/util-linux/mkswap.c
pascal@2574 4 @@ -92,14 +92,14 @@
pascal@2574 5 {
pascal@2574 6 int fd, pagesize;
pascal@2574 7 off_t len;
pascal@2574 8 + char *label = NULL;
pascal@2574 9
pascal@2574 10 - // No options supported.
pascal@2574 11 -
pascal@2574 12 - if (argc != 2) bb_show_usage();
pascal@2574 13 + getopt32(argv, "L:", &label);
pascal@2574 14 + argv += optind;
pascal@2574 15
pascal@2574 16 // Figure out how big the device is and announce our intentions.
pascal@2574 17
pascal@2574 18 - fd = xopen(argv[1], O_RDWR);
pascal@2574 19 + fd = xopen(argv[0], O_RDWR);
pascal@2574 20 /* fdlength was reported to be unreliable - use seek */
pascal@2574 21 len = xlseek(fd, 0, SEEK_END);
pascal@2574 22 #if ENABLE_SELINUX
pascal@2574 23 @@ -119,6 +119,12 @@
pascal@2574 24
pascal@2574 25 xlseek(fd, 1024, SEEK_SET);
pascal@2574 26 xwrite(fd, hdr, NWORDS * 4);
pascal@2574 27 + if (label) {
pascal@2574 28 + if (strlen(label) > 15)
pascal@2574 29 + label[15] = 0;
pascal@2574 30 + xlseek(fd, 1024 + 28, SEEK_SET);
pascal@2574 31 + xwrite(fd, label, strlen(label));
pascal@2574 32 + }
pascal@2574 33 xlseek(fd, pagesize - 10, SEEK_SET);
pascal@2574 34 xwrite(fd, SWAPSPACE2, 10);
pascal@2574 35 fsync(fd);