diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-30 19:28:54 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-30 19:28:54 +0100 |
commit | 62df226f26bd6ac3c481a7790eb89d760d2f0386 (patch) | |
tree | 617a5a436598902b2239d67535925520c20a6e6e /ocaml | |
parent | 2a42bec2c5ee521f29179a5aab713f5a9ca2c3b8 (diff) | |
download | libguestfs-62df226f26bd6ac3c481a7790eb89d760d2f0386.tar.gz libguestfs-62df226f26bd6ac3c481a7790eb89d760d2f0386.tar.xz libguestfs-62df226f26bd6ac3c481a7790eb89d760d2f0386.zip |
Added 'zero' command to wipe partition tables and superblocks.
Diffstat (limited to 'ocaml')
-rw-r--r-- | ocaml/guestfs.ml | 1 | ||||
-rw-r--r-- | ocaml/guestfs.mli | 3 | ||||
-rw-r--r-- | ocaml/guestfs_c_actions.c | 23 |
3 files changed, 27 insertions, 0 deletions
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); +} + |