X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=ocaml%2Fguestfs_c_actions.c;h=c64bcf09349281ba658cc91920a312b677d327b9;hp=73515cfccc87def218f01b3113e2553a2fd021f6;hb=ca49c50e06834bbc68e21630a5552c57494f2b53;hpb=aed0fa2c015e56a882fd6d4b759c82df08fc40d7 diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index 73515cf..c64bcf0 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -556,6 +556,51 @@ ocaml_guestfs_get_path (value gv) } CAMLprim value +ocaml_guestfs_set_append (value gv, value appendv) +{ + CAMLparam2 (gv, appendv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("set_append: used handle after closing it"); + + const char *append = String_val (appendv); + int r; + + caml_enter_blocking_section (); + r = guestfs_set_append (g, append); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "set_append"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_get_append (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("get_append: used handle after closing it"); + + const char *r; + + caml_enter_blocking_section (); + r = guestfs_get_append (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "get_append"); + + rv = caml_copy_string (r); + CAMLreturn (rv); +} + +CAMLprim value ocaml_guestfs_set_autosync (value gv, value autosyncv) { CAMLparam2 (gv, autosyncv); @@ -800,6 +845,28 @@ ocaml_guestfs_set_ready (value gv) } CAMLprim value +ocaml_guestfs_end_busy (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("end_busy: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_end_busy (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "end_busy"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value ocaml_guestfs_mount (value gv, value devicev, value mountpointv) { CAMLparam3 (gv, devicev, mountpointv); @@ -1744,7 +1811,7 @@ ocaml_guestfs_vgcreate (value gv, value volgroupv, value physvolsv) caml_failwith ("vgcreate: used handle after closing it"); const char *volgroup = String_val (volgroupv); - char **physvols = ocaml_guestfs_strings_val (physvolsv); + char **physvols = ocaml_guestfs_strings_val (g, physvolsv); int r; caml_enter_blocking_section (); @@ -1822,7 +1889,7 @@ ocaml_guestfs_sfdisk (value gv, value devicev, value cylsv, value headsv, value int cyls = Int_val (cylsv); int heads = Int_val (headsv); int sectors = Int_val (sectorsv); - char **lines = ocaml_guestfs_strings_val (linesv); + char **lines = ocaml_guestfs_strings_val (g, linesv); int r; caml_enter_blocking_section (); @@ -1993,7 +2060,7 @@ ocaml_guestfs_command (value gv, value argumentsv) if (g == NULL) caml_failwith ("command: used handle after closing it"); - char **arguments = ocaml_guestfs_strings_val (argumentsv); + char **arguments = ocaml_guestfs_strings_val (g, argumentsv); char *r; caml_enter_blocking_section (); @@ -2018,7 +2085,7 @@ ocaml_guestfs_command_lines (value gv, value argumentsv) if (g == NULL) caml_failwith ("command_lines: used handle after closing it"); - char **arguments = ocaml_guestfs_strings_val (argumentsv); + char **arguments = ocaml_guestfs_strings_val (g, argumentsv); int i; char **r; @@ -2619,7 +2686,7 @@ ocaml_guestfs_debug (value gv, value subcmdv, value extraargsv) caml_failwith ("debug: used handle after closing it"); const char *subcmd = String_val (subcmdv); - char **extraargs = ocaml_guestfs_strings_val (extraargsv); + char **extraargs = ocaml_guestfs_strings_val (g, extraargsv); char *r; caml_enter_blocking_section (); @@ -2703,3 +2770,659 @@ ocaml_guestfs_pvremove (value gv, value devicev) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_set_e2label (value gv, value devicev, value labelv) +{ + CAMLparam3 (gv, devicev, labelv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("set_e2label: used handle after closing it"); + + const char *device = String_val (devicev); + const char *label = String_val (labelv); + int r; + + caml_enter_blocking_section (); + r = guestfs_set_e2label (g, device, label); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "set_e2label"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_get_e2label (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("get_e2label: used handle after closing it"); + + const char *device = String_val (devicev); + char *r; + + caml_enter_blocking_section (); + r = guestfs_get_e2label (g, device); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "get_e2label"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_set_e2uuid (value gv, value devicev, value uuidv) +{ + CAMLparam3 (gv, devicev, uuidv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("set_e2uuid: used handle after closing it"); + + const char *device = String_val (devicev); + const char *uuid = String_val (uuidv); + int r; + + caml_enter_blocking_section (); + r = guestfs_set_e2uuid (g, device, uuid); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "set_e2uuid"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_get_e2uuid (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("get_e2uuid: used handle after closing it"); + + const char *device = String_val (devicev); + char *r; + + caml_enter_blocking_section (); + r = guestfs_get_e2uuid (g, device); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "get_e2uuid"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_fsck (value gv, value fstypev, value devicev) +{ + CAMLparam3 (gv, fstypev, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("fsck: used handle after closing it"); + + const char *fstype = String_val (fstypev); + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_fsck (g, fstype, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "fsck"); + + rv = Val_int (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_zero (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("zero: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_zero (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "zero"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_grub_install (value gv, value rootv, value devicev) +{ + CAMLparam3 (gv, rootv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("grub_install: used handle after closing it"); + + const char *root = String_val (rootv); + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_grub_install (g, root, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "grub_install"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_cp (value gv, value srcv, value destv) +{ + CAMLparam3 (gv, srcv, destv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("cp: used handle after closing it"); + + const char *src = String_val (srcv); + const char *dest = String_val (destv); + int r; + + caml_enter_blocking_section (); + r = guestfs_cp (g, src, dest); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "cp"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_cp_a (value gv, value srcv, value destv) +{ + CAMLparam3 (gv, srcv, destv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("cp_a: used handle after closing it"); + + const char *src = String_val (srcv); + const char *dest = String_val (destv); + int r; + + caml_enter_blocking_section (); + r = guestfs_cp_a (g, src, dest); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "cp_a"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_mv (value gv, value srcv, value destv) +{ + CAMLparam3 (gv, srcv, destv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("mv: used handle after closing it"); + + const char *src = String_val (srcv); + const char *dest = String_val (destv); + int r; + + caml_enter_blocking_section (); + r = guestfs_mv (g, src, dest); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "mv"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_drop_caches (value gv, value whattodropv) +{ + CAMLparam2 (gv, whattodropv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("drop_caches: used handle after closing it"); + + int whattodrop = Int_val (whattodropv); + int r; + + caml_enter_blocking_section (); + r = guestfs_drop_caches (g, whattodrop); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "drop_caches"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_dmesg (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("dmesg: used handle after closing it"); + + char *r; + + caml_enter_blocking_section (); + r = guestfs_dmesg (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "dmesg"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_ping_daemon (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("ping_daemon: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_ping_daemon (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "ping_daemon"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_equal (value gv, value file1v, value file2v) +{ + CAMLparam3 (gv, file1v, file2v); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("equal: used handle after closing it"); + + const char *file1 = String_val (file1v); + const char *file2 = String_val (file2v); + int r; + + caml_enter_blocking_section (); + r = guestfs_equal (g, file1, file2); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "equal"); + + rv = Val_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_strings (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("strings: used handle after closing it"); + + const char *path = String_val (pathv); + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_strings (g, path); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "strings"); + + 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_strings_e (value gv, value encodingv, value pathv) +{ + CAMLparam3 (gv, encodingv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("strings_e: used handle after closing it"); + + const char *encoding = String_val (encodingv); + const char *path = String_val (pathv); + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_strings_e (g, encoding, path); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "strings_e"); + + 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_hexdump (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("hexdump: used handle after closing it"); + + const char *path = String_val (pathv); + char *r; + + caml_enter_blocking_section (); + r = guestfs_hexdump (g, path); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "hexdump"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_zerofree (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("zerofree: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_zerofree (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "zerofree"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_pvresize (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("pvresize: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_pvresize (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "pvresize"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_sfdisk_N (value gv, value devicev, value nv, value cylsv, value headsv, value sectorsv, value linev) +{ + CAMLparam5 (gv, devicev, nv, cylsv, headsv); + CAMLxparam2 (sectorsv, linev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("sfdisk_N: used handle after closing it"); + + const char *device = String_val (devicev); + int n = Int_val (nv); + int cyls = Int_val (cylsv); + int heads = Int_val (headsv); + int sectors = Int_val (sectorsv); + const char *line = String_val (linev); + int r; + + caml_enter_blocking_section (); + r = guestfs_sfdisk_N (g, device, n, cyls, heads, sectors, line); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "sfdisk_N"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_sfdisk_N_byte (value *argv, int argn) +{ + return ocaml_guestfs_sfdisk_N (argv[0], argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); +} + +CAMLprim value +ocaml_guestfs_sfdisk_l (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("sfdisk_l: used handle after closing it"); + + const char *device = String_val (devicev); + char *r; + + caml_enter_blocking_section (); + r = guestfs_sfdisk_l (g, device); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "sfdisk_l"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_sfdisk_kernel_geometry (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("sfdisk_kernel_geometry: used handle after closing it"); + + const char *device = String_val (devicev); + char *r; + + caml_enter_blocking_section (); + r = guestfs_sfdisk_kernel_geometry (g, device); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "sfdisk_kernel_geometry"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_sfdisk_disk_geometry (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("sfdisk_disk_geometry: used handle after closing it"); + + const char *device = String_val (devicev); + char *r; + + caml_enter_blocking_section (); + r = guestfs_sfdisk_disk_geometry (g, device); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "sfdisk_disk_geometry"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_vg_activate_all (value gv, value activatev) +{ + CAMLparam2 (gv, activatev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("vg_activate_all: used handle after closing it"); + + int activate = Bool_val (activatev); + int r; + + caml_enter_blocking_section (); + r = guestfs_vg_activate_all (g, activate); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "vg_activate_all"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_vg_activate (value gv, value activatev, value volgroupsv) +{ + CAMLparam3 (gv, activatev, volgroupsv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("vg_activate: used handle after closing it"); + + int activate = Bool_val (activatev); + char **volgroups = ocaml_guestfs_strings_val (g, volgroupsv); + int r; + + caml_enter_blocking_section (); + r = guestfs_vg_activate (g, activate, volgroups); + caml_leave_blocking_section (); + ocaml_guestfs_free_strings (volgroups); + if (r == -1) + ocaml_guestfs_raise_error (g, "vg_activate"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_lvresize (value gv, value devicev, value mbytesv) +{ + CAMLparam3 (gv, devicev, mbytesv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("lvresize: used handle after closing it"); + + const char *device = String_val (devicev); + int mbytes = Int_val (mbytesv); + int r; + + caml_enter_blocking_section (); + r = guestfs_lvresize (g, device, mbytes); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "lvresize"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_resize2fs (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("resize2fs: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_resize2fs (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "resize2fs"); + + rv = Val_unit; + CAMLreturn (rv); +} +