[git commit master 1/1] mkswap: clear 1st kilobyte. Closes bug 1831
Denys Vlasenko
vda.linux at googlemail.com
Mon Aug 30 23:50:03 UTC 2010
commit: http://git.busybox.net/busybox/commit/?id=4e7dd3c363377aefd6ac60ab4335e773482bcca1
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
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 3f736fa..61a786e 100644
--- a/util-linux/mkswap.c
+++ b/util-linux/mkswap.c
@@ -102,7 +102,15 @@ int mkswap_main(int argc UNUSED_PARAM, char **argv)
printf("Setting up swapspace version 1, size = %"OFF_FMT"u bytes\n", len);
mkswap_selinux_setcontext(fd, argv[0]);
- /* Make a header. hdr is zero-filled so far... */
+ /* hdr is zero-filled so far. Clear the first kbyte, or else
+ * mkswap-ing former FAT partition does NOT erase its signature.
+ *
+ * util-linux-ng 2.17.2 claims to erase it only if it does not see
+ * a partition table and is not run on whole disk. -f forces it.
+ */
+ xwrite(fd, hdr, 1024);
+
+ /* Fill the header. */
hdr->version = 1;
hdr->last_page = (uoff_t)len / pagesize;
@@ -123,7 +131,6 @@ int mkswap_main(int argc UNUSED_PARAM, char **argv)
/* Write the header. Sync to disk because some kernel versions check
* signature on disk (not in cache) during swapon. */
- xlseek(fd, 1024, SEEK_SET);
xwrite(fd, hdr, NWORDS * 4);
xlseek(fd, pagesize - 10, SEEK_SET);
xwrite(fd, SWAPSPACE2, 10);
--
1.7.1
More information about the busybox-cvs
mailing list