summaryrefslogtreecommitdiffstats
path: root/format/format.c
diff options
context:
space:
mode:
authorWanlong Gao <gaowanlong@cn.fujitsu.com>2012-02-10 17:10:03 +0800
committerRichard W.M. Jones <rjones@redhat.com>2012-02-10 09:34:17 +0000
commit088546af9dd7574ed74d19989b24ddbb2eb122e4 (patch)
treefa753642863596a65ffc3bf12c406fce21f21475 /format/format.c
parenta2b3e0900ee14e5a49d526c24e22edefc3030f99 (diff)
downloadlibguestfs-088546af9dd7574ed74d19989b24ddbb2eb122e4.tar.gz
libguestfs-088546af9dd7574ed74d19989b24ddbb2eb122e4.tar.xz
libguestfs-088546af9dd7574ed74d19989b24ddbb2eb122e4.zip
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>
Diffstat (limited to 'format/format.c')
-rw-r--r--format/format.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/format/format.c b/format/format.c
index b3a47cdf..6799fd43 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);
}