X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=ocaml%2Fguestfs_c_actions.c;h=f4079564db3f246f40ac5f7f0574b5f74f4fea18;hp=e4dc509990708543c88788fc856d25d4f8fb52dc;hb=0574eab8bc7d8e72db862ec36815835938a5fdf1;hpb=4211c7a258debd236017a19c70965bc1b3658edb diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index e4dc509..f407956 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -4248,3 +4248,122 @@ ocaml_guestfs_sh_lines (value gv, value commandv) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_glob_expand (value gv, value patternv) +{ + CAMLparam2 (gv, patternv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("glob_expand: used handle after closing it"); + + const char *pattern = String_val (patternv); + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_glob_expand (g, pattern); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "glob_expand"); + + 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_scrub_device (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("scrub_device: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_scrub_device (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "scrub_device"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_scrub_file (value gv, value filev) +{ + CAMLparam2 (gv, filev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("scrub_file: used handle after closing it"); + + const char *file = String_val (filev); + int r; + + caml_enter_blocking_section (); + r = guestfs_scrub_file (g, file); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "scrub_file"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_scrub_freespace (value gv, value dirv) +{ + CAMLparam2 (gv, dirv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("scrub_freespace: used handle after closing it"); + + const char *dir = String_val (dirv); + int r; + + caml_enter_blocking_section (); + r = guestfs_scrub_freespace (g, dir); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "scrub_freespace"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_mkdtemp (value gv, value templatev) +{ + CAMLparam2 (gv, templatev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("mkdtemp: used handle after closing it"); + + const char *template = String_val (templatev); + char *r; + + caml_enter_blocking_section (); + r = guestfs_mkdtemp (g, template); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "mkdtemp"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} +