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);
236 static CAMLprim value
237 copy_stat (const struct guestfs_stat *stat)
242 rv = caml_alloc (13, 0);
243 v = caml_copy_int64 (stat->dev);
244 Store_field (rv, 0, v);
245 v = caml_copy_int64 (stat->ino);
246 Store_field (rv, 1, v);
247 v = caml_copy_int64 (stat->mode);
248 Store_field (rv, 2, v);
249 v = caml_copy_int64 (stat->nlink);
250 Store_field (rv, 3, v);
251 v = caml_copy_int64 (stat->uid);
252 Store_field (rv, 4, v);
253 v = caml_copy_int64 (stat->gid);
254 Store_field (rv, 5, v);
255 v = caml_copy_int64 (stat->rdev);
256 Store_field (rv, 6, v);
257 v = caml_copy_int64 (stat->size);
258 Store_field (rv, 7, v);
259 v = caml_copy_int64 (stat->blksize);
260 Store_field (rv, 8, v);
261 v = caml_copy_int64 (stat->blocks);
262 Store_field (rv, 9, v);
263 v = caml_copy_int64 (stat->atime);
264 Store_field (rv, 10, v);
265 v = caml_copy_int64 (stat->mtime);
266 Store_field (rv, 11, v);
267 v = caml_copy_int64 (stat->ctime);
268 Store_field (rv, 12, v);
272 static CAMLprim value
273 copy_statvfs (const struct guestfs_statvfs *statvfs)
278 rv = caml_alloc (11, 0);
279 v = caml_copy_int64 (statvfs->bsize);
280 Store_field (rv, 0, v);
281 v = caml_copy_int64 (statvfs->frsize);
282 Store_field (rv, 1, v);
283 v = caml_copy_int64 (statvfs->blocks);
284 Store_field (rv, 2, v);
285 v = caml_copy_int64 (statvfs->bfree);
286 Store_field (rv, 3, v);
287 v = caml_copy_int64 (statvfs->bavail);
288 Store_field (rv, 4, v);
289 v = caml_copy_int64 (statvfs->files);
290 Store_field (rv, 5, v);
291 v = caml_copy_int64 (statvfs->ffree);
292 Store_field (rv, 6, v);
293 v = caml_copy_int64 (statvfs->favail);
294 Store_field (rv, 7, v);
295 v = caml_copy_int64 (statvfs->fsid);
296 Store_field (rv, 8, v);
297 v = caml_copy_int64 (statvfs->flag);
298 Store_field (rv, 9, v);
299 v = caml_copy_int64 (statvfs->namemax);
300 Store_field (rv, 10, v);
305 ocaml_guestfs_launch (value gv)
310 guestfs_h *g = Guestfs_val (gv);
312 caml_failwith ("launch: used handle after closing it");
316 caml_enter_blocking_section ();
317 r = guestfs_launch (g);
318 caml_leave_blocking_section ();
320 ocaml_guestfs_raise_error (g, "launch");
327 ocaml_guestfs_wait_ready (value gv)
332 guestfs_h *g = Guestfs_val (gv);
334 caml_failwith ("wait_ready: used handle after closing it");
338 caml_enter_blocking_section ();
339 r = guestfs_wait_ready (g);
340 caml_leave_blocking_section ();
342 ocaml_guestfs_raise_error (g, "wait_ready");
349 ocaml_guestfs_kill_subprocess (value gv)
354 guestfs_h *g = Guestfs_val (gv);
356 caml_failwith ("kill_subprocess: used handle after closing it");
360 caml_enter_blocking_section ();
361 r = guestfs_kill_subprocess (g);
362 caml_leave_blocking_section ();
364 ocaml_guestfs_raise_error (g, "kill_subprocess");
371 ocaml_guestfs_add_drive (value gv, value filenamev)
373 CAMLparam2 (gv, filenamev);
376 guestfs_h *g = Guestfs_val (gv);
378 caml_failwith ("add_drive: used handle after closing it");
380 const char *filename = String_val (filenamev);
383 caml_enter_blocking_section ();
384 r = guestfs_add_drive (g, filename);
385 caml_leave_blocking_section ();
387 ocaml_guestfs_raise_error (g, "add_drive");
394 ocaml_guestfs_add_cdrom (value gv, value filenamev)
396 CAMLparam2 (gv, filenamev);
399 guestfs_h *g = Guestfs_val (gv);
401 caml_failwith ("add_cdrom: used handle after closing it");
403 const char *filename = String_val (filenamev);
406 caml_enter_blocking_section ();
407 r = guestfs_add_cdrom (g, filename);
408 caml_leave_blocking_section ();
410 ocaml_guestfs_raise_error (g, "add_cdrom");
417 ocaml_guestfs_config (value gv, value qemuparamv, value qemuvaluev)
419 CAMLparam3 (gv, qemuparamv, qemuvaluev);
422 guestfs_h *g = Guestfs_val (gv);
424 caml_failwith ("config: used handle after closing it");
426 const char *qemuparam = String_val (qemuparamv);
427 const char *qemuvalue =
428 qemuvaluev != Val_int (0) ? String_val (Field (qemuvaluev, 0)) : NULL;
431 caml_enter_blocking_section ();
432 r = guestfs_config (g, qemuparam, qemuvalue);
433 caml_leave_blocking_section ();
435 ocaml_guestfs_raise_error (g, "config");
442 ocaml_guestfs_set_path (value gv, value pathv)
444 CAMLparam2 (gv, pathv);
447 guestfs_h *g = Guestfs_val (gv);
449 caml_failwith ("set_path: used handle after closing it");
451 const char *path = String_val (pathv);
454 caml_enter_blocking_section ();
455 r = guestfs_set_path (g, path);
456 caml_leave_blocking_section ();
458 ocaml_guestfs_raise_error (g, "set_path");
465 ocaml_guestfs_get_path (value gv)
470 guestfs_h *g = Guestfs_val (gv);
472 caml_failwith ("get_path: used handle after closing it");
476 caml_enter_blocking_section ();
477 r = guestfs_get_path (g);
478 caml_leave_blocking_section ();
480 ocaml_guestfs_raise_error (g, "get_path");
482 rv = caml_copy_string (r);
487 ocaml_guestfs_set_autosync (value gv, value autosyncv)
489 CAMLparam2 (gv, autosyncv);
492 guestfs_h *g = Guestfs_val (gv);
494 caml_failwith ("set_autosync: used handle after closing it");
496 int autosync = Bool_val (autosyncv);
499 caml_enter_blocking_section ();
500 r = guestfs_set_autosync (g, autosync);
501 caml_leave_blocking_section ();
503 ocaml_guestfs_raise_error (g, "set_autosync");
510 ocaml_guestfs_get_autosync (value gv)
515 guestfs_h *g = Guestfs_val (gv);
517 caml_failwith ("get_autosync: used handle after closing it");
521 caml_enter_blocking_section ();
522 r = guestfs_get_autosync (g);
523 caml_leave_blocking_section ();
525 ocaml_guestfs_raise_error (g, "get_autosync");
532 ocaml_guestfs_set_verbose (value gv, value verbosev)
534 CAMLparam2 (gv, verbosev);
537 guestfs_h *g = Guestfs_val (gv);
539 caml_failwith ("set_verbose: used handle after closing it");
541 int verbose = Bool_val (verbosev);
544 caml_enter_blocking_section ();
545 r = guestfs_set_verbose (g, verbose);
546 caml_leave_blocking_section ();
548 ocaml_guestfs_raise_error (g, "set_verbose");
555 ocaml_guestfs_get_verbose (value gv)
560 guestfs_h *g = Guestfs_val (gv);
562 caml_failwith ("get_verbose: used handle after closing it");
566 caml_enter_blocking_section ();
567 r = guestfs_get_verbose (g);
568 caml_leave_blocking_section ();
570 ocaml_guestfs_raise_error (g, "get_verbose");
577 ocaml_guestfs_mount (value gv, value devicev, value mountpointv)
579 CAMLparam3 (gv, devicev, mountpointv);
582 guestfs_h *g = Guestfs_val (gv);
584 caml_failwith ("mount: used handle after closing it");
586 const char *device = String_val (devicev);
587 const char *mountpoint = String_val (mountpointv);
590 caml_enter_blocking_section ();
591 r = guestfs_mount (g, device, mountpoint);
592 caml_leave_blocking_section ();
594 ocaml_guestfs_raise_error (g, "mount");
601 ocaml_guestfs_sync (value gv)
606 guestfs_h *g = Guestfs_val (gv);
608 caml_failwith ("sync: used handle after closing it");
612 caml_enter_blocking_section ();
613 r = guestfs_sync (g);
614 caml_leave_blocking_section ();
616 ocaml_guestfs_raise_error (g, "sync");
623 ocaml_guestfs_touch (value gv, value pathv)
625 CAMLparam2 (gv, pathv);
628 guestfs_h *g = Guestfs_val (gv);
630 caml_failwith ("touch: used handle after closing it");
632 const char *path = String_val (pathv);
635 caml_enter_blocking_section ();
636 r = guestfs_touch (g, path);
637 caml_leave_blocking_section ();
639 ocaml_guestfs_raise_error (g, "touch");
646 ocaml_guestfs_cat (value gv, value pathv)
648 CAMLparam2 (gv, pathv);
651 guestfs_h *g = Guestfs_val (gv);
653 caml_failwith ("cat: used handle after closing it");
655 const char *path = String_val (pathv);
658 caml_enter_blocking_section ();
659 r = guestfs_cat (g, path);
660 caml_leave_blocking_section ();
662 ocaml_guestfs_raise_error (g, "cat");
664 rv = caml_copy_string (r);
670 ocaml_guestfs_ll (value gv, value directoryv)
672 CAMLparam2 (gv, directoryv);
675 guestfs_h *g = Guestfs_val (gv);
677 caml_failwith ("ll: used handle after closing it");
679 const char *directory = String_val (directoryv);
682 caml_enter_blocking_section ();
683 r = guestfs_ll (g, directory);
684 caml_leave_blocking_section ();
686 ocaml_guestfs_raise_error (g, "ll");
688 rv = caml_copy_string (r);
694 ocaml_guestfs_ls (value gv, value directoryv)
696 CAMLparam2 (gv, directoryv);
699 guestfs_h *g = Guestfs_val (gv);
701 caml_failwith ("ls: used handle after closing it");
703 const char *directory = String_val (directoryv);
707 caml_enter_blocking_section ();
708 r = guestfs_ls (g, directory);
709 caml_leave_blocking_section ();
711 ocaml_guestfs_raise_error (g, "ls");
713 rv = caml_copy_string_array ((const char **) r);
714 for (i = 0; r[i] != NULL; ++i) free (r[i]);
720 ocaml_guestfs_list_devices (value gv)
725 guestfs_h *g = Guestfs_val (gv);
727 caml_failwith ("list_devices: used handle after closing it");
732 caml_enter_blocking_section ();
733 r = guestfs_list_devices (g);
734 caml_leave_blocking_section ();
736 ocaml_guestfs_raise_error (g, "list_devices");
738 rv = caml_copy_string_array ((const char **) r);
739 for (i = 0; r[i] != NULL; ++i) free (r[i]);
745 ocaml_guestfs_list_partitions (value gv)
750 guestfs_h *g = Guestfs_val (gv);
752 caml_failwith ("list_partitions: used handle after closing it");
757 caml_enter_blocking_section ();
758 r = guestfs_list_partitions (g);
759 caml_leave_blocking_section ();
761 ocaml_guestfs_raise_error (g, "list_partitions");
763 rv = caml_copy_string_array ((const char **) r);
764 for (i = 0; r[i] != NULL; ++i) free (r[i]);
770 ocaml_guestfs_pvs (value gv)
775 guestfs_h *g = Guestfs_val (gv);
777 caml_failwith ("pvs: used handle after closing it");
782 caml_enter_blocking_section ();
784 caml_leave_blocking_section ();
786 ocaml_guestfs_raise_error (g, "pvs");
788 rv = caml_copy_string_array ((const char **) r);
789 for (i = 0; r[i] != NULL; ++i) free (r[i]);
795 ocaml_guestfs_vgs (value gv)
800 guestfs_h *g = Guestfs_val (gv);
802 caml_failwith ("vgs: used handle after closing it");
807 caml_enter_blocking_section ();
809 caml_leave_blocking_section ();
811 ocaml_guestfs_raise_error (g, "vgs");
813 rv = caml_copy_string_array ((const char **) r);
814 for (i = 0; r[i] != NULL; ++i) free (r[i]);
820 ocaml_guestfs_lvs (value gv)
825 guestfs_h *g = Guestfs_val (gv);
827 caml_failwith ("lvs: used handle after closing it");
832 caml_enter_blocking_section ();
834 caml_leave_blocking_section ();
836 ocaml_guestfs_raise_error (g, "lvs");
838 rv = caml_copy_string_array ((const char **) r);
839 for (i = 0; r[i] != NULL; ++i) free (r[i]);
845 ocaml_guestfs_pvs_full (value gv)
850 guestfs_h *g = Guestfs_val (gv);
852 caml_failwith ("pvs_full: used handle after closing it");
854 struct guestfs_lvm_pv_list *r;
856 caml_enter_blocking_section ();
857 r = guestfs_pvs_full (g);
858 caml_leave_blocking_section ();
860 ocaml_guestfs_raise_error (g, "pvs_full");
862 rv = copy_lvm_pv_list (r);
863 guestfs_free_lvm_pv_list (r);
868 ocaml_guestfs_vgs_full (value gv)
873 guestfs_h *g = Guestfs_val (gv);
875 caml_failwith ("vgs_full: used handle after closing it");
877 struct guestfs_lvm_vg_list *r;
879 caml_enter_blocking_section ();
880 r = guestfs_vgs_full (g);
881 caml_leave_blocking_section ();
883 ocaml_guestfs_raise_error (g, "vgs_full");
885 rv = copy_lvm_vg_list (r);
886 guestfs_free_lvm_vg_list (r);
891 ocaml_guestfs_lvs_full (value gv)
896 guestfs_h *g = Guestfs_val (gv);
898 caml_failwith ("lvs_full: used handle after closing it");
900 struct guestfs_lvm_lv_list *r;
902 caml_enter_blocking_section ();
903 r = guestfs_lvs_full (g);
904 caml_leave_blocking_section ();
906 ocaml_guestfs_raise_error (g, "lvs_full");
908 rv = copy_lvm_lv_list (r);
909 guestfs_free_lvm_lv_list (r);
914 ocaml_guestfs_read_lines (value gv, value pathv)
916 CAMLparam2 (gv, pathv);
919 guestfs_h *g = Guestfs_val (gv);
921 caml_failwith ("read_lines: used handle after closing it");
923 const char *path = String_val (pathv);
927 caml_enter_blocking_section ();
928 r = guestfs_read_lines (g, path);
929 caml_leave_blocking_section ();
931 ocaml_guestfs_raise_error (g, "read_lines");
933 rv = caml_copy_string_array ((const char **) r);
934 for (i = 0; r[i] != NULL; ++i) free (r[i]);
940 ocaml_guestfs_aug_init (value gv, value rootv, value flagsv)
942 CAMLparam3 (gv, rootv, flagsv);
945 guestfs_h *g = Guestfs_val (gv);
947 caml_failwith ("aug_init: used handle after closing it");
949 const char *root = String_val (rootv);
950 int flags = Int_val (flagsv);
953 caml_enter_blocking_section ();
954 r = guestfs_aug_init (g, root, flags);
955 caml_leave_blocking_section ();
957 ocaml_guestfs_raise_error (g, "aug_init");
964 ocaml_guestfs_aug_close (value gv)
969 guestfs_h *g = Guestfs_val (gv);
971 caml_failwith ("aug_close: used handle after closing it");
975 caml_enter_blocking_section ();
976 r = guestfs_aug_close (g);
977 caml_leave_blocking_section ();
979 ocaml_guestfs_raise_error (g, "aug_close");
986 ocaml_guestfs_aug_defvar (value gv, value namev, value exprv)
988 CAMLparam3 (gv, namev, exprv);
991 guestfs_h *g = Guestfs_val (gv);
993 caml_failwith ("aug_defvar: used handle after closing it");
995 const char *name = String_val (namev);
997 exprv != Val_int (0) ? String_val (Field (exprv, 0)) : NULL;
1000 caml_enter_blocking_section ();
1001 r = guestfs_aug_defvar (g, name, expr);
1002 caml_leave_blocking_section ();
1004 ocaml_guestfs_raise_error (g, "aug_defvar");
1011 ocaml_guestfs_aug_defnode (value gv, value namev, value exprv, value valv)
1013 CAMLparam4 (gv, namev, exprv, valv);
1016 guestfs_h *g = Guestfs_val (gv);
1018 caml_failwith ("aug_defnode: used handle after closing it");
1020 const char *name = String_val (namev);
1021 const char *expr = String_val (exprv);
1022 const char *val = String_val (valv);
1023 struct guestfs_int_bool *r;
1025 caml_enter_blocking_section ();
1026 r = guestfs_aug_defnode (g, name, expr, val);
1027 caml_leave_blocking_section ();
1029 ocaml_guestfs_raise_error (g, "aug_defnode");
1031 rv = caml_alloc (2, 0);
1032 Store_field (rv, 0, Val_int (r->i));
1033 Store_field (rv, 1, Val_bool (r->b));
1034 guestfs_free_int_bool (r);
1039 ocaml_guestfs_aug_get (value gv, value pathv)
1041 CAMLparam2 (gv, pathv);
1044 guestfs_h *g = Guestfs_val (gv);
1046 caml_failwith ("aug_get: used handle after closing it");
1048 const char *path = String_val (pathv);
1051 caml_enter_blocking_section ();
1052 r = guestfs_aug_get (g, path);
1053 caml_leave_blocking_section ();
1055 ocaml_guestfs_raise_error (g, "aug_get");
1057 rv = caml_copy_string (r);
1063 ocaml_guestfs_aug_set (value gv, value pathv, value valv)
1065 CAMLparam3 (gv, pathv, valv);
1068 guestfs_h *g = Guestfs_val (gv);
1070 caml_failwith ("aug_set: used handle after closing it");
1072 const char *path = String_val (pathv);
1073 const char *val = String_val (valv);
1076 caml_enter_blocking_section ();
1077 r = guestfs_aug_set (g, path, val);
1078 caml_leave_blocking_section ();
1080 ocaml_guestfs_raise_error (g, "aug_set");
1087 ocaml_guestfs_aug_insert (value gv, value pathv, value labelv, value beforev)
1089 CAMLparam4 (gv, pathv, labelv, beforev);
1092 guestfs_h *g = Guestfs_val (gv);
1094 caml_failwith ("aug_insert: used handle after closing it");
1096 const char *path = String_val (pathv);
1097 const char *label = String_val (labelv);
1098 int before = Bool_val (beforev);
1101 caml_enter_blocking_section ();
1102 r = guestfs_aug_insert (g, path, label, before);
1103 caml_leave_blocking_section ();
1105 ocaml_guestfs_raise_error (g, "aug_insert");
1112 ocaml_guestfs_aug_rm (value gv, value pathv)
1114 CAMLparam2 (gv, pathv);
1117 guestfs_h *g = Guestfs_val (gv);
1119 caml_failwith ("aug_rm: used handle after closing it");
1121 const char *path = String_val (pathv);
1124 caml_enter_blocking_section ();
1125 r = guestfs_aug_rm (g, path);
1126 caml_leave_blocking_section ();
1128 ocaml_guestfs_raise_error (g, "aug_rm");
1135 ocaml_guestfs_aug_mv (value gv, value srcv, value destv)
1137 CAMLparam3 (gv, srcv, destv);
1140 guestfs_h *g = Guestfs_val (gv);
1142 caml_failwith ("aug_mv: used handle after closing it");
1144 const char *src = String_val (srcv);
1145 const char *dest = String_val (destv);
1148 caml_enter_blocking_section ();
1149 r = guestfs_aug_mv (g, src, dest);
1150 caml_leave_blocking_section ();
1152 ocaml_guestfs_raise_error (g, "aug_mv");
1159 ocaml_guestfs_aug_match (value gv, value pathv)
1161 CAMLparam2 (gv, pathv);
1164 guestfs_h *g = Guestfs_val (gv);
1166 caml_failwith ("aug_match: used handle after closing it");
1168 const char *path = String_val (pathv);
1172 caml_enter_blocking_section ();
1173 r = guestfs_aug_match (g, path);
1174 caml_leave_blocking_section ();
1176 ocaml_guestfs_raise_error (g, "aug_match");
1178 rv = caml_copy_string_array ((const char **) r);
1179 for (i = 0; r[i] != NULL; ++i) free (r[i]);
1185 ocaml_guestfs_aug_save (value gv)
1190 guestfs_h *g = Guestfs_val (gv);
1192 caml_failwith ("aug_save: used handle after closing it");
1196 caml_enter_blocking_section ();
1197 r = guestfs_aug_save (g);
1198 caml_leave_blocking_section ();
1200 ocaml_guestfs_raise_error (g, "aug_save");
1207 ocaml_guestfs_aug_load (value gv)
1212 guestfs_h *g = Guestfs_val (gv);
1214 caml_failwith ("aug_load: used handle after closing it");
1218 caml_enter_blocking_section ();
1219 r = guestfs_aug_load (g);
1220 caml_leave_blocking_section ();
1222 ocaml_guestfs_raise_error (g, "aug_load");
1229 ocaml_guestfs_aug_ls (value gv, value pathv)
1231 CAMLparam2 (gv, pathv);
1234 guestfs_h *g = Guestfs_val (gv);
1236 caml_failwith ("aug_ls: used handle after closing it");
1238 const char *path = String_val (pathv);
1242 caml_enter_blocking_section ();
1243 r = guestfs_aug_ls (g, path);
1244 caml_leave_blocking_section ();
1246 ocaml_guestfs_raise_error (g, "aug_ls");
1248 rv = caml_copy_string_array ((const char **) r);
1249 for (i = 0; r[i] != NULL; ++i) free (r[i]);
1255 ocaml_guestfs_rm (value gv, value pathv)
1257 CAMLparam2 (gv, pathv);
1260 guestfs_h *g = Guestfs_val (gv);
1262 caml_failwith ("rm: used handle after closing it");
1264 const char *path = String_val (pathv);
1267 caml_enter_blocking_section ();
1268 r = guestfs_rm (g, path);
1269 caml_leave_blocking_section ();
1271 ocaml_guestfs_raise_error (g, "rm");
1278 ocaml_guestfs_rmdir (value gv, value pathv)
1280 CAMLparam2 (gv, pathv);
1283 guestfs_h *g = Guestfs_val (gv);
1285 caml_failwith ("rmdir: used handle after closing it");
1287 const char *path = String_val (pathv);
1290 caml_enter_blocking_section ();
1291 r = guestfs_rmdir (g, path);
1292 caml_leave_blocking_section ();
1294 ocaml_guestfs_raise_error (g, "rmdir");
1301 ocaml_guestfs_rm_rf (value gv, value pathv)
1303 CAMLparam2 (gv, pathv);
1306 guestfs_h *g = Guestfs_val (gv);
1308 caml_failwith ("rm_rf: used handle after closing it");
1310 const char *path = String_val (pathv);
1313 caml_enter_blocking_section ();
1314 r = guestfs_rm_rf (g, path);
1315 caml_leave_blocking_section ();
1317 ocaml_guestfs_raise_error (g, "rm_rf");
1324 ocaml_guestfs_mkdir (value gv, value pathv)
1326 CAMLparam2 (gv, pathv);
1329 guestfs_h *g = Guestfs_val (gv);
1331 caml_failwith ("mkdir: used handle after closing it");
1333 const char *path = String_val (pathv);
1336 caml_enter_blocking_section ();
1337 r = guestfs_mkdir (g, path);
1338 caml_leave_blocking_section ();
1340 ocaml_guestfs_raise_error (g, "mkdir");
1347 ocaml_guestfs_mkdir_p (value gv, value pathv)
1349 CAMLparam2 (gv, pathv);
1352 guestfs_h *g = Guestfs_val (gv);
1354 caml_failwith ("mkdir_p: used handle after closing it");
1356 const char *path = String_val (pathv);
1359 caml_enter_blocking_section ();
1360 r = guestfs_mkdir_p (g, path);
1361 caml_leave_blocking_section ();
1363 ocaml_guestfs_raise_error (g, "mkdir_p");
1370 ocaml_guestfs_chmod (value gv, value modev, value pathv)
1372 CAMLparam3 (gv, modev, pathv);
1375 guestfs_h *g = Guestfs_val (gv);
1377 caml_failwith ("chmod: used handle after closing it");
1379 int mode = Int_val (modev);
1380 const char *path = String_val (pathv);
1383 caml_enter_blocking_section ();
1384 r = guestfs_chmod (g, mode, path);
1385 caml_leave_blocking_section ();
1387 ocaml_guestfs_raise_error (g, "chmod");
1394 ocaml_guestfs_chown (value gv, value ownerv, value groupv, value pathv)
1396 CAMLparam4 (gv, ownerv, groupv, pathv);
1399 guestfs_h *g = Guestfs_val (gv);
1401 caml_failwith ("chown: used handle after closing it");
1403 int owner = Int_val (ownerv);
1404 int group = Int_val (groupv);
1405 const char *path = String_val (pathv);
1408 caml_enter_blocking_section ();
1409 r = guestfs_chown (g, owner, group, path);
1410 caml_leave_blocking_section ();
1412 ocaml_guestfs_raise_error (g, "chown");
1419 ocaml_guestfs_exists (value gv, value pathv)
1421 CAMLparam2 (gv, pathv);
1424 guestfs_h *g = Guestfs_val (gv);
1426 caml_failwith ("exists: used handle after closing it");
1428 const char *path = String_val (pathv);
1431 caml_enter_blocking_section ();
1432 r = guestfs_exists (g, path);
1433 caml_leave_blocking_section ();
1435 ocaml_guestfs_raise_error (g, "exists");
1442 ocaml_guestfs_is_file (value gv, value pathv)
1444 CAMLparam2 (gv, pathv);
1447 guestfs_h *g = Guestfs_val (gv);
1449 caml_failwith ("is_file: used handle after closing it");
1451 const char *path = String_val (pathv);
1454 caml_enter_blocking_section ();
1455 r = guestfs_is_file (g, path);
1456 caml_leave_blocking_section ();
1458 ocaml_guestfs_raise_error (g, "is_file");
1465 ocaml_guestfs_is_dir (value gv, value pathv)
1467 CAMLparam2 (gv, pathv);
1470 guestfs_h *g = Guestfs_val (gv);
1472 caml_failwith ("is_dir: used handle after closing it");
1474 const char *path = String_val (pathv);
1477 caml_enter_blocking_section ();
1478 r = guestfs_is_dir (g, path);
1479 caml_leave_blocking_section ();
1481 ocaml_guestfs_raise_error (g, "is_dir");
1488 ocaml_guestfs_pvcreate (value gv, value devicev)
1490 CAMLparam2 (gv, devicev);
1493 guestfs_h *g = Guestfs_val (gv);
1495 caml_failwith ("pvcreate: used handle after closing it");
1497 const char *device = String_val (devicev);
1500 caml_enter_blocking_section ();
1501 r = guestfs_pvcreate (g, device);
1502 caml_leave_blocking_section ();
1504 ocaml_guestfs_raise_error (g, "pvcreate");
1511 ocaml_guestfs_vgcreate (value gv, value volgroupv, value physvolsv)
1513 CAMLparam3 (gv, volgroupv, physvolsv);
1516 guestfs_h *g = Guestfs_val (gv);
1518 caml_failwith ("vgcreate: used handle after closing it");
1520 const char *volgroup = String_val (volgroupv);
1521 char **physvols = ocaml_guestfs_strings_val (physvolsv);
1524 caml_enter_blocking_section ();
1525 r = guestfs_vgcreate (g, volgroup, physvols);
1526 caml_leave_blocking_section ();
1527 ocaml_guestfs_free_strings (physvols);
1529 ocaml_guestfs_raise_error (g, "vgcreate");
1536 ocaml_guestfs_lvcreate (value gv, value logvolv, value volgroupv, value mbytesv)
1538 CAMLparam4 (gv, logvolv, volgroupv, mbytesv);
1541 guestfs_h *g = Guestfs_val (gv);
1543 caml_failwith ("lvcreate: used handle after closing it");
1545 const char *logvol = String_val (logvolv);
1546 const char *volgroup = String_val (volgroupv);
1547 int mbytes = Int_val (mbytesv);
1550 caml_enter_blocking_section ();
1551 r = guestfs_lvcreate (g, logvol, volgroup, mbytes);
1552 caml_leave_blocking_section ();
1554 ocaml_guestfs_raise_error (g, "lvcreate");
1561 ocaml_guestfs_mkfs (value gv, value fstypev, value devicev)
1563 CAMLparam3 (gv, fstypev, devicev);
1566 guestfs_h *g = Guestfs_val (gv);
1568 caml_failwith ("mkfs: used handle after closing it");
1570 const char *fstype = String_val (fstypev);
1571 const char *device = String_val (devicev);
1574 caml_enter_blocking_section ();
1575 r = guestfs_mkfs (g, fstype, device);
1576 caml_leave_blocking_section ();
1578 ocaml_guestfs_raise_error (g, "mkfs");
1585 ocaml_guestfs_sfdisk (value gv, value devicev, value cylsv, value headsv, value sectorsv, value linesv)
1587 CAMLparam5 (gv, devicev, cylsv, headsv, sectorsv);
1588 CAMLxparam1 (linesv);
1591 guestfs_h *g = Guestfs_val (gv);
1593 caml_failwith ("sfdisk: used handle after closing it");
1595 const char *device = String_val (devicev);
1596 int cyls = Int_val (cylsv);
1597 int heads = Int_val (headsv);
1598 int sectors = Int_val (sectorsv);
1599 char **lines = ocaml_guestfs_strings_val (linesv);
1602 caml_enter_blocking_section ();
1603 r = guestfs_sfdisk (g, device, cyls, heads, sectors, lines);
1604 caml_leave_blocking_section ();
1605 ocaml_guestfs_free_strings (lines);
1607 ocaml_guestfs_raise_error (g, "sfdisk");
1614 ocaml_guestfs_sfdisk_byte (value *argv, int argn)
1616 return ocaml_guestfs_sfdisk (argv[0], argv[0], argv[1], argv[2], argv[3], argv[4]);
1620 ocaml_guestfs_write_file (value gv, value pathv, value contentv, value sizev)
1622 CAMLparam4 (gv, pathv, contentv, sizev);
1625 guestfs_h *g = Guestfs_val (gv);
1627 caml_failwith ("write_file: used handle after closing it");
1629 const char *path = String_val (pathv);
1630 const char *content = String_val (contentv);
1631 int size = Int_val (sizev);
1634 caml_enter_blocking_section ();
1635 r = guestfs_write_file (g, path, content, size);
1636 caml_leave_blocking_section ();
1638 ocaml_guestfs_raise_error (g, "write_file");
1645 ocaml_guestfs_umount (value gv, value pathordevicev)
1647 CAMLparam2 (gv, pathordevicev);
1650 guestfs_h *g = Guestfs_val (gv);
1652 caml_failwith ("umount: used handle after closing it");
1654 const char *pathordevice = String_val (pathordevicev);
1657 caml_enter_blocking_section ();
1658 r = guestfs_umount (g, pathordevice);
1659 caml_leave_blocking_section ();
1661 ocaml_guestfs_raise_error (g, "umount");
1668 ocaml_guestfs_mounts (value gv)
1673 guestfs_h *g = Guestfs_val (gv);
1675 caml_failwith ("mounts: used handle after closing it");
1680 caml_enter_blocking_section ();
1681 r = guestfs_mounts (g);
1682 caml_leave_blocking_section ();
1684 ocaml_guestfs_raise_error (g, "mounts");
1686 rv = caml_copy_string_array ((const char **) r);
1687 for (i = 0; r[i] != NULL; ++i) free (r[i]);
1693 ocaml_guestfs_umount_all (value gv)
1698 guestfs_h *g = Guestfs_val (gv);
1700 caml_failwith ("umount_all: used handle after closing it");
1704 caml_enter_blocking_section ();
1705 r = guestfs_umount_all (g);
1706 caml_leave_blocking_section ();
1708 ocaml_guestfs_raise_error (g, "umount_all");
1715 ocaml_guestfs_lvm_remove_all (value gv)
1720 guestfs_h *g = Guestfs_val (gv);
1722 caml_failwith ("lvm_remove_all: used handle after closing it");
1726 caml_enter_blocking_section ();
1727 r = guestfs_lvm_remove_all (g);
1728 caml_leave_blocking_section ();
1730 ocaml_guestfs_raise_error (g, "lvm_remove_all");
1737 ocaml_guestfs_file (value gv, value pathv)
1739 CAMLparam2 (gv, pathv);
1742 guestfs_h *g = Guestfs_val (gv);
1744 caml_failwith ("file: used handle after closing it");
1746 const char *path = String_val (pathv);
1749 caml_enter_blocking_section ();
1750 r = guestfs_file (g, path);
1751 caml_leave_blocking_section ();
1753 ocaml_guestfs_raise_error (g, "file");
1755 rv = caml_copy_string (r);
1761 ocaml_guestfs_command (value gv, value argumentsv)
1763 CAMLparam2 (gv, argumentsv);
1766 guestfs_h *g = Guestfs_val (gv);
1768 caml_failwith ("command: used handle after closing it");
1770 char **arguments = ocaml_guestfs_strings_val (argumentsv);
1773 caml_enter_blocking_section ();
1774 r = guestfs_command (g, arguments);
1775 caml_leave_blocking_section ();
1776 ocaml_guestfs_free_strings (arguments);
1778 ocaml_guestfs_raise_error (g, "command");
1780 rv = caml_copy_string (r);
1786 ocaml_guestfs_command_lines (value gv, value argumentsv)
1788 CAMLparam2 (gv, argumentsv);
1791 guestfs_h *g = Guestfs_val (gv);
1793 caml_failwith ("command_lines: used handle after closing it");
1795 char **arguments = ocaml_guestfs_strings_val (argumentsv);
1799 caml_enter_blocking_section ();
1800 r = guestfs_command_lines (g, arguments);
1801 caml_leave_blocking_section ();
1802 ocaml_guestfs_free_strings (arguments);
1804 ocaml_guestfs_raise_error (g, "command_lines");
1806 rv = caml_copy_string_array ((const char **) r);
1807 for (i = 0; r[i] != NULL; ++i) free (r[i]);
1813 ocaml_guestfs_stat (value gv, value pathv)
1815 CAMLparam2 (gv, pathv);
1818 guestfs_h *g = Guestfs_val (gv);
1820 caml_failwith ("stat: used handle after closing it");
1822 const char *path = String_val (pathv);
1823 struct guestfs_stat *r;
1825 caml_enter_blocking_section ();
1826 r = guestfs_stat (g, path);
1827 caml_leave_blocking_section ();
1829 ocaml_guestfs_raise_error (g, "stat");
1837 ocaml_guestfs_lstat (value gv, value pathv)
1839 CAMLparam2 (gv, pathv);
1842 guestfs_h *g = Guestfs_val (gv);
1844 caml_failwith ("lstat: used handle after closing it");
1846 const char *path = String_val (pathv);
1847 struct guestfs_stat *r;
1849 caml_enter_blocking_section ();
1850 r = guestfs_lstat (g, path);
1851 caml_leave_blocking_section ();
1853 ocaml_guestfs_raise_error (g, "lstat");
1861 ocaml_guestfs_statvfs (value gv, value pathv)
1863 CAMLparam2 (gv, pathv);
1866 guestfs_h *g = Guestfs_val (gv);
1868 caml_failwith ("statvfs: used handle after closing it");
1870 const char *path = String_val (pathv);
1871 struct guestfs_statvfs *r;
1873 caml_enter_blocking_section ();
1874 r = guestfs_statvfs (g, path);
1875 caml_leave_blocking_section ();
1877 ocaml_guestfs_raise_error (g, "statvfs");
1879 rv = copy_statvfs (r);