Add support for zerofree command.
[libguestfs.git] / ocaml / guestfs_c_actions.c
index 22e6500..79a5c16 100644 (file)
@@ -3178,3 +3178,26 @@ ocaml_guestfs_hexdump (value gv, value pathv)
   CAMLreturn (rv);
 }
 
+CAMLprim value
+ocaml_guestfs_zerofree (value gv, value devicev)
+{
+  CAMLparam2 (gv, devicev);
+  CAMLlocal1 (rv);
+
+  guestfs_h *g = Guestfs_val (gv);
+  if (g == NULL)
+    caml_failwith ("zerofree: used handle after closing it");
+
+  const char *device = String_val (devicev);
+  int r;
+
+  caml_enter_blocking_section ();
+  r = guestfs_zerofree (g, device);
+  caml_leave_blocking_section ();
+  if (r == -1)
+    ocaml_guestfs_raise_error (g, "zerofree");
+
+  rv = Val_unit;
+  CAMLreturn (rv);
+}
+