diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-31 01:50:03 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-08-31 01:50:03 +0200 |
commit | 4e7dd3c363377aefd6ac60ab4335e773482bcca1 (patch) | |
tree | 6b1245a04f63e2be22535da0c9d76a289b677453 | |
parent | c71ec7061637ef490186144e03b8d9a61464d934 (diff) | |
download | busybox-w32-4e7dd3c363377aefd6ac60ab4335e773482bcca1.tar.gz busybox-w32-4e7dd3c363377aefd6ac60ab4335e773482bcca1.tar.bz2 busybox-w32-4e7dd3c363377aefd6ac60ab4335e773482bcca1.zip |
mkswap: clear 1st kilobyte. Closes bug 1831
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | util-linux/mkswap.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index 3f736faba..61a786e92 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c | |||
@@ -102,7 +102,15 @@ int mkswap_main(int argc UNUSED_PARAM, char **argv) | |||
102 | printf("Setting up swapspace version 1, size = %"OFF_FMT"u bytes\n", len); | 102 | printf("Setting up swapspace version 1, size = %"OFF_FMT"u bytes\n", len); |
103 | mkswap_selinux_setcontext(fd, argv[0]); | 103 | mkswap_selinux_setcontext(fd, argv[0]); |
104 | 104 | ||
105 | /* Make a header. hdr is zero-filled so far... */ | 105 | /* hdr is zero-filled so far. Clear the first kbyte, or else |
106 | * mkswap-ing former FAT partition does NOT erase its signature. | ||
107 | * | ||
108 | * util-linux-ng 2.17.2 claims to erase it only if it does not see | ||
109 | * a partition table and is not run on whole disk. -f forces it. | ||
110 | */ | ||
111 | xwrite(fd, hdr, 1024); | ||
112 | |||
113 | /* Fill the header. */ | ||
106 | hdr->version = 1; | 114 | hdr->version = 1; |
107 | hdr->last_page = (uoff_t)len / pagesize; | 115 | hdr->last_page = (uoff_t)len / pagesize; |
108 | 116 | ||
@@ -123,7 +131,6 @@ int mkswap_main(int argc UNUSED_PARAM, char **argv) | |||
123 | 131 | ||
124 | /* Write the header. Sync to disk because some kernel versions check | 132 | /* Write the header. Sync to disk because some kernel versions check |
125 | * signature on disk (not in cache) during swapon. */ | 133 | * signature on disk (not in cache) during swapon. */ |
126 | xlseek(fd, 1024, SEEK_SET); | ||
127 | xwrite(fd, hdr, NWORDS * 4); | 134 | xwrite(fd, hdr, NWORDS * 4); |
128 | xlseek(fd, pagesize - 10, SEEK_SET); | 135 | xlseek(fd, pagesize - 10, SEEK_SET); |
129 | xwrite(fd, SWAPSPACE2, 10); | 136 | xwrite(fd, SWAPSPACE2, 10); |