From e492608f2f3809a824cb70ee03ff305964b69dd7 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 29 Jun 2009 12:47:20 +0100 Subject: Generated code for 'du' command. --- 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 52bd54c2..90f3ca8d 100644 --- a/ocaml/guestfs.ml +++ b/ocaml/guestfs.ml @@ -293,3 +293,4 @@ external tail : t -> string -> string array = "ocaml_guestfs_tail" external tail_n : t -> int -> string -> string array = "ocaml_guestfs_tail_n" external df : t -> string = "ocaml_guestfs_df" external df_h : t -> string = "ocaml_guestfs_df_h" +external du : t -> string -> int64 = "ocaml_guestfs_du" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli index 390b6b9c..39df5045 100644 --- a/ocaml/guestfs.mli +++ b/ocaml/guestfs.mli @@ -658,3 +658,6 @@ val df : t -> string val df_h : t -> string (** report file system disk space usage (human readable) *) +val du : t -> string -> int64 +(** estimate file space usage *) + diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index 04be8180..a5e18940 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -4588,3 +4588,26 @@ ocaml_guestfs_df_h (value gv) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_du (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("du: used handle after closing it"); + + const char *path = String_val (pathv); + int64_t r; + + caml_enter_blocking_section (); + r = guestfs_du (g, path); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "du"); + + rv = caml_copy_int64 (r); + CAMLreturn (rv); +} + -- cgit