diff options
Diffstat (limited to 'util-linux/mkswap.c')
-rw-r--r-- | util-linux/mkswap.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index 2dee5ac18..7baa3ecfb 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Licensed under GPL version 2, see file LICENSE in this tarball for details. | 6 | * Licensed under GPL version 2, see file LICENSE in this tarball for details. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <busybox.h> | 9 | #include "busybox.h" |
10 | 10 | ||
11 | int mkswap_main(int argc, char *argv[]) | 11 | int mkswap_main(int argc, char *argv[]) |
12 | { | 12 | { |
@@ -16,18 +16,19 @@ int mkswap_main(int argc, char *argv[]) | |||
16 | 16 | ||
17 | // No options supported. | 17 | // No options supported. |
18 | 18 | ||
19 | if (argc!=2) bb_show_usage(); | 19 | if (argc != 2) bb_show_usage(); |
20 | 20 | ||
21 | // Figure out how big the device is and announce our intentions. | 21 | // Figure out how big the device is and announce our intentions. |
22 | 22 | ||
23 | fd = xopen(argv[1],O_RDWR); | 23 | fd = xopen(argv[1], O_RDWR); |
24 | len = fdlength(fd); | 24 | len = fdlength(fd); |
25 | pagesize = getpagesize(); | 25 | pagesize = getpagesize(); |
26 | printf("Setting up swapspace version 1, size = %ld bytes\n", (long)(len-pagesize)); | 26 | printf("Setting up swapspace version 1, size = %"OFF_FMT"d bytes\n", |
27 | len - pagesize); | ||
27 | 28 | ||
28 | // Make a header. | 29 | // Make a header. |
29 | 30 | ||
30 | memset(hdr, 0, 129 * sizeof(unsigned int)); | 31 | memset(hdr, 0, sizeof(hdr)); |
31 | hdr[0] = 1; | 32 | hdr[0] = 1; |
32 | hdr[1] = (len / pagesize) - 1; | 33 | hdr[1] = (len / pagesize) - 1; |
33 | 34 | ||
@@ -35,7 +36,7 @@ int mkswap_main(int argc, char *argv[]) | |||
35 | // signature on disk (not in cache) during swapon. | 36 | // signature on disk (not in cache) during swapon. |
36 | 37 | ||
37 | xlseek(fd, 1024, SEEK_SET); | 38 | xlseek(fd, 1024, SEEK_SET); |
38 | xwrite(fd, hdr, 129 * sizeof(unsigned int)); | 39 | xwrite(fd, hdr, sizeof(hdr)); |
39 | xlseek(fd, pagesize-10, SEEK_SET); | 40 | xlseek(fd, pagesize-10, SEEK_SET); |
40 | xwrite(fd, "SWAPSPACE2", 10); | 41 | xwrite(fd, "SWAPSPACE2", 10); |
41 | fsync(fd); | 42 | fsync(fd); |