X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=ocaml%2Fguestfs_c_actions.c;h=c396a8a84f834a6e0af8941e0ac5218b7213f13f;hp=decb838338ab40883681b0579ec96d98ffeb20c5;hb=8f9f02d483b87c787d089cf9329f5f1b81d3a77e;hpb=adefe14e308a0f8cf73f9c60693a3dbbded157b9 diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index decb838..c396a8a 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -35,6 +35,33 @@ #include "guestfs_c.h" +/* Copy a hashtable of string pairs into an assoc-list. We return + * the list in reverse order, but hashtables aren't supposed to be + * ordered anyway. + */ +static CAMLprim value +copy_table (char * const * argv) +{ + CAMLparam0 (); + CAMLlocal5 (rv, pairv, kv, vv, cons); + int i; + + rv = Val_int (0); + for (i = 0; argv[i] != NULL; i += 2) { + kv = caml_copy_string (argv[i]); + vv = caml_copy_string (argv[i+1]); + pairv = caml_alloc (2, 0); + Store_field (pairv, 0, kv); + Store_field (pairv, 1, vv); + cons = caml_alloc (2, 0); + Store_field (cons, 1, rv); + rv = cons; + Store_field (cons, 0, pairv); + } + + CAMLreturn (rv); +} + static CAMLprim value copy_lvm_pv (const struct guestfs_lvm_pv *pv) { @@ -233,6 +260,74 @@ copy_lvm_lv_list (const struct guestfs_lvm_lv_list *lvs) } } +static CAMLprim value +copy_stat (const struct guestfs_stat *stat) +{ + CAMLparam0 (); + CAMLlocal2 (rv, v); + + rv = caml_alloc (13, 0); + v = caml_copy_int64 (stat->dev); + Store_field (rv, 0, v); + v = caml_copy_int64 (stat->ino); + Store_field (rv, 1, v); + v = caml_copy_int64 (stat->mode); + Store_field (rv, 2, v); + v = caml_copy_int64 (stat->nlink); + Store_field (rv, 3, v); + v = caml_copy_int64 (stat->uid); + Store_field (rv, 4, v); + v = caml_copy_int64 (stat->gid); + Store_field (rv, 5, v); + v = caml_copy_int64 (stat->rdev); + Store_field (rv, 6, v); + v = caml_copy_int64 (stat->size); + Store_field (rv, 7, v); + v = caml_copy_int64 (stat->blksize); + Store_field (rv, 8, v); + v = caml_copy_int64 (stat->blocks); + Store_field (rv, 9, v); + v = caml_copy_int64 (stat->atime); + Store_field (rv, 10, v); + v = caml_copy_int64 (stat->mtime); + Store_field (rv, 11, v); + v = caml_copy_int64 (stat->ctime); + Store_field (rv, 12, v); + CAMLreturn (rv); +} + +static CAMLprim value +copy_statvfs (const struct guestfs_statvfs *statvfs) +{ + CAMLparam0 (); + CAMLlocal2 (rv, v); + + rv = caml_alloc (11, 0); + v = caml_copy_int64 (statvfs->bsize); + Store_field (rv, 0, v); + v = caml_copy_int64 (statvfs->frsize); + Store_field (rv, 1, v); + v = caml_copy_int64 (statvfs->blocks); + Store_field (rv, 2, v); + v = caml_copy_int64 (statvfs->bfree); + Store_field (rv, 3, v); + v = caml_copy_int64 (statvfs->bavail); + Store_field (rv, 4, v); + v = caml_copy_int64 (statvfs->files); + Store_field (rv, 5, v); + v = caml_copy_int64 (statvfs->ffree); + Store_field (rv, 6, v); + v = caml_copy_int64 (statvfs->favail); + Store_field (rv, 7, v); + v = caml_copy_int64 (statvfs->fsid); + Store_field (rv, 8, v); + v = caml_copy_int64 (statvfs->flag); + Store_field (rv, 9, v); + v = caml_copy_int64 (statvfs->namemax); + Store_field (rv, 10, v); + CAMLreturn (rv); +} + CAMLprim value ocaml_guestfs_launch (value gv) { @@ -371,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); @@ -506,6 +646,160 @@ ocaml_guestfs_get_verbose (value gv) } CAMLprim value +ocaml_guestfs_is_ready (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("is_ready: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_is_ready (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "is_ready"); + + rv = Val_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_is_config (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("is_config: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_is_config (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "is_config"); + + rv = Val_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_is_launching (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("is_launching: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_is_launching (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "is_launching"); + + rv = Val_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_is_busy (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("is_busy: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_is_busy (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "is_busy"); + + rv = Val_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_get_state (value gv) +{ + CAMLparam1 (gv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("get_state: used handle after closing it"); + + int r; + + caml_enter_blocking_section (); + r = guestfs_get_state (g); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "get_state"); + + rv = Val_int (r); + CAMLreturn (rv); +} + +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); @@ -1689,3 +1983,654 @@ ocaml_guestfs_file (value gv, value pathv) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_command (value gv, value argumentsv) +{ + CAMLparam2 (gv, argumentsv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("command: used handle after closing it"); + + char **arguments = ocaml_guestfs_strings_val (argumentsv); + char *r; + + caml_enter_blocking_section (); + r = guestfs_command (g, arguments); + caml_leave_blocking_section (); + ocaml_guestfs_free_strings (arguments); + if (r == NULL) + ocaml_guestfs_raise_error (g, "command"); + + rv = caml_copy_string (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_command_lines (value gv, value argumentsv) +{ + CAMLparam2 (gv, argumentsv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("command_lines: used handle after closing it"); + + char **arguments = ocaml_guestfs_strings_val (argumentsv); + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_command_lines (g, arguments); + caml_leave_blocking_section (); + ocaml_guestfs_free_strings (arguments); + if (r == NULL) + ocaml_guestfs_raise_error (g, "command_lines"); + + 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_stat (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("stat: used handle after closing it"); + + const char *path = String_val (pathv); + struct guestfs_stat *r; + + caml_enter_blocking_section (); + r = guestfs_stat (g, path); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "stat"); + + rv = copy_stat (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_lstat (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("lstat: used handle after closing it"); + + const char *path = String_val (pathv); + struct guestfs_stat *r; + + caml_enter_blocking_section (); + r = guestfs_lstat (g, path); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "lstat"); + + rv = copy_stat (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_statvfs (value gv, value pathv) +{ + CAMLparam2 (gv, pathv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("statvfs: used handle after closing it"); + + const char *path = String_val (pathv); + struct guestfs_statvfs *r; + + caml_enter_blocking_section (); + r = guestfs_statvfs (g, path); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "statvfs"); + + rv = copy_statvfs (r); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_tune2fs_l (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("tune2fs_l: used handle after closing it"); + + const char *device = String_val (devicev); + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_tune2fs_l (g, device); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "tune2fs_l"); + + rv = copy_table (r); + for (i = 0; r[i] != NULL; ++i) free (r[i]); + free (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_blockdev_setro (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("blockdev_setro: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_blockdev_setro (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "blockdev_setro"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_blockdev_setrw (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("blockdev_setrw: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_blockdev_setrw (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "blockdev_setrw"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_blockdev_getro (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("blockdev_getro: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_blockdev_getro (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "blockdev_getro"); + + rv = Val_bool (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_blockdev_getss (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("blockdev_getss: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_blockdev_getss (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "blockdev_getss"); + + rv = Val_int (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_blockdev_getbsz (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("blockdev_getbsz: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_blockdev_getbsz (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "blockdev_getbsz"); + + rv = Val_int (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_blockdev_setbsz (value gv, value devicev, value blocksizev) +{ + CAMLparam3 (gv, devicev, blocksizev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("blockdev_setbsz: used handle after closing it"); + + const char *device = String_val (devicev); + int blocksize = Int_val (blocksizev); + int r; + + caml_enter_blocking_section (); + r = guestfs_blockdev_setbsz (g, device, blocksize); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "blockdev_setbsz"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_blockdev_getsz (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("blockdev_getsz: used handle after closing it"); + + const char *device = String_val (devicev); + int64_t r; + + caml_enter_blocking_section (); + r = guestfs_blockdev_getsz (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "blockdev_getsz"); + + rv = caml_copy_int64 (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_blockdev_getsize64 (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("blockdev_getsize64: used handle after closing it"); + + const char *device = String_val (devicev); + int64_t r; + + caml_enter_blocking_section (); + r = guestfs_blockdev_getsize64 (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "blockdev_getsize64"); + + rv = caml_copy_int64 (r); + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_blockdev_flushbufs (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("blockdev_flushbufs: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_blockdev_flushbufs (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "blockdev_flushbufs"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_blockdev_rereadpt (value gv, value devicev) +{ + CAMLparam2 (gv, devicev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("blockdev_rereadpt: used handle after closing it"); + + const char *device = String_val (devicev); + int r; + + caml_enter_blocking_section (); + r = guestfs_blockdev_rereadpt (g, device); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "blockdev_rereadpt"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_upload (value gv, value filenamev, value remotefilenamev) +{ + CAMLparam3 (gv, filenamev, remotefilenamev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("upload: used handle after closing it"); + + const char *filename = String_val (filenamev); + const char *remotefilename = String_val (remotefilenamev); + int r; + + caml_enter_blocking_section (); + r = guestfs_upload (g, filename, remotefilename); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "upload"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_download (value gv, value remotefilenamev, value filenamev) +{ + CAMLparam3 (gv, remotefilenamev, filenamev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("download: used handle after closing it"); + + const char *remotefilename = String_val (remotefilenamev); + const char *filename = String_val (filenamev); + int r; + + caml_enter_blocking_section (); + r = guestfs_download (g, remotefilename, filename); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "download"); + + rv = Val_unit; + 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 (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); +} +