summaryrefslogtreecommitdiffstats
path: root/ocaml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml')
-rw-r--r--ocaml/guestfs.ml1
-rw-r--r--ocaml/guestfs.mli3
-rw-r--r--ocaml/guestfs_c_actions.c23
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);
+}
+