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");
459 rv = r ? Val_true : Val_false;
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");
504 rv = r ? Val_true : Val_false;
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);