diff options
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 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); +} + |