summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWanlong Gao <gaowanlong@cn.fujitsu.com>2012-02-10 17:10:02 +0800
committerRichard W.M. Jones <rjones@redhat.com>2012-02-10 09:34:13 +0000
commita2b3e0900ee14e5a49d526c24e22edefc3030f99 (patch)
tree99e4877512bb160388f7e6c9b299235002fc0705
parent6ca8a2db6d6f1028a35ece616af44538074483fc (diff)
downloadlibguestfs-a2b3e0900ee14e5a49d526c24e22edefc3030f99.tar.gz
libguestfs-a2b3e0900ee14e5a49d526c24e22edefc3030f99.tar.xz
libguestfs-a2b3e0900ee14e5a49d526c24e22edefc3030f99.zip
NEW API: add a new api wipefs
Add the new api wipefs to erase the filesystem signatures on a device but now erase any data. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
-rw-r--r--TODO2
-rw-r--r--daemon/zero.c24
-rw-r--r--generator/generator_actions.ml16
-rw-r--r--src/MAX_PROC_NR2
4 files changed, 41 insertions, 3 deletions
diff --git a/TODO b/TODO
index 3adb7403..b9a4ee9f 100644
--- a/TODO
+++ b/TODO
@@ -318,8 +318,6 @@ Display the structure of an image file as a PS.
Greater use of blkid / libblkid
-------------------------------
-guestfs_zero should use wipefs. See wipefs(8).
-
There are various useful functions in libblkid for listing partitions,
devices etc which we are essentially duplicating in the daemon. It
would make more sense to just use libblkid for this.
diff --git a/daemon/zero.c b/daemon/zero.c
index 398f8440..00badd23 100644
--- a/daemon/zero.c
+++ b/daemon/zero.c
@@ -73,6 +73,30 @@ do_zero (const char *device)
}
int
+optgroup_wipefs_available (void)
+{
+ return prog_exists ("wipefs");
+}
+
+int
+do_wipefs (const char *device)
+{
+ int r;
+ char *err = NULL;
+
+ const char *wipefs[] = {"wipefs", "-a", device, NULL};
+ r = commandv (NULL, &err, wipefs);
+ if (r == -1) {
+ reply_with_error ("%s", err);
+ free (err);
+ return -1;
+ }
+
+ free (err);
+ return 0;
+}
+
+int
do_zero_device (const char *device)
{
int64_t ssize = do_blockdev_getsize64 (device);
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index f9ba5c39..6119fe18 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -6660,6 +6660,22 @@ List the files in C<directory> in the format of 'ls -laZ'.
This command is mostly useful for interactive sessions. It
is I<not> intended that you try to parse the output string.");
+ ("wipefs", (RErr, [Device "device"], []), 306, [Optional "wipefs"],
+ [InitBasicFSonLVM, Always, TestRun (
+ [["wipefs"; "/dev/VG/LV"]])],
+ "wipe a filesystem signature from a device",
+ "\
+This command erases filesystem or RAID signatures from
+the specified C<device> to make the filesystem invisible to libblkid.
+
+This does not erase the filesystem itself nor any other data from the
+C<device>.
+
+Compare with C<guestfs_zero> which zeroes the first few blocks of a
+device.
+
+=back");
+
]
let all_functions = non_daemon_functions @ daemon_functions
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR
index 67d04b9f..cd307095 100644
--- a/src/MAX_PROC_NR
+++ b/src/MAX_PROC_NR
@@ -1 +1 @@
-305
+306