1 /* libguestfs generated file
2 * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3 * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
5 * Copyright (C) 2009 Red Hat Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <caml/config.h>
27 #include <caml/alloc.h>
28 #include <caml/callback.h>
29 #include <caml/fail.h>
30 #include <caml/memory.h>
31 #include <caml/mlvalues.h>
32 #include <caml/signals.h>
36 #include "guestfs_c.h"
39 copy_lvm_pv (const struct guestfs_lvm_pv *pv)
44 rv = caml_alloc (14, 0);
45 v = caml_copy_string (pv->pv_name);
46 Store_field (rv, 0, v);
47 v = caml_alloc_string (32);
48 memcpy (String_val (v), pv->pv_uuid, 32);
49 Store_field (rv, 1, v);
50 v = caml_copy_string (pv->pv_fmt);
51 Store_field (rv, 2, v);
52 v = caml_copy_int64 (pv->pv_size);
53 Store_field (rv, 3, v);
54 v = caml_copy_int64 (pv->dev_size);
55 Store_field (rv, 4, v);
56 v = caml_copy_int64 (pv->pv_free);
57 Store_field (rv, 5, v);
58 v = caml_copy_int64 (pv->pv_used);
59 Store_field (rv, 6, v);
60 v = caml_copy_string (pv->pv_attr);
61 Store_field (rv, 7, v);
62 v = caml_copy_int64 (pv->pv_pe_count);
63 Store_field (rv, 8, v);
64 v = caml_copy_int64 (pv->pv_pe_alloc_count);
65 Store_field (rv, 9, v);
66 v = caml_copy_string (pv->pv_tags);
67 Store_field (rv, 10, v);
68 v = caml_copy_int64 (pv->pe_start);
69 Store_field (rv, 11, v);
70 v = caml_copy_int64 (pv->pv_mda_count);
71 Store_field (rv, 12, v);
72 v = caml_copy_int64 (pv->pv_mda_free);
73 Store_field (rv, 13, v);
78 copy_lvm_pv_list (const struct guestfs_lvm_pv_list *pvs)
85 CAMLreturn (Atom (0));
87 rv = caml_alloc (pvs->len, 0);
88 for (i = 0; i < pvs->len; ++i) {
89 v = copy_lvm_pv (&pvs->val[i]);
90 caml_modify (&Field (rv, i), v);
97 copy_lvm_vg (const struct guestfs_lvm_vg *vg)
102 rv = caml_alloc (19, 0);
103 v = caml_copy_string (vg->vg_name);
104 Store_field (rv, 0, v);
105 v = caml_alloc_string (32);
106 memcpy (String_val (v), vg->vg_uuid, 32);
107 Store_field (rv, 1, v);
108 v = caml_copy_string (vg->vg_fmt);
109 Store_field (rv, 2, v);
110 v = caml_copy_string (vg->vg_attr);
111 Store_field (rv, 3, v);
112 v = caml_copy_int64 (vg->vg_size);
113 Store_field (rv, 4, v);
114 v = caml_copy_int64 (vg->vg_free);
115 Store_field (rv, 5, v);
116 v = caml_copy_string (vg->vg_sysid);
117 Store_field (rv, 6, v);
118 v = caml_copy_int64 (vg->vg_extent_size);
119 Store_field (rv, 7, v);
120 v = caml_copy_int64 (vg->vg_extent_count);
121 Store_field (rv, 8, v);
122 v = caml_copy_int64 (vg->vg_free_count);
123 Store_field (rv, 9, v);
124 v = caml_copy_int64 (vg->max_lv);
125 Store_field (rv, 10, v);
126 v = caml_copy_int64 (vg->max_pv);
127 Store_field (rv, 11, v);
128 v = caml_copy_int64 (vg->pv_count);
129 Store_field (rv, 12, v);
130 v = caml_copy_int64 (vg->lv_count);
131 Store_field (rv, 13, v);
132 v = caml_copy_int64 (vg->snap_count);
133 Store_field (rv, 14, v);
134 v = caml_copy_int64 (vg->vg_seqno);
135 Store_field (rv, 15, v);
136 v = caml_copy_string (vg->vg_tags);
137 Store_field (rv, 16, v);
138 v = caml_copy_int64 (vg->vg_mda_count);
139 Store_field (rv, 17, v);
140 v = caml_copy_int64 (vg->vg_mda_free);
141 Store_field (rv, 18, v);
145 static CAMLprim value
146 copy_lvm_vg_list (const struct guestfs_lvm_vg_list *vgs)
153 CAMLreturn (Atom (0));
155 rv = caml_alloc (vgs->len, 0);
156 for (i = 0; i < vgs->len; ++i) {
157 v = copy_lvm_vg (&vgs->val[i]);
158 caml_modify (&Field (rv, i), v);
164 static CAMLprim value
165 copy_lvm_lv (const struct guestfs_lvm_lv *lv)
168 CAMLlocal3 (rv, v, v2);
170 rv = caml_alloc (16, 0);
171 v = caml_copy_string (lv->lv_name);
172 Store_field (rv, 0, v);
173 v = caml_alloc_string (32);
174 memcpy (String_val (v), lv->lv_uuid, 32);
175 Store_field (rv, 1, v);
176 v = caml_copy_string (lv->lv_attr);
177 Store_field (rv, 2, v);
178 v = caml_copy_int64 (lv->lv_major);
179 Store_field (rv, 3, v);
180 v = caml_copy_int64 (lv->lv_minor);
181 Store_field (rv, 4, v);
182 v = caml_copy_int64 (lv->lv_kernel_major);
183 Store_field (rv, 5, v);
184 v = caml_copy_int64 (lv->lv_kernel_minor);
185 Store_field (rv, 6, v);
186 v = caml_copy_int64 (lv->lv_size);
187 Store_field (rv, 7, v);
188 v = caml_copy_int64 (lv->seg_count);
189 Store_field (rv, 8, v);
190 v = caml_copy_string (lv->origin);
191 Store_field (rv, 9, v);
192 if (lv->snap_percent >= 0) { /* Some snap_percent */
193 v2 = caml_copy_double (lv->snap_percent);
194 v = caml_alloc (1, 0);
195 Store_field (v, 0, v2);
198 Store_field (rv, 10, v);
199 if (lv->copy_percent >= 0) { /* Some copy_percent */
200 v2 = caml_copy_double (lv->copy_percent);
201 v = caml_alloc (1, 0);
202 Store_field (v, 0, v2);
205 Store_field (rv, 11, v);
206 v = caml_copy_string (lv->move_pv);
207 Store_field (rv, 12, v);
208 v = caml_copy_string (lv->lv_tags);
209 Store_field (rv, 13, v);
210 v = caml_copy_string (lv->mirror_log);
211 Store_field (rv, 14, v);
212 v = caml_copy_string (lv->modules);
213 Store_field (rv, 15, v);
217 static CAMLprim value
218 copy_lvm_lv_list (const struct guestfs_lvm_lv_list *lvs)
225 CAMLreturn (Atom (0));
227 rv = caml_alloc (lvs->len, 0);
228 for (i = 0; i < lvs->len; ++i) {
229 v = copy_lvm_lv (&lvs->val[i]);
230 caml_modify (&Field (rv, i), v);
237 ocaml_guestfs_launch (value gv)
242 guestfs_h *g = Guestfs_val (gv);
244 caml_failwith ("launch: used handle after closing it");
248 caml_enter_blocking_section ();
249 r = guestfs_launch (g);
250 caml_leave_blocking_section ();
252 ocaml_guestfs_raise_error (g, "launch");
259 ocaml_guestfs_wait_ready (value gv)
264 guestfs_h *g = Guestfs_val (gv);
266 caml_failwith ("wait_ready: used handle after closing it");
270 caml_enter_blocking_section ();
271 r = guestfs_wait_ready (g);
272 caml_leave_blocking_section ();
274 ocaml_guestfs_raise_error (g, "wait_ready");
281 ocaml_guestfs_kill_subprocess (value gv)
286 guestfs_h *g = Guestfs_val (gv);
288 caml_failwith ("kill_subprocess: used handle after closing it");
292 caml_enter_blocking_section ();
293 r = guestfs_kill_subprocess (g);
294 caml_leave_blocking_section ();
296 ocaml_guestfs_raise_error (g, "kill_subprocess");
303 ocaml_guestfs_add_drive (value gv, value filenamev)
305 CAMLparam2 (gv, filenamev);
308 guestfs_h *g = Guestfs_val (gv);
310 caml_failwith ("add_drive: used handle after closing it");
312 const char *filename = String_val (filenamev);
315 caml_enter_blocking_section ();
316 r = guestfs_add_drive (g, filename);
317 caml_leave_blocking_section ();
319 ocaml_guestfs_raise_error (g, "add_drive");
326 ocaml_guestfs_add_cdrom (value gv, value filenamev)
328 CAMLparam2 (gv, filenamev);
331 guestfs_h *g = Guestfs_val (gv);
333 caml_failwith ("add_cdrom: used handle after closing it");
335 const char *filename = String_val (filenamev);
338 caml_enter_blocking_section ();
339 r = guestfs_add_cdrom (g, filename);
340 caml_leave_blocking_section ();
342 ocaml_guestfs_raise_error (g, "add_cdrom");
349 ocaml_guestfs_config (value gv, value qemuparamv, value qemuvaluev)
351 CAMLparam3 (gv, qemuparamv, qemuvaluev);
354 guestfs_h *g = Guestfs_val (gv);
356 caml_failwith ("config: used handle after closing it");
358 const char *qemuparam = String_val (qemuparamv);
359 const char *qemuvalue =
360 qemuvaluev != Val_int (0) ? String_val (Field (qemuvaluev, 0)) : NULL;
363 caml_enter_blocking_section ();
364 r = guestfs_config (g, qemuparam, qemuvalue);
365 caml_leave_blocking_section ();
367 ocaml_guestfs_raise_error (g, "config");
374 ocaml_guestfs_set_path (value gv, value pathv)
376 CAMLparam2 (gv, pathv);
379 guestfs_h *g = Guestfs_val (gv);
381 caml_failwith ("set_path: used handle after closing it");
383 const char *path = String_val (pathv);
386 caml_enter_blocking_section ();
387 r = guestfs_set_path (g, path);
388 caml_leave_blocking_section ();
390 ocaml_guestfs_raise_error (g, "set_path");
397 ocaml_guestfs_get_path (value gv)
402 guestfs_h *g = Guestfs_val (gv);
404 caml_failwith ("get_path: used handle after closing it");
408 caml_enter_blocking_section ();
409 r = guestfs_get_path (g);
410 caml_leave_blocking_section ();
412 ocaml_guestfs_raise_error (g, "get_path");
414 rv = caml_copy_string (r);
419 ocaml_guestfs_set_autosync (value gv, value autosyncv)
421 CAMLparam2 (gv, autosyncv);
424 guestfs_h *g = Guestfs_val (gv);
426 caml_failwith ("set_autosync: used handle after closing it");
428 int autosync = Bool_val (autosyncv);
431 caml_enter_blocking_section ();
432 r = guestfs_set_autosync (g, autosync);
433 caml_leave_blocking_section ();
435 ocaml_guestfs_raise_error (g, "set_autosync");
442 ocaml_guestfs_get_autosync (value gv)
447 guestfs_h *g = Guestfs_val (gv);
449 caml_failwith ("get_autosync: used handle after closing it");
453 caml_enter_blocking_section ();
454 r = guestfs_get_autosync (g);
455 caml_leave_blocking_section ();
457 ocaml_guestfs_raise_error (g, "get_autosync");
464 ocaml_guestfs_set_verbose (value gv, value verbosev)
466 CAMLparam2 (gv, verbosev);
469 guestfs_h *g = Guestfs_val (gv);
471 caml_failwith ("set_verbose: used handle after closing it");
473 int verbose = Bool_val (verbosev);
476 caml_enter_blocking_section ();
477 r = guestfs_set_verbose (g, verbose);
478 caml_leave_blocking_section ();
480 ocaml_guestfs_raise_error (g, "set_verbose");
487 ocaml_guestfs_get_verbose (value gv)
492 guestfs_h *g = Guestfs_val (gv);
494 caml_failwith ("get_verbose: used handle after closing it");
498 caml_enter_blocking_section ();
499 r = guestfs_get_verbose (g);
500 caml_leave_blocking_section ();
502 ocaml_guestfs_raise_error (g, "get_verbose");
509 ocaml_guestfs_mount (value gv, value devicev, value mountpointv)
511 CAMLparam3 (gv, devicev, mountpointv);
514 guestfs_h *g = Guestfs_val (gv);
516 caml_failwith ("mount: used handle after closing it");
518 const char *device = String_val (devicev);
519 const char *mountpoint = String_val (mountpointv);
522 caml_enter_blocking_section ();
523 r = guestfs_mount (g, device, mountpoint);
524 caml_leave_blocking_section ();
526 ocaml_guestfs_raise_error (g, "mount");
533 ocaml_guestfs_sync (value gv)
538 guestfs_h *g = Guestfs_val (gv);
540 caml_failwith ("sync: used handle after closing it");
544 caml_enter_blocking_section ();
545 r = guestfs_sync (g);
546 caml_leave_blocking_section ();
548 ocaml_guestfs_raise_error (g, "sync");
555 ocaml_guestfs_touch (value gv, value pathv)
557 CAMLparam2 (gv, pathv);
560 guestfs_h *g = Guestfs_val (gv);
562 caml_failwith ("touch: used handle after closing it");
564 const char *path = String_val (pathv);
567 caml_enter_blocking_section ();
568 r = guestfs_touch (g, path);
569 caml_leave_blocking_section ();
571 ocaml_guestfs_raise_error (g, "touch");
578 ocaml_guestfs_cat (value gv, value pathv)
580 CAMLparam2 (gv, pathv);
583 guestfs_h *g = Guestfs_val (gv);
585 caml_failwith ("cat: used handle after closing it");
587 const char *path = String_val (pathv);
590 caml_enter_blocking_section ();
591 r = guestfs_cat (g, path);
592 caml_leave_blocking_section ();
594 ocaml_guestfs_raise_error (g, "cat");
596 rv = caml_copy_string (r);
602 ocaml_guestfs_ll (value gv, value directoryv)
604 CAMLparam2 (gv, directoryv);
607 guestfs_h *g = Guestfs_val (gv);
609 caml_failwith ("ll: used handle after closing it");
611 const char *directory = String_val (directoryv);
614 caml_enter_blocking_section ();
615 r = guestfs_ll (g, directory);
616 caml_leave_blocking_section ();
618 ocaml_guestfs_raise_error (g, "ll");
620 rv = caml_copy_string (r);
626 ocaml_guestfs_ls (value gv, value directoryv)
628 CAMLparam2 (gv, directoryv);
631 guestfs_h *g = Guestfs_val (gv);
633 caml_failwith ("ls: used handle after closing it");
635 const char *directory = String_val (directoryv);
639 caml_enter_blocking_section ();
640 r = guestfs_ls (g, directory);
641 caml_leave_blocking_section ();
643 ocaml_guestfs_raise_error (g, "ls");
645 rv = caml_copy_string_array ((const char **) r);
646 for (i = 0; r[i] != NULL; ++i) free (r[i]);
652 ocaml_guestfs_list_devices (value gv)
657 guestfs_h *g = Guestfs_val (gv);
659 caml_failwith ("list_devices: used handle after closing it");
664 caml_enter_blocking_section ();
665 r = guestfs_list_devices (g);
666 caml_leave_blocking_section ();
668 ocaml_guestfs_raise_error (g, "list_devices");
670 rv = caml_copy_string_array ((const char **) r);
671 for (i = 0; r[i] != NULL; ++i) free (r[i]);
677 ocaml_guestfs_list_partitions (value gv)
682 guestfs_h *g = Guestfs_val (gv);
684 caml_failwith ("list_partitions: used handle after closing it");
689 caml_enter_blocking_section ();
690 r = guestfs_list_partitions (g);
691 caml_leave_blocking_section ();
693 ocaml_guestfs_raise_error (g, "list_partitions");
695 rv = caml_copy_string_array ((const char **) r);
696 for (i = 0; r[i] != NULL; ++i) free (r[i]);
702 ocaml_guestfs_pvs (value gv)
707 guestfs_h *g = Guestfs_val (gv);
709 caml_failwith ("pvs: used handle after closing it");
714 caml_enter_blocking_section ();
716 caml_leave_blocking_section ();
718 ocaml_guestfs_raise_error (g, "pvs");
720 rv = caml_copy_string_array ((const char **) r);
721 for (i = 0; r[i] != NULL; ++i) free (r[i]);
727 ocaml_guestfs_vgs (value gv)
732 guestfs_h *g = Guestfs_val (gv);
734 caml_failwith ("vgs: used handle after closing it");
739 caml_enter_blocking_section ();
741 caml_leave_blocking_section ();
743 ocaml_guestfs_raise_error (g, "vgs");
745 rv = caml_copy_string_array ((const char **) r);
746 for (i = 0; r[i] != NULL; ++i) free (r[i]);
752 ocaml_guestfs_lvs (value gv)
757 guestfs_h *g = Guestfs_val (gv);
759 caml_failwith ("lvs: used handle after closing it");
764 caml_enter_blocking_section ();
766 caml_leave_blocking_section ();
768 ocaml_guestfs_raise_error (g, "lvs");
770 rv = caml_copy_string_array ((const char **) r);
771 for (i = 0; r[i] != NULL; ++i) free (r[i]);
777 ocaml_guestfs_pvs_full (value gv)
782 guestfs_h *g = Guestfs_val (gv);
784 caml_failwith ("pvs_full: used handle after closing it");
786 struct guestfs_lvm_pv_list *r;
788 caml_enter_blocking_section ();
789 r = guestfs_pvs_full (g);
790 caml_leave_blocking_section ();
792 ocaml_guestfs_raise_error (g, "pvs_full");
794 rv = copy_lvm_pv_list (r);
795 guestfs_free_lvm_pv_list (r);
800 ocaml_guestfs_vgs_full (value gv)
805 guestfs_h *g = Guestfs_val (gv);
807 caml_failwith ("vgs_full: used handle after closing it");
809 struct guestfs_lvm_vg_list *r;
811 caml_enter_blocking_section ();
812 r = guestfs_vgs_full (g);
813 caml_leave_blocking_section ();
815 ocaml_guestfs_raise_error (g, "vgs_full");
817 rv = copy_lvm_vg_list (r);
818 guestfs_free_lvm_vg_list (r);
823 ocaml_guestfs_lvs_full (value gv)
828 guestfs_h *g = Guestfs_val (gv);
830 caml_failwith ("lvs_full: used handle after closing it");
832 struct guestfs_lvm_lv_list *r;
834 caml_enter_blocking_section ();
835 r = guestfs_lvs_full (g);
836 caml_leave_blocking_section ();
838 ocaml_guestfs_raise_error (g, "lvs_full");
840 rv = copy_lvm_lv_list (r);
841 guestfs_free_lvm_lv_list (r);
846 ocaml_guestfs_read_lines (value gv, value pathv)
848 CAMLparam2 (gv, pathv);
851 guestfs_h *g = Guestfs_val (gv);
853 caml_failwith ("read_lines: used handle after closing it");
855 const char *path = String_val (pathv);
859 caml_enter_blocking_section ();
860 r = guestfs_read_lines (g, path);
861 caml_leave_blocking_section ();
863 ocaml_guestfs_raise_error (g, "read_lines");
865 rv = caml_copy_string_array ((const char **) r);
866 for (i = 0; r[i] != NULL; ++i) free (r[i]);
872 ocaml_guestfs_aug_init (value gv, value rootv, value flagsv)
874 CAMLparam3 (gv, rootv, flagsv);
877 guestfs_h *g = Guestfs_val (gv);
879 caml_failwith ("aug_init: used handle after closing it");
881 const char *root = String_val (rootv);
882 int flags = Int_val (flagsv);
885 caml_enter_blocking_section ();
886 r = guestfs_aug_init (g, root, flags);
887 caml_leave_blocking_section ();
889 ocaml_guestfs_raise_error (g, "aug_init");
896 ocaml_guestfs_aug_close (value gv)
901 guestfs_h *g = Guestfs_val (gv);
903 caml_failwith ("aug_close: used handle after closing it");
907 caml_enter_blocking_section ();
908 r = guestfs_aug_close (g);
909 caml_leave_blocking_section ();
911 ocaml_guestfs_raise_error (g, "aug_close");
918 ocaml_guestfs_aug_defvar (value gv, value namev, value exprv)
920 CAMLparam3 (gv, namev, exprv);
923 guestfs_h *g = Guestfs_val (gv);
925 caml_failwith ("aug_defvar: used handle after closing it");
927 const char *name = String_val (namev);
929 exprv != Val_int (0) ? String_val (Field (exprv, 0)) : NULL;
932 caml_enter_blocking_section ();
933 r = guestfs_aug_defvar (g, name, expr);
934 caml_leave_blocking_section ();
936 ocaml_guestfs_raise_error (g, "aug_defvar");
943 ocaml_guestfs_aug_defnode (value gv, value namev, value exprv, value valv)
945 CAMLparam4 (gv, namev, exprv, valv);
948 guestfs_h *g = Guestfs_val (gv);
950 caml_failwith ("aug_defnode: used handle after closing it");
952 const char *name = String_val (namev);
953 const char *expr = String_val (exprv);
954 const char *val = String_val (valv);
955 struct guestfs_int_bool *r;
957 caml_enter_blocking_section ();
958 r = guestfs_aug_defnode (g, name, expr, val);
959 caml_leave_blocking_section ();
961 ocaml_guestfs_raise_error (g, "aug_defnode");
963 rv = caml_alloc (2, 0);
964 Store_field (rv, 0, Val_int (r->i));
965 Store_field (rv, 1, Val_bool (r->b));
966 guestfs_free_int_bool (r);
971 ocaml_guestfs_aug_get (value gv, value pathv)
973 CAMLparam2 (gv, pathv);
976 guestfs_h *g = Guestfs_val (gv);
978 caml_failwith ("aug_get: used handle after closing it");
980 const char *path = String_val (pathv);
983 caml_enter_blocking_section ();
984 r = guestfs_aug_get (g, path);
985 caml_leave_blocking_section ();
987 ocaml_guestfs_raise_error (g, "aug_get");
989 rv = caml_copy_string (r);
995 ocaml_guestfs_aug_set (value gv, value pathv, value valv)
997 CAMLparam3 (gv, pathv, valv);
1000 guestfs_h *g = Guestfs_val (gv);
1002 caml_failwith ("aug_set: used handle after closing it");
1004 const char *path = String_val (pathv);
1005 const char *val = String_val (valv);
1008 caml_enter_blocking_section ();
1009 r = guestfs_aug_set (g, path, val);
1010 caml_leave_blocking_section ();
1012 ocaml_guestfs_raise_error (g, "aug_set");
1019 ocaml_guestfs_aug_insert (value gv, value pathv, value labelv, value beforev)
1021 CAMLparam4 (gv, pathv, labelv, beforev);
1024 guestfs_h *g = Guestfs_val (gv);
1026 caml_failwith ("aug_insert: used handle after closing it");
1028 const char *path = String_val (pathv);
1029 const char *label = String_val (labelv);
1030 int before = Bool_val (beforev);
1033 caml_enter_blocking_section ();
1034 r = guestfs_aug_insert (g, path, label, before);
1035 caml_leave_blocking_section ();
1037 ocaml_guestfs_raise_error (g, "aug_insert");
1044 ocaml_guestfs_aug_rm (value gv, value pathv)
1046 CAMLparam2 (gv, pathv);
1049 guestfs_h *g = Guestfs_val (gv);
1051 caml_failwith ("aug_rm: used handle after closing it");
1053 const char *path = String_val (pathv);
1056 caml_enter_blocking_section ();
1057 r = guestfs_aug_rm (g, path);
1058 caml_leave_blocking_section ();
1060 ocaml_guestfs_raise_error (g, "aug_rm");
1067 ocaml_guestfs_aug_mv (value gv, value srcv, value destv)
1069 CAMLparam3 (gv, srcv, destv);
1072 guestfs_h *g = Guestfs_val (gv);
1074 caml_failwith ("aug_mv: used handle after closing it");
1076 const char *src = String_val (srcv);
1077 const char *dest = String_val (destv);
1080 caml_enter_blocking_section ();
1081 r = guestfs_aug_mv (g, src, dest);
1082 caml_leave_blocking_section ();
1084 ocaml_guestfs_raise_error (g, "aug_mv");
1091 ocaml_guestfs_aug_match (value gv, value pathv)
1093 CAMLparam2 (gv, pathv);
1096 guestfs_h *g = Guestfs_val (gv);
1098 caml_failwith ("aug_match: used handle after closing it");
1100 const char *path = String_val (pathv);
1104 caml_enter_blocking_section ();
1105 r = guestfs_aug_match (g, path);
1106 caml_leave_blocking_section ();
1108 ocaml_guestfs_raise_error (g, "aug_match");
1110 rv = caml_copy_string_array ((const char **) r);
1111 for (i = 0; r[i] != NULL; ++i) free (r[i]);
1117 ocaml_guestfs_aug_save (value gv)
1122 guestfs_h *g = Guestfs_val (gv);
1124 caml_failwith ("aug_save: used handle after closing it");
1128 caml_enter_blocking_section ();
1129 r = guestfs_aug_save (g);
1130 caml_leave_blocking_section ();
1132 ocaml_guestfs_raise_error (g, "aug_save");
1139 ocaml_guestfs_aug_load (value gv)
1144 guestfs_h *g = Guestfs_val (gv);
1146 caml_failwith ("aug_load: used handle after closing it");
1150 caml_enter_blocking_section ();
1151 r = guestfs_aug_load (g);
1152 caml_leave_blocking_section ();
1154 ocaml_guestfs_raise_error (g, "aug_load");
1161 ocaml_guestfs_aug_ls (value gv, value pathv)
1163 CAMLparam2 (gv, pathv);
1166 guestfs_h *g = Guestfs_val (gv);
1168 caml_failwith ("aug_ls: used handle after closing it");
1170 const char *path = String_val (pathv);
1174 caml_enter_blocking_section ();
1175 r = guestfs_aug_ls (g, path);
1176 caml_leave_blocking_section ();
1178 ocaml_guestfs_raise_error (g, "aug_ls");
1180 rv = caml_copy_string_array ((const char **) r);
1181 for (i = 0; r[i] != NULL; ++i) free (r[i]);
1187 ocaml_guestfs_rm (value gv, value pathv)
1189 CAMLparam2 (gv, pathv);
1192 guestfs_h *g = Guestfs_val (gv);
1194 caml_failwith ("rm: used handle after closing it");
1196 const char *path = String_val (pathv);
1199 caml_enter_blocking_section ();
1200 r = guestfs_rm (g, path);
1201 caml_leave_blocking_section ();
1203 ocaml_guestfs_raise_error (g, "rm");
1210 ocaml_guestfs_rmdir (value gv, value pathv)
1212 CAMLparam2 (gv, pathv);
1215 guestfs_h *g = Guestfs_val (gv);
1217 caml_failwith ("rmdir: used handle after closing it");
1219 const char *path = String_val (pathv);
1222 caml_enter_blocking_section ();
1223 r = guestfs_rmdir (g, path);
1224 caml_leave_blocking_section ();
1226 ocaml_guestfs_raise_error (g, "rmdir");
1233 ocaml_guestfs_rm_rf (value gv, value pathv)
1235 CAMLparam2 (gv, pathv);
1238 guestfs_h *g = Guestfs_val (gv);
1240 caml_failwith ("rm_rf: used handle after closing it");
1242 const char *path = String_val (pathv);
1245 caml_enter_blocking_section ();
1246 r = guestfs_rm_rf (g, path);
1247 caml_leave_blocking_section ();
1249 ocaml_guestfs_raise_error (g, "rm_rf");
1256 ocaml_guestfs_mkdir (value gv, value pathv)
1258 CAMLparam2 (gv, pathv);
1261 guestfs_h *g = Guestfs_val (gv);
1263 caml_failwith ("mkdir: used handle after closing it");
1265 const char *path = String_val (pathv);
1268 caml_enter_blocking_section ();
1269 r = guestfs_mkdir (g, path);
1270 caml_leave_blocking_section ();
1272 ocaml_guestfs_raise_error (g, "mkdir");
1279 ocaml_guestfs_mkdir_p (value gv, value pathv)
1281 CAMLparam2 (gv, pathv);
1284 guestfs_h *g = Guestfs_val (gv);
1286 caml_failwith ("mkdir_p: used handle after closing it");
1288 const char *path = String_val (pathv);
1291 caml_enter_blocking_section ();
1292 r = guestfs_mkdir_p (g, path);
1293 caml_leave_blocking_section ();
1295 ocaml_guestfs_raise_error (g, "mkdir_p");
1302 ocaml_guestfs_chmod (value gv, value modev, value pathv)
1304 CAMLparam3 (gv, modev, pathv);
1307 guestfs_h *g = Guestfs_val (gv);
1309 caml_failwith ("chmod: used handle after closing it");
1311 int mode = Int_val (modev);
1312 const char *path = String_val (pathv);
1315 caml_enter_blocking_section ();
1316 r = guestfs_chmod (g, mode, path);
1317 caml_leave_blocking_section ();
1319 ocaml_guestfs_raise_error (g, "chmod");
1326 ocaml_guestfs_chown (value gv, value ownerv, value groupv, value pathv)
1328 CAMLparam4 (gv, ownerv, groupv, pathv);
1331 guestfs_h *g = Guestfs_val (gv);
1333 caml_failwith ("chown: used handle after closing it");
1335 int owner = Int_val (ownerv);
1336 int group = Int_val (groupv);
1337 const char *path = String_val (pathv);
1340 caml_enter_blocking_section ();
1341 r = guestfs_chown (g, owner, group, path);
1342 caml_leave_blocking_section ();
1344 ocaml_guestfs_raise_error (g, "chown");
1351 ocaml_guestfs_exists (value gv, value pathv)
1353 CAMLparam2 (gv, pathv);
1356 guestfs_h *g = Guestfs_val (gv);
1358 caml_failwith ("exists: used handle after closing it");
1360 const char *path = String_val (pathv);
1363 caml_enter_blocking_section ();
1364 r = guestfs_exists (g, path);
1365 caml_leave_blocking_section ();
1367 ocaml_guestfs_raise_error (g, "exists");
1374 ocaml_guestfs_is_file (value gv, value pathv)
1376 CAMLparam2 (gv, pathv);
1379 guestfs_h *g = Guestfs_val (gv);
1381 caml_failwith ("is_file: used handle after closing it");
1383 const char *path = String_val (pathv);
1386 caml_enter_blocking_section ();
1387 r = guestfs_is_file (g, path);
1388 caml_leave_blocking_section ();
1390 ocaml_guestfs_raise_error (g, "is_file");
1397 ocaml_guestfs_is_dir (value gv, value pathv)
1399 CAMLparam2 (gv, pathv);
1402 guestfs_h *g = Guestfs_val (gv);
1404 caml_failwith ("is_dir: used handle after closing it");
1406 const char *path = String_val (pathv);
1409 caml_enter_blocking_section ();
1410 r = guestfs_is_dir (g, path);
1411 caml_leave_blocking_section ();
1413 ocaml_guestfs_raise_error (g, "is_dir");
1420 ocaml_guestfs_pvcreate (value gv, value devicev)
1422 CAMLparam2 (gv, devicev);
1425 guestfs_h *g = Guestfs_val (gv);
1427 caml_failwith ("pvcreate: used handle after closing it");
1429 const char *device = String_val (devicev);
1432 caml_enter_blocking_section ();
1433 r = guestfs_pvcreate (g, device);
1434 caml_leave_blocking_section ();
1436 ocaml_guestfs_raise_error (g, "pvcreate");
1443 ocaml_guestfs_vgcreate (value gv, value volgroupv, value physvolsv)
1445 CAMLparam3 (gv, volgroupv, physvolsv);
1448 guestfs_h *g = Guestfs_val (gv);
1450 caml_failwith ("vgcreate: used handle after closing it");
1452 const char *volgroup = String_val (volgroupv);
1453 char **physvols = ocaml_guestfs_strings_val (physvolsv);
1456 caml_enter_blocking_section ();
1457 r = guestfs_vgcreate (g, volgroup, physvols);
1458 caml_leave_blocking_section ();
1459 ocaml_guestfs_free_strings (physvols);
1461 ocaml_guestfs_raise_error (g, "vgcreate");
1468 ocaml_guestfs_lvcreate (value gv, value logvolv, value volgroupv, value mbytesv)
1470 CAMLparam4 (gv, logvolv, volgroupv, mbytesv);
1473 guestfs_h *g = Guestfs_val (gv);
1475 caml_failwith ("lvcreate: used handle after closing it");
1477 const char *logvol = String_val (logvolv);
1478 const char *volgroup = String_val (volgroupv);
1479 int mbytes = Int_val (mbytesv);
1482 caml_enter_blocking_section ();
1483 r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
1484 caml_leave_blocking_section ();
1486 ocaml_guestfs_raise_error (g, "lvcreate");
1493 ocaml_guestfs_mkfs (value gv, value fstypev, value devicev)
1495 CAMLparam3 (gv, fstypev, devicev);
1498 guestfs_h *g = Guestfs_val (gv);
1500 caml_failwith ("mkfs: used handle after closing it");
1502 const char *fstype = String_val (fstypev);
1503 const char *device = String_val (devicev);
1506 caml_enter_blocking_section ();
1507 r = guestfs_mkfs (g, fstype, device);
1508 caml_leave_blocking_section ();
1510 ocaml_guestfs_raise_error (g, "mkfs");
1517 ocaml_guestfs_sfdisk (value gv, value devicev, value cylsv, value headsv, value sectorsv, value linesv)
1519 CAMLparam5 (gv, devicev, cylsv, headsv, sectorsv);
1520 CAMLxparam1 (linesv);
1523 guestfs_h *g = Guestfs_val (gv);
1525 caml_failwith ("sfdisk: used handle after closing it");
1527 const char *device = String_val (devicev);
1528 int cyls = Int_val (cylsv);
1529 int heads = Int_val (headsv);
1530 int sectors = Int_val (sectorsv);
1531 char **lines = ocaml_guestfs_strings_val (linesv);
1534 caml_enter_blocking_section ();
1535 r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
1536 caml_leave_blocking_section ();
1537 ocaml_guestfs_free_strings (lines);
1539 ocaml_guestfs_raise_error (g, "sfdisk");
1546 ocaml_guestfs_sfdisk_byte (value *argv, int argn)
1548 return ocaml_guestfs_sfdisk (argv[0], argv[0], argv[1], argv[2], argv[3], argv[4]);
1552 ocaml_guestfs_write_file (value gv, value pathv, value contentv, value sizev)
1554 CAMLparam4 (gv, pathv, contentv, sizev);
1557 guestfs_h *g = Guestfs_val (gv);
1559 caml_failwith ("write_file: used handle after closing it");
1561 const char *path = String_val (pathv);
1562 const char *content = String_val (contentv);
1563 int size = Int_val (sizev);
1566 caml_enter_blocking_section ();
1567 r = guestfs_write_file (g, path, content, size);
1568 caml_leave_blocking_section ();
1570 ocaml_guestfs_raise_error (g, "write_file");
1577 ocaml_guestfs_umount (value gv, value pathordevicev)
1579 CAMLparam2 (gv, pathordevicev);
1582 guestfs_h *g = Guestfs_val (gv);
1584 caml_failwith ("umount: used handle after closing it");
1586 const char *pathordevice = String_val (pathordevicev);
1589 caml_enter_blocking_section ();
1590 r = guestfs_umount (g, pathordevice);
1591 caml_leave_blocking_section ();
1593 ocaml_guestfs_raise_error (g, "umount");
1600 ocaml_guestfs_mounts (value gv)
1605 guestfs_h *g = Guestfs_val (gv);
1607 caml_failwith ("mounts: used handle after closing it");
1612 caml_enter_blocking_section ();
1613 r = guestfs_mounts (g);
1614 caml_leave_blocking_section ();
1616 ocaml_guestfs_raise_error (g, "mounts");
1618 rv = caml_copy_string_array ((const char **) r);
1619 for (i = 0; r[i] != NULL; ++i) free (r[i]);
1625 ocaml_guestfs_umount_all (value gv)
1630 guestfs_h *g = Guestfs_val (gv);
1632 caml_failwith ("umount_all: used handle after closing it");
1636 caml_enter_blocking_section ();
1637 r = guestfs_umount_all (g);
1638 caml_leave_blocking_section ();
1640 ocaml_guestfs_raise_error (g, "umount_all");
1647 ocaml_guestfs_lvm_remove_all (value gv)
1652 guestfs_h *g = Guestfs_val (gv);
1654 caml_failwith ("lvm_remove_all: used handle after closing it");
1658 caml_enter_blocking_section ();
1659 r = guestfs_lvm_remove_all (g);
1660 caml_leave_blocking_section ();
1662 ocaml_guestfs_raise_error (g, "lvm_remove_all");
1669 ocaml_guestfs_file (value gv, value pathv)
1671 CAMLparam2 (gv, pathv);
1674 guestfs_h *g = Guestfs_val (gv);
1676 caml_failwith ("file: used handle after closing it");
1678 const char *path = String_val (pathv);
1681 caml_enter_blocking_section ();
1682 r = guestfs_file (g, path);
1683 caml_leave_blocking_section ();
1685 ocaml_guestfs_raise_error (g, "file");
1687 rv = caml_copy_string (r);