summaryrefslogtreecommitdiffstats
path: root/ocaml
diff options
context:
space:
mode:
authorRichard Jones <rjones@trick.home.annexia.org>2009-06-22 07:49:50 +0100
committerRichard Jones <rjones@trick.home.annexia.org>2009-06-22 07:49:50 +0100
commit4211c7a258debd236017a19c70965bc1b3658edb (patch)
tree50372cfd72f49b84b753e2aa58c92dfc99b4586f /ocaml
parent57d2dfab18ad3d987d9273bb7c1f42e73e0bbcb2 (diff)
downloadlibguestfs-4211c7a258debd236017a19c70965bc1b3658edb.tar.gz
libguestfs-4211c7a258debd236017a19c70965bc1b3658edb.tar.xz
libguestfs-4211c7a258debd236017a19c70965bc1b3658edb.zip
Generated code for 'sh' and 'sh-lines' commands.
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 fb432142..f102459b 100644
--- a/ocaml/guestfs.ml
+++ b/ocaml/guestfs.ml
@@ -277,3 +277,5 @@ external find : t -> string -> string array = "ocaml_guestfs_find"
external e2fsck_f : t -> string -> unit = "ocaml_guestfs_e2fsck_f"
external sleep : t -> int -> unit = "ocaml_guestfs_sleep"
external ntfs_3g_probe : t -> bool -> string -> int = "ocaml_guestfs_ntfs_3g_probe"
+external sh : t -> string -> string = "ocaml_guestfs_sh"
+external sh_lines : t -> string -> string array = "ocaml_guestfs_sh_lines"
diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli
index 859774aa..8983a164 100644
--- a/ocaml/guestfs.mli
+++ b/ocaml/guestfs.mli
@@ -610,3 +610,9 @@ val sleep : t -> int -> unit
val ntfs_3g_probe : t -> bool -> string -> int
(** probe NTFS volume *)
+val sh : t -> string -> string
+(** run a command via the shell *)
+
+val sh_lines : t -> string -> string array
+(** run a command via the shell returning lines *)
+
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c
index 45c9883f..e4dc5099 100644
--- a/ocaml/guestfs_c_actions.c
+++ b/ocaml/guestfs_c_actions.c
@@ -4198,3 +4198,53 @@ ocaml_guestfs_ntfs_3g_probe (value gv, value rwv, value devicev)
CAMLreturn (rv);
}
+CAMLprim value
+ocaml_guestfs_sh (value gv, value commandv)
+{
+ CAMLparam2 (gv, commandv);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("sh: used handle after closing it");
+
+ const char *command = String_val (commandv);
+ char *r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_sh (g, command);
+ caml_leave_blocking_section ();
+ if (r == NULL)
+ ocaml_guestfs_raise_error (g, "sh");
+
+ rv = caml_copy_string (r);
+ free (r);
+ CAMLreturn (rv);
+}
+
+CAMLprim value
+ocaml_guestfs_sh_lines (value gv, value commandv)
+{
+ CAMLparam2 (gv, commandv);
+ CAMLlocal1 (rv);
+
+ guestfs_h *g = Guestfs_val (gv);
+ if (g == NULL)
+ caml_failwith ("sh_lines: used handle after closing it");
+
+ const char *command = String_val (commandv);
+ int i;
+ char **r;
+
+ caml_enter_blocking_section ();
+ r = guestfs_sh_lines (g, command);
+ caml_leave_blocking_section ();
+ if (r == NULL)
+ ocaml_guestfs_raise_error (g, "sh_lines");
+
+ rv = caml_copy_string_array ((const char **) r);
+ for (i = 0; r[i] != NULL; ++i) free (r[i]);
+ free (r);
+ CAMLreturn (rv);
+}
+