[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH v3 2/2] virt-format: erase the filesystem signatures before erase partitions



erase the filesystem signatures on each device, then erase
the partitions, avoid to list all the partitions here.

Signed-off-by: Wanlong Gao <gaowanlong cn fujitsu com>
---
 format/format.c |   19 ++++---------------
 1 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/format/format.c b/format/format.c
index b3a47cd..6799fd4 100644
--- a/format/format.c
+++ b/format/format.c
@@ -323,22 +323,11 @@ do_format (void)
 
   /* Erase the disks. */
   if (!wipe) {
-    char **parts;
-
-    /* No wipe, but get rid of LVM metadata by erasing each partition. */
-    parts = guestfs_list_partitions (g);
-    if (parts == NULL)
-      exit (EXIT_FAILURE);
-
-    for (i = 0; parts[i] != NULL; ++i) {
-      if (guestfs_zero (g, parts[i]) == -1)
-        exit (EXIT_FAILURE);
-      free (parts[i]);
-    }
-    free (parts);
-
-    /* Then erase the partition table on each device. */
     for (i = 0; devices[i] != NULL; ++i) {
+      /* erase the filesystem signatures on each device */
+      if (guestfs_wipefs (g, devices[i]) == -1)
+        exit (EXIT_FAILURE);
+      /* Then erase the partition table on each device. */
       if (guestfs_zero (g, devices[i]) == -1)
         exit (EXIT_FAILURE);
     }
-- 
1.7.9


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]