X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=ocaml%2Fguestfs_c_actions.c;h=a707897af0c0908db3223a1a67cd6976b2732fd1;hp=4d7b350a5a0925bd36d9ccd9de00b7157306be55;hb=0faa5dde7b992ba11bb88f77b3424676c7c492e4;hpb=bb07a7f858da5d07c57360e62c0ddfd24ce6be45 diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index 4d7b350..a707897 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -466,6 +466,51 @@ ocaml_guestfs_config (value gv, value qemuparamv, value qemuvaluev) } CAMLprim value +ocaml_guestfs_set_qemu (value gv, value qemuv) +{ + CAMLparam2 (gv, qemuv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("set_qemu: used handle after closing it"); + + const char *qemu = String_val (qemuv); + int r; + + caml_enter_blocking_section (); + r = guestfs_set_qemu (g, qemu); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "set_qemu"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_get_qemu (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("get_qemu: used handle after closing it"); + + const char *r; + + caml_enter_blocking_section (); + r = guestfs_get_qemu (g); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "get_qemu"); + + rv = caml_copy_string (r); + CAMLreturn (rv); +} + +CAMLprim value ocaml_guestfs_set_path (value gv, value pathv) { CAMLparam2 (gv, pathv); @@ -711,6 +756,50 @@ ocaml_guestfs_get_state (value gv) } CAMLprim value +ocaml_guestfs_set_busy (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("set_busy: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_set_busy (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "set_busy"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_set_ready (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("set_ready: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_set_ready (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "set_ready"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value ocaml_guestfs_mount (value gv, value devicev, value mountpointv) { CAMLparam3 (gv, devicev, mountpointv); @@ -1655,7 +1744,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 (); @@ -1733,7 +1822,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 (); @@ -1904,7 +1993,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 (); @@ -1929,7 +2018,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; @@ -2323,3 +2412,702 @@ ocaml_guestfs_download (value gv, value remotefilenamev, value filenamev) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_checksum (value gv, value csumtypev, value pathv) +{ + CAMLparam3 (gv, csumtypev, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("checksum: used handle after closing it"); + + const char *csumtype = String_val (csumtypev); + const char *path = String_val (pathv); + char *r; + + caml_enter_blocking_section (); + r = guestfs_checksum (g, csumtype, path); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "checksum"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_tar_in (value gv, value tarfilev, value directoryv) +{ + CAMLparam3 (gv, tarfilev, directoryv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("tar_in: used handle after closing it"); + + const char *tarfile = String_val (tarfilev); + const char *directory = String_val (directoryv); + int r; + + caml_enter_blocking_section (); + r = guestfs_tar_in (g, tarfile, directory); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "tar_in"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_tar_out (value gv, value directoryv, value tarfilev) +{ + CAMLparam3 (gv, directoryv, tarfilev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("tar_out: used handle after closing it"); + + const char *directory = String_val (directoryv); + const char *tarfile = String_val (tarfilev); + int r; + + caml_enter_blocking_section (); + r = guestfs_tar_out (g, directory, tarfile); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "tar_out"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_tgz_in (value gv, value tarballv, value directoryv) +{ + CAMLparam3 (gv, tarballv, directoryv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("tgz_in: used handle after closing it"); + + const char *tarball = String_val (tarballv); + const char *directory = String_val (directoryv); + int r; + + caml_enter_blocking_section (); + r = guestfs_tgz_in (g, tarball, directory); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "tgz_in"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_tgz_out (value gv, value directoryv, value tarballv) +{ + CAMLparam3 (gv, directoryv, tarballv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("tgz_out: used handle after closing it"); + + const char *directory = String_val (directoryv); + const char *tarball = String_val (tarballv); + int r; + + caml_enter_blocking_section (); + r = guestfs_tgz_out (g, directory, tarball); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "tgz_out"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_mount_ro (value gv, value devicev, value mountpointv) +{ + CAMLparam3 (gv, devicev, mountpointv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("mount_ro: used handle after closing it"); + + const char *device = String_val (devicev); + const char *mountpoint = String_val (mountpointv); + int r; + + caml_enter_blocking_section (); + r = guestfs_mount_ro (g, device, mountpoint); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "mount_ro"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_mount_options (value gv, value optionsv, value devicev, value mountpointv) +{ + CAMLparam4 (gv, optionsv, devicev, mountpointv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("mount_options: used handle after closing it"); + + const char *options = String_val (optionsv); + const char *device = String_val (devicev); + const char *mountpoint = String_val (mountpointv); + int r; + + caml_enter_blocking_section (); + r = guestfs_mount_options (g, options, device, mountpoint); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "mount_options"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_mount_vfs (value gv, value optionsv, value vfstypev, value devicev, value mountpointv) +{ + CAMLparam5 (gv, optionsv, vfstypev, devicev, mountpointv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("mount_vfs: used handle after closing it"); + + const char *options = String_val (optionsv); + const char *vfstype = String_val (vfstypev); + const char *device = String_val (devicev); + const char *mountpoint = String_val (mountpointv); + int r; + + caml_enter_blocking_section (); + r = guestfs_mount_vfs (g, options, vfstype, device, mountpoint); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "mount_vfs"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_debug (value gv, value subcmdv, value extraargsv) +{ + CAMLparam3 (gv, subcmdv, extraargsv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("debug: used handle after closing it"); + + const char *subcmd = String_val (subcmdv); + char **extraargs = ocaml_guestfs_strings_val (g, extraargsv); + char *r; + + caml_enter_blocking_section (); + r = guestfs_debug (g, subcmd, extraargs); + caml_leave_blocking_section (); + ocaml_guestfs_free_strings (extraargs); + if (r == NULL) + ocaml_guestfs_raise_error (g, "debug"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_lvremove (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("lvremove: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_lvremove (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "lvremove"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_vgremove (value gv, value vgnamev) +{ + CAMLparam2 (gv, vgnamev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("vgremove: used handle after closing it"); + + const char *vgname = String_val (vgnamev); + int r; + + caml_enter_blocking_section (); + r = guestfs_vgremove (g, vgname); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "vgremove"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_pvremove (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("pvremove: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_pvremove (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "pvremove"); + + rv = Val_unit; + 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); +} +