summaryrefslogtreecommitdiffstats
path: root/ocaml
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-05-14 23:47:17 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-05-14 23:47:17 +0100
commitd901cc916102f1aaccfb73396b48aa303e5b8cd7 (patch)
tree7c2fd470088874ab99b5922393327170e653cf01 /ocaml
parent4aa4ecc380edc509aba886417c67d9c39ab51c9a (diff)
downloadlibguestfs-d901cc916102f1aaccfb73396b48aa303e5b8cd7.tar.gz
libguestfs-d901cc916102f1aaccfb73396b48aa303e5b8cd7.tar.xz
libguestfs-d901cc916102f1aaccfb73396b48aa303e5b8cd7.zip
Add support for zerofree command.
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 2544b16b..3886022d 100644
--- a/ocaml/guestfs.ml
+++ b/ocaml/guestfs.ml
@@ -235,3 +235,4 @@ external equal : t -> string -> string -> bool = "ocaml_guestfs_equal"
external strings : t -> string -> string array = "ocaml_guestfs_strings"
external strings_e : t -> string -> string -> string array = "ocaml_guestfs_strings_e"
external hexdump : t -> string -> string = "ocaml_guestfs_hexdump"
+external zerofree : t -> string -> unit = "ocaml_guestfs_zerofree"
diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli
index 870ffb69..3776abe7 100644
--- a/ocaml/guestfs.mli
+++ b/ocaml/guestfs.mli
@@ -484,3 +484,6 @@ val strings_e : t -> string -> string -> string array
val hexdump : t -> string -> string
(** dump a file in hexadecimal *)
+val zerofree : t -> string -> unit
+(** zero unused inodes and disk blocks on ext2/3 filesystem *)
+
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c
index 22e65008..79a5c16f 100644
--- a/ocaml/guestfs_c_actions.c
+++ b/ocaml/guestfs_c_actions.c
@@ -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);
+}
+