summaryrefslogtreecommitdiffstats
path: root/ocaml
diff options
context:
space:
mode:
Diffstat (limited to 'ocaml')
-rw-r--r--ocaml/guestfs.ml2
-rw-r--r--ocaml/guestfs.mli6
-rw-r--r--ocaml/guestfs_c_actions.c50
3 files changed, 58 insertions, 0 deletions
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml
index 90f3ca8d..d9b652b7 100644
--- a/ocaml/guestfs.ml
+++ b/ocaml/guestfs.ml
@@ -294,3 +294,5 @@ 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"
+external initrd_list : t -> string -> string array = "ocaml_guestfs_initrd_list"
+external mount_loop : t -> string -> string -> unit = "ocaml_guestfs_mount_loop"
diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli
index 39df5045..612d0022 100644
--- a/ocaml/guestfs.mli
+++ b/ocaml/guestfs.mli
@@ -661,3 +661,9 @@ val df_h : t -> string
val du : t -> string -> int64
(** estimate file space usage *)
+val initrd_list : t -> string -> string array
+(** list files in an initrd *)
+
+val mount_loop : t -> string -> string -> unit
+(** mount a file using the loop device *)
+
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c
index a5e18940..8b018f6e 100644
--- a/ocaml/guestfs_c_actions.c
+++ b/ocaml/guestfs_c_actions.c
@@ -4611,3 +4611,53 @@ ocaml_guestfs_du (value gv, value pathv)
CAMLreturn (rv);
}
+CAMLprim value
+ocaml_guestfs_initrd_list (value gv, value pathv)
+{
+ CAMLparam2 (gv, pathv);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("initrd_list: used handle after closing it");
+
+ const char *path = String_val (pathv);
+ int i;
+ char **r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_initrd_list (g, path);
+ caml_leave_blocking_section ();
+ if (r == NULL)
+ ocaml_guestfs_raise_error (g, "initrd_list");
+
+ rv = caml_copy_string_array ((const char **) r);
+ for (i = 0; r[i] != NULL; ++i) free (r[i]);
+ free (r);
+ CAMLreturn (rv);
+}
+
+CAMLprim value
+ocaml_guestfs_mount_loop (value gv, value filev, value mountpointv)
+{
+ CAMLparam3 (gv, filev, mountpointv);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("mount_loop: used handle after closing it");
+
+ const char *file = String_val (filev);
+ const char *mountpoint = String_val (mountpointv);
+ int r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_mount_loop (g, file, mountpoint);
+ caml_leave_blocking_section ();
+ if (r == -1)
+ ocaml_guestfs_raise_error (g, "mount_loop");
+
+ rv = Val_unit;
+ CAMLreturn (rv);
+}
+