X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=ocaml%2Fguestfs_c_actions.c;h=e4dc509990708543c88788fc856d25d4f8fb52dc;hp=615d209ecce22ab7595123b1fda9b96867a5bc39;hb=4211c7a258debd236017a19c70965bc1b3658edb;hpb=b6adf09c4d2cc3f1d0285950c151b1fd7688ec67 diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index 615d209..e4dc509 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -4174,3 +4174,77 @@ ocaml_guestfs_sleep (value gv, value secsv) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_ntfs_3g_probe (value gv, value rwv, value devicev) +{ + CAMLparam3 (gv, rwv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("ntfs_3g_probe: used handle after closing it"); + + int rw = Bool_val (rwv); + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_ntfs_3g_probe (g, rw, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "ntfs_3g_probe"); + + rv = Val_int (r); + 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); +} +