[Libguestfs] [PATCH] mkfs: wipefs before we mkfs

Wanlong Gao gaowanlong at cn.fujitsu.com
Thu Feb 16 09:59:24 UTC 2012


we wipe the filesystem signatures from device before do mkfs,
since we can't trust mkfs can remove the filesystem signature absolutely.

Signed-off-by: Wanlong Gao <gaowanlong at cn.fujitsu.com>
---
 daemon/mkfs.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/daemon/mkfs.c b/daemon/mkfs.c
index 5475582..19224ec 100644
--- a/daemon/mkfs.c
+++ b/daemon/mkfs.c
@@ -181,6 +181,15 @@ do_mkfs_opts (const char *fstype, const char *device, int blocksize,
   ADD_ARG (argv, i, device);
   ADD_ARG (argv, i, NULL);
 
+  /* we wipe the filesystem signatures from device before do mkfs,
+   * since we can't trust mkfs can remove the filesystem signature absolutely.
+   */
+  if (do_wipefs (device)) {
+    reply_with_error ("%s: %s: %s", fstype, device, err);
+    free (err);
+    return -1;
+  }
+
   r = commandv (NULL, &err, argv);
   if (r == -1) {
     reply_with_error ("%s: %s: %s", fstype, device, err);
-- 
1.7.9




More information about the Libguestfs mailing list