From 62df226f26bd6ac3c481a7790eb89d760d2f0386 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Thu, 30 Apr 2009 19:28:54 +0100 Subject: Added 'zero' command to wipe partition tables and superblocks. --- ocaml/guestfs.ml | 1 + ocaml/guestfs.mli | 3 +++ ocaml/guestfs_c_actions.c | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+) (limited to 'ocaml') diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml index 32e2264e..0d60bccf 100644 --- a/ocaml/guestfs.ml +++ b/ocaml/guestfs.ml @@ -220,3 +220,4 @@ external get_e2label : t -> string -> string = "ocaml_guestfs_get_e2label" external set_e2uuid : t -> string -> string -> unit = "ocaml_guestfs_set_e2uuid" external get_e2uuid : t -> string -> string = "ocaml_guestfs_get_e2uuid" external fsck : t -> string -> string -> int = "ocaml_guestfs_fsck" +external zero : t -> string -> unit = "ocaml_guestfs_zero" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli index 2cbd7346..259c8f34 100644 --- a/ocaml/guestfs.mli +++ b/ocaml/guestfs.mli @@ -439,3 +439,6 @@ val get_e2uuid : t -> string -> string val fsck : t -> string -> string -> int (** run the filesystem checker *) +val zero : t -> string -> unit +(** write zeroes to the device *) + diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index 22dc18f9..458d7a70 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -2823,3 +2823,26 @@ ocaml_guestfs_fsck (value gv, value fstypev, value devicev) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_zero (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("zero: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_zero (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "zero"); + + rv = Val_unit; + CAMLreturn (rv); +} + -- cgit