Correct the path to /sbin/fsck.
[libguestfs.git] / daemon / lvm.c
index 55b41f0..326b583 100644 (file)
@@ -197,6 +197,10 @@ do_vgcreate (const char *volgroup, char * const* const physvols)
 
   argc = count_strings (physvols) + 3;
   argv = malloc (sizeof (char *) * (argc + 1));
+  if (argv == NULL) {
+    reply_with_perror ("malloc");
+    return -1;
+  }
   argv[0] = "/sbin/lvm";
   argv[1] = "vgcreate";
   argv[2] = volgroup;
@@ -300,3 +304,57 @@ do_lvm_remove_all (void)
   /* There, that was easy, sorry about your data. */
   return 0;
 }
+
+int
+do_lvremove (const char *device)
+{
+  char *err;
+  int r;
+
+  r = command (NULL, &err,
+              "/sbin/lvm", "lvremove", "-f", device, NULL);
+  if (r == -1) {
+    reply_with_error ("%s", err);
+    free (err);
+    return -1;
+  }
+
+  free (err);
+  return 0;
+}
+
+int
+do_vgremove (const char *device)
+{
+  char *err;
+  int r;
+
+  r = command (NULL, &err,
+              "/sbin/lvm", "vgremove", "-f", device, NULL);
+  if (r == -1) {
+    reply_with_error ("%s", err);
+    free (err);
+    return -1;
+  }
+
+  free (err);
+  return 0;
+}
+
+int
+do_pvremove (const char *device)
+{
+  char *err;
+  int r;
+
+  r = command (NULL, &err,
+              "/sbin/lvm", "pvremove", "-ff", device, NULL);
+  if (r == -1) {
+    reply_with_error ("%s", err);
+    free (err);
+    return -1;
+  }
+
+  free (err);
+  return 0;
+}