[Pkg-libvirt-commits] [libguestfs] 81/233: daemon: Use wipefs_has_force_option to decide whether to add wipefs --force option.

Hilko Bengen bengen at moszumanska.debian.org
Wed Feb 19 21:11:19 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit d0c5450c451acde4357ebcb4a5f9d4a74332a864
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Sun Jan 19 20:28:35 2014 +0000

    daemon: Use wipefs_has_force_option to decide whether to add wipefs --force option.
---
 daemon/zero.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/daemon/zero.c b/daemon/zero.c
index a07989e..ff0ea97 100644
--- a/daemon/zero.c
+++ b/daemon/zero.c
@@ -26,6 +26,8 @@
 #include <unistd.h>
 #include <sys/statvfs.h>
 
+#include "ignore-value.h"
+
 #include "daemon.h"
 #include "actions.h"
 #include "optgroups.h"
@@ -91,7 +93,7 @@ wipefs_has_force_option (void)
   CLEANUP_FREE char *out = NULL, *err = NULL;
 
   if (flag == -1) {
-    r = command (&out, &err, "wipefs", "--help", NULL);
+    r = command (&out, &err, str_wipefs, "--help", NULL);
     if (r == -1) {
       reply_with_error ("%s", err);
       return -1;
@@ -354,15 +356,23 @@ do_zero_free_space (const char *dir)
 void
 wipe_device_before_mkfs (const char *device)
 {
-  int r;
+  int force;
+  const size_t MAX_ARGS = 16;
+  const char *argv[MAX_ARGS];
+  size_t i = 0;
 
-  r = command (NULL, NULL, "wipefs", "-a", "--force", device, NULL);
-  if (r == 0)
+  force = wipefs_has_force_option ();
+  if (force == -1)
     return;
 
-  r = command (NULL, NULL, "wipefs", "-a", device, NULL);
-  if (r == 0)
-    return;
+  ADD_ARG (argv, i, str_wipefs);
+  ADD_ARG (argv, i, "-a");
+  if (force)
+    ADD_ARG (argv, i, "--force");
+  ADD_ARG (argv, i, device);
+  ADD_ARG (argv, i, NULL);
+
+  ignore_value (commandv (NULL, NULL, argv));
 
   /* XXX We could fall back to overwriting bits of disk here, but if
    * they don't have working wipefs, it seems unlikely they are using

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list