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
24 struct guestfs_message_header hdr;
25 struct guestfs_message_error err;
28 static void mount_cb (guestfs_h *g, void *data, XDR *xdr)
30 struct mount_state *state = (struct mount_state *) data;
32 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
33 error (g, "guestfs_mount: failed to parse reply header");
36 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
37 if (!xdr_guestfs_message_error (xdr, &state->err)) {
38 error (g, "guestfs_mount: failed to parse reply error");
45 g->main_loop->main_loop_quit (g->main_loop, g);
48 int guestfs_mount (guestfs_h *g,
50 const char *mountpoint)
52 struct guestfs_mount_args args;
53 struct mount_state state;
56 if (g->state != READY) {
57 if (g->state == CONFIG)
58 error (g, "%s: call launch() before using this function",
60 else if (g->state == LAUNCHING)
61 error (g, "%s: call wait_ready() before using this function",
64 error (g, "%s called from the wrong state, %d != READY",
65 "guestfs_mount", g->state);
69 memset (&state, 0, sizeof state);
71 args.device = (char *) device;
72 args.mountpoint = (char *) mountpoint;
73 serial = dispatch (g, GUESTFS_PROC_MOUNT,
74 (xdrproc_t) xdr_guestfs_mount_args, (char *) &args);
79 g->reply_cb_internal = mount_cb;
80 g->reply_cb_internal_data = &state;
81 (void) g->main_loop->main_loop_run (g->main_loop, g);
82 g->reply_cb_internal = NULL;
83 g->reply_cb_internal_data = NULL;
85 error (g, "guestfs_mount failed, see earlier error messages");
89 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_MOUNT, serial) == -1)
92 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
93 error (g, "%s", state.err.error);
102 struct guestfs_message_header hdr;
103 struct guestfs_message_error err;
106 static void sync_cb (guestfs_h *g, void *data, XDR *xdr)
108 struct sync_state *state = (struct sync_state *) data;
110 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
111 error (g, "guestfs_sync: failed to parse reply header");
114 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
115 if (!xdr_guestfs_message_error (xdr, &state->err)) {
116 error (g, "guestfs_sync: failed to parse reply error");
123 g->main_loop->main_loop_quit (g->main_loop, g);
126 int guestfs_sync (guestfs_h *g)
128 struct sync_state state;
131 if (g->state != READY) {
132 if (g->state == CONFIG)
133 error (g, "%s: call launch() before using this function",
135 else if (g->state == LAUNCHING)
136 error (g, "%s: call wait_ready() before using this function",
139 error (g, "%s called from the wrong state, %d != READY",
140 "guestfs_sync", g->state);
144 memset (&state, 0, sizeof state);
146 serial = dispatch (g, GUESTFS_PROC_SYNC, NULL, NULL);
151 g->reply_cb_internal = sync_cb;
152 g->reply_cb_internal_data = &state;
153 (void) g->main_loop->main_loop_run (g->main_loop, g);
154 g->reply_cb_internal = NULL;
155 g->reply_cb_internal_data = NULL;
156 if (!state.cb_done) {
157 error (g, "guestfs_sync failed, see earlier error messages");
161 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_SYNC, serial) == -1)
164 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
165 error (g, "%s", state.err.error);
174 struct guestfs_message_header hdr;
175 struct guestfs_message_error err;
178 static void touch_cb (guestfs_h *g, void *data, XDR *xdr)
180 struct touch_state *state = (struct touch_state *) data;
182 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
183 error (g, "guestfs_touch: failed to parse reply header");
186 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
187 if (!xdr_guestfs_message_error (xdr, &state->err)) {
188 error (g, "guestfs_touch: failed to parse reply error");
195 g->main_loop->main_loop_quit (g->main_loop, g);
198 int guestfs_touch (guestfs_h *g,
201 struct guestfs_touch_args args;
202 struct touch_state state;
205 if (g->state != READY) {
206 if (g->state == CONFIG)
207 error (g, "%s: call launch() before using this function",
209 else if (g->state == LAUNCHING)
210 error (g, "%s: call wait_ready() before using this function",
213 error (g, "%s called from the wrong state, %d != READY",
214 "guestfs_touch", g->state);
218 memset (&state, 0, sizeof state);
220 args.path = (char *) path;
221 serial = dispatch (g, GUESTFS_PROC_TOUCH,
222 (xdrproc_t) xdr_guestfs_touch_args, (char *) &args);
227 g->reply_cb_internal = touch_cb;
228 g->reply_cb_internal_data = &state;
229 (void) g->main_loop->main_loop_run (g->main_loop, g);
230 g->reply_cb_internal = NULL;
231 g->reply_cb_internal_data = NULL;
232 if (!state.cb_done) {
233 error (g, "guestfs_touch failed, see earlier error messages");
237 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_TOUCH, serial) == -1)
240 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
241 error (g, "%s", state.err.error);
250 struct guestfs_message_header hdr;
251 struct guestfs_message_error err;
252 struct guestfs_cat_ret ret;
255 static void cat_cb (guestfs_h *g, void *data, XDR *xdr)
257 struct cat_state *state = (struct cat_state *) data;
259 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
260 error (g, "guestfs_cat: failed to parse reply header");
263 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
264 if (!xdr_guestfs_message_error (xdr, &state->err)) {
265 error (g, "guestfs_cat: failed to parse reply error");
270 if (!xdr_guestfs_cat_ret (xdr, &state->ret)) {
271 error (g, "guestfs_cat: failed to parse reply");
276 g->main_loop->main_loop_quit (g->main_loop, g);
279 char *guestfs_cat (guestfs_h *g,
282 struct guestfs_cat_args args;
283 struct cat_state state;
286 if (g->state != READY) {
287 if (g->state == CONFIG)
288 error (g, "%s: call launch() before using this function",
290 else if (g->state == LAUNCHING)
291 error (g, "%s: call wait_ready() before using this function",
294 error (g, "%s called from the wrong state, %d != READY",
295 "guestfs_cat", g->state);
299 memset (&state, 0, sizeof state);
301 args.path = (char *) path;
302 serial = dispatch (g, GUESTFS_PROC_CAT,
303 (xdrproc_t) xdr_guestfs_cat_args, (char *) &args);
308 g->reply_cb_internal = cat_cb;
309 g->reply_cb_internal_data = &state;
310 (void) g->main_loop->main_loop_run (g->main_loop, g);
311 g->reply_cb_internal = NULL;
312 g->reply_cb_internal_data = NULL;
313 if (!state.cb_done) {
314 error (g, "guestfs_cat failed, see earlier error messages");
318 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_CAT, serial) == -1)
321 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
322 error (g, "%s", state.err.error);
326 return state.ret.content; /* caller will free */
331 struct guestfs_message_header hdr;
332 struct guestfs_message_error err;
333 struct guestfs_ll_ret ret;
336 static void ll_cb (guestfs_h *g, void *data, XDR *xdr)
338 struct ll_state *state = (struct ll_state *) data;
340 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
341 error (g, "guestfs_ll: failed to parse reply header");
344 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
345 if (!xdr_guestfs_message_error (xdr, &state->err)) {
346 error (g, "guestfs_ll: failed to parse reply error");
351 if (!xdr_guestfs_ll_ret (xdr, &state->ret)) {
352 error (g, "guestfs_ll: failed to parse reply");
357 g->main_loop->main_loop_quit (g->main_loop, g);
360 char *guestfs_ll (guestfs_h *g,
361 const char *directory)
363 struct guestfs_ll_args args;
364 struct ll_state state;
367 if (g->state != READY) {
368 if (g->state == CONFIG)
369 error (g, "%s: call launch() before using this function",
371 else if (g->state == LAUNCHING)
372 error (g, "%s: call wait_ready() before using this function",
375 error (g, "%s called from the wrong state, %d != READY",
376 "guestfs_ll", g->state);
380 memset (&state, 0, sizeof state);
382 args.directory = (char *) directory;
383 serial = dispatch (g, GUESTFS_PROC_LL,
384 (xdrproc_t) xdr_guestfs_ll_args, (char *) &args);
389 g->reply_cb_internal = ll_cb;
390 g->reply_cb_internal_data = &state;
391 (void) g->main_loop->main_loop_run (g->main_loop, g);
392 g->reply_cb_internal = NULL;
393 g->reply_cb_internal_data = NULL;
394 if (!state.cb_done) {
395 error (g, "guestfs_ll failed, see earlier error messages");
399 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_LL, serial) == -1)
402 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
403 error (g, "%s", state.err.error);
407 return state.ret.listing; /* caller will free */
412 struct guestfs_message_header hdr;
413 struct guestfs_message_error err;
414 struct guestfs_ls_ret ret;
417 static void ls_cb (guestfs_h *g, void *data, XDR *xdr)
419 struct ls_state *state = (struct ls_state *) data;
421 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
422 error (g, "guestfs_ls: failed to parse reply header");
425 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
426 if (!xdr_guestfs_message_error (xdr, &state->err)) {
427 error (g, "guestfs_ls: failed to parse reply error");
432 if (!xdr_guestfs_ls_ret (xdr, &state->ret)) {
433 error (g, "guestfs_ls: failed to parse reply");
438 g->main_loop->main_loop_quit (g->main_loop, g);
441 char **guestfs_ls (guestfs_h *g,
442 const char *directory)
444 struct guestfs_ls_args args;
445 struct ls_state state;
448 if (g->state != READY) {
449 if (g->state == CONFIG)
450 error (g, "%s: call launch() before using this function",
452 else if (g->state == LAUNCHING)
453 error (g, "%s: call wait_ready() before using this function",
456 error (g, "%s called from the wrong state, %d != READY",
457 "guestfs_ls", g->state);
461 memset (&state, 0, sizeof state);
463 args.directory = (char *) directory;
464 serial = dispatch (g, GUESTFS_PROC_LS,
465 (xdrproc_t) xdr_guestfs_ls_args, (char *) &args);
470 g->reply_cb_internal = ls_cb;
471 g->reply_cb_internal_data = &state;
472 (void) g->main_loop->main_loop_run (g->main_loop, g);
473 g->reply_cb_internal = NULL;
474 g->reply_cb_internal_data = NULL;
475 if (!state.cb_done) {
476 error (g, "guestfs_ls failed, see earlier error messages");
480 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_LS, serial) == -1)
483 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
484 error (g, "%s", state.err.error);
488 /* caller will free this, but we need to add a NULL entry */
489 state.ret.listing.listing_val = safe_realloc (g, state.ret.listing.listing_val,
490 sizeof (char *) * (state.ret.listing.listing_len + 1));
491 state.ret.listing.listing_val[state.ret.listing.listing_len] = NULL;
492 return state.ret.listing.listing_val;
495 struct list_devices_state {
497 struct guestfs_message_header hdr;
498 struct guestfs_message_error err;
499 struct guestfs_list_devices_ret ret;
502 static void list_devices_cb (guestfs_h *g, void *data, XDR *xdr)
504 struct list_devices_state *state = (struct list_devices_state *) data;
506 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
507 error (g, "guestfs_list_devices: failed to parse reply header");
510 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
511 if (!xdr_guestfs_message_error (xdr, &state->err)) {
512 error (g, "guestfs_list_devices: failed to parse reply error");
517 if (!xdr_guestfs_list_devices_ret (xdr, &state->ret)) {
518 error (g, "guestfs_list_devices: failed to parse reply");
523 g->main_loop->main_loop_quit (g->main_loop, g);
526 char **guestfs_list_devices (guestfs_h *g)
528 struct list_devices_state state;
531 if (g->state != READY) {
532 if (g->state == CONFIG)
533 error (g, "%s: call launch() before using this function",
534 "guestfs_list_devices");
535 else if (g->state == LAUNCHING)
536 error (g, "%s: call wait_ready() before using this function",
537 "guestfs_list_devices");
539 error (g, "%s called from the wrong state, %d != READY",
540 "guestfs_list_devices", g->state);
544 memset (&state, 0, sizeof state);
546 serial = dispatch (g, GUESTFS_PROC_LIST_DEVICES, NULL, NULL);
551 g->reply_cb_internal = list_devices_cb;
552 g->reply_cb_internal_data = &state;
553 (void) g->main_loop->main_loop_run (g->main_loop, g);
554 g->reply_cb_internal = NULL;
555 g->reply_cb_internal_data = NULL;
556 if (!state.cb_done) {
557 error (g, "guestfs_list_devices failed, see earlier error messages");
561 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_LIST_DEVICES, serial) == -1)
564 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
565 error (g, "%s", state.err.error);
569 /* caller will free this, but we need to add a NULL entry */
570 state.ret.devices.devices_val = safe_realloc (g, state.ret.devices.devices_val,
571 sizeof (char *) * (state.ret.devices.devices_len + 1));
572 state.ret.devices.devices_val[state.ret.devices.devices_len] = NULL;
573 return state.ret.devices.devices_val;
576 struct list_partitions_state {
578 struct guestfs_message_header hdr;
579 struct guestfs_message_error err;
580 struct guestfs_list_partitions_ret ret;
583 static void list_partitions_cb (guestfs_h *g, void *data, XDR *xdr)
585 struct list_partitions_state *state = (struct list_partitions_state *) data;
587 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
588 error (g, "guestfs_list_partitions: failed to parse reply header");
591 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
592 if (!xdr_guestfs_message_error (xdr, &state->err)) {
593 error (g, "guestfs_list_partitions: failed to parse reply error");
598 if (!xdr_guestfs_list_partitions_ret (xdr, &state->ret)) {
599 error (g, "guestfs_list_partitions: failed to parse reply");
604 g->main_loop->main_loop_quit (g->main_loop, g);
607 char **guestfs_list_partitions (guestfs_h *g)
609 struct list_partitions_state state;
612 if (g->state != READY) {
613 if (g->state == CONFIG)
614 error (g, "%s: call launch() before using this function",
615 "guestfs_list_partitions");
616 else if (g->state == LAUNCHING)
617 error (g, "%s: call wait_ready() before using this function",
618 "guestfs_list_partitions");
620 error (g, "%s called from the wrong state, %d != READY",
621 "guestfs_list_partitions", g->state);
625 memset (&state, 0, sizeof state);
627 serial = dispatch (g, GUESTFS_PROC_LIST_PARTITIONS, NULL, NULL);
632 g->reply_cb_internal = list_partitions_cb;
633 g->reply_cb_internal_data = &state;
634 (void) g->main_loop->main_loop_run (g->main_loop, g);
635 g->reply_cb_internal = NULL;
636 g->reply_cb_internal_data = NULL;
637 if (!state.cb_done) {
638 error (g, "guestfs_list_partitions failed, see earlier error messages");
642 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_LIST_PARTITIONS, serial) == -1)
645 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
646 error (g, "%s", state.err.error);
650 /* caller will free this, but we need to add a NULL entry */
651 state.ret.partitions.partitions_val = safe_realloc (g, state.ret.partitions.partitions_val,
652 sizeof (char *) * (state.ret.partitions.partitions_len + 1));
653 state.ret.partitions.partitions_val[state.ret.partitions.partitions_len] = NULL;
654 return state.ret.partitions.partitions_val;
659 struct guestfs_message_header hdr;
660 struct guestfs_message_error err;
661 struct guestfs_pvs_ret ret;
664 static void pvs_cb (guestfs_h *g, void *data, XDR *xdr)
666 struct pvs_state *state = (struct pvs_state *) data;
668 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
669 error (g, "guestfs_pvs: failed to parse reply header");
672 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
673 if (!xdr_guestfs_message_error (xdr, &state->err)) {
674 error (g, "guestfs_pvs: failed to parse reply error");
679 if (!xdr_guestfs_pvs_ret (xdr, &state->ret)) {
680 error (g, "guestfs_pvs: failed to parse reply");
685 g->main_loop->main_loop_quit (g->main_loop, g);
688 char **guestfs_pvs (guestfs_h *g)
690 struct pvs_state state;
693 if (g->state != READY) {
694 if (g->state == CONFIG)
695 error (g, "%s: call launch() before using this function",
697 else if (g->state == LAUNCHING)
698 error (g, "%s: call wait_ready() before using this function",
701 error (g, "%s called from the wrong state, %d != READY",
702 "guestfs_pvs", g->state);
706 memset (&state, 0, sizeof state);
708 serial = dispatch (g, GUESTFS_PROC_PVS, NULL, NULL);
713 g->reply_cb_internal = pvs_cb;
714 g->reply_cb_internal_data = &state;
715 (void) g->main_loop->main_loop_run (g->main_loop, g);
716 g->reply_cb_internal = NULL;
717 g->reply_cb_internal_data = NULL;
718 if (!state.cb_done) {
719 error (g, "guestfs_pvs failed, see earlier error messages");
723 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_PVS, serial) == -1)
726 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
727 error (g, "%s", state.err.error);
731 /* caller will free this, but we need to add a NULL entry */
732 state.ret.physvols.physvols_val = safe_realloc (g, state.ret.physvols.physvols_val,
733 sizeof (char *) * (state.ret.physvols.physvols_len + 1));
734 state.ret.physvols.physvols_val[state.ret.physvols.physvols_len] = NULL;
735 return state.ret.physvols.physvols_val;
740 struct guestfs_message_header hdr;
741 struct guestfs_message_error err;
742 struct guestfs_vgs_ret ret;
745 static void vgs_cb (guestfs_h *g, void *data, XDR *xdr)
747 struct vgs_state *state = (struct vgs_state *) data;
749 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
750 error (g, "guestfs_vgs: failed to parse reply header");
753 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
754 if (!xdr_guestfs_message_error (xdr, &state->err)) {
755 error (g, "guestfs_vgs: failed to parse reply error");
760 if (!xdr_guestfs_vgs_ret (xdr, &state->ret)) {
761 error (g, "guestfs_vgs: failed to parse reply");
766 g->main_loop->main_loop_quit (g->main_loop, g);
769 char **guestfs_vgs (guestfs_h *g)
771 struct vgs_state state;
774 if (g->state != READY) {
775 if (g->state == CONFIG)
776 error (g, "%s: call launch() before using this function",
778 else if (g->state == LAUNCHING)
779 error (g, "%s: call wait_ready() before using this function",
782 error (g, "%s called from the wrong state, %d != READY",
783 "guestfs_vgs", g->state);
787 memset (&state, 0, sizeof state);
789 serial = dispatch (g, GUESTFS_PROC_VGS, NULL, NULL);
794 g->reply_cb_internal = vgs_cb;
795 g->reply_cb_internal_data = &state;
796 (void) g->main_loop->main_loop_run (g->main_loop, g);
797 g->reply_cb_internal = NULL;
798 g->reply_cb_internal_data = NULL;
799 if (!state.cb_done) {
800 error (g, "guestfs_vgs failed, see earlier error messages");
804 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_VGS, serial) == -1)
807 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
808 error (g, "%s", state.err.error);
812 /* caller will free this, but we need to add a NULL entry */
813 state.ret.volgroups.volgroups_val = safe_realloc (g, state.ret.volgroups.volgroups_val,
814 sizeof (char *) * (state.ret.volgroups.volgroups_len + 1));
815 state.ret.volgroups.volgroups_val[state.ret.volgroups.volgroups_len] = NULL;
816 return state.ret.volgroups.volgroups_val;
821 struct guestfs_message_header hdr;
822 struct guestfs_message_error err;
823 struct guestfs_lvs_ret ret;
826 static void lvs_cb (guestfs_h *g, void *data, XDR *xdr)
828 struct lvs_state *state = (struct lvs_state *) data;
830 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
831 error (g, "guestfs_lvs: failed to parse reply header");
834 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
835 if (!xdr_guestfs_message_error (xdr, &state->err)) {
836 error (g, "guestfs_lvs: failed to parse reply error");
841 if (!xdr_guestfs_lvs_ret (xdr, &state->ret)) {
842 error (g, "guestfs_lvs: failed to parse reply");
847 g->main_loop->main_loop_quit (g->main_loop, g);
850 char **guestfs_lvs (guestfs_h *g)
852 struct lvs_state state;
855 if (g->state != READY) {
856 if (g->state == CONFIG)
857 error (g, "%s: call launch() before using this function",
859 else if (g->state == LAUNCHING)
860 error (g, "%s: call wait_ready() before using this function",
863 error (g, "%s called from the wrong state, %d != READY",
864 "guestfs_lvs", g->state);
868 memset (&state, 0, sizeof state);
870 serial = dispatch (g, GUESTFS_PROC_LVS, NULL, NULL);
875 g->reply_cb_internal = lvs_cb;
876 g->reply_cb_internal_data = &state;
877 (void) g->main_loop->main_loop_run (g->main_loop, g);
878 g->reply_cb_internal = NULL;
879 g->reply_cb_internal_data = NULL;
880 if (!state.cb_done) {
881 error (g, "guestfs_lvs failed, see earlier error messages");
885 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_LVS, serial) == -1)
888 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
889 error (g, "%s", state.err.error);
893 /* caller will free this, but we need to add a NULL entry */
894 state.ret.logvols.logvols_val = safe_realloc (g, state.ret.logvols.logvols_val,
895 sizeof (char *) * (state.ret.logvols.logvols_len + 1));
896 state.ret.logvols.logvols_val[state.ret.logvols.logvols_len] = NULL;
897 return state.ret.logvols.logvols_val;
900 struct pvs_full_state {
902 struct guestfs_message_header hdr;
903 struct guestfs_message_error err;
904 struct guestfs_pvs_full_ret ret;
907 static void pvs_full_cb (guestfs_h *g, void *data, XDR *xdr)
909 struct pvs_full_state *state = (struct pvs_full_state *) data;
911 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
912 error (g, "guestfs_pvs_full: failed to parse reply header");
915 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
916 if (!xdr_guestfs_message_error (xdr, &state->err)) {
917 error (g, "guestfs_pvs_full: failed to parse reply error");
922 if (!xdr_guestfs_pvs_full_ret (xdr, &state->ret)) {
923 error (g, "guestfs_pvs_full: failed to parse reply");
928 g->main_loop->main_loop_quit (g->main_loop, g);
931 struct guestfs_lvm_pv_list *guestfs_pvs_full (guestfs_h *g)
933 struct pvs_full_state state;
936 if (g->state != READY) {
937 if (g->state == CONFIG)
938 error (g, "%s: call launch() before using this function",
940 else if (g->state == LAUNCHING)
941 error (g, "%s: call wait_ready() before using this function",
944 error (g, "%s called from the wrong state, %d != READY",
945 "guestfs_pvs_full", g->state);
949 memset (&state, 0, sizeof state);
951 serial = dispatch (g, GUESTFS_PROC_PVS_FULL, NULL, NULL);
956 g->reply_cb_internal = pvs_full_cb;
957 g->reply_cb_internal_data = &state;
958 (void) g->main_loop->main_loop_run (g->main_loop, g);
959 g->reply_cb_internal = NULL;
960 g->reply_cb_internal_data = NULL;
961 if (!state.cb_done) {
962 error (g, "guestfs_pvs_full failed, see earlier error messages");
966 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_PVS_FULL, serial) == -1)
969 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
970 error (g, "%s", state.err.error);
974 /* caller will free this */
975 return safe_memdup (g, &state.ret.physvols, sizeof (state.ret.physvols));
978 struct vgs_full_state {
980 struct guestfs_message_header hdr;
981 struct guestfs_message_error err;
982 struct guestfs_vgs_full_ret ret;
985 static void vgs_full_cb (guestfs_h *g, void *data, XDR *xdr)
987 struct vgs_full_state *state = (struct vgs_full_state *) data;
989 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
990 error (g, "guestfs_vgs_full: failed to parse reply header");
993 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
994 if (!xdr_guestfs_message_error (xdr, &state->err)) {
995 error (g, "guestfs_vgs_full: failed to parse reply error");
1000 if (!xdr_guestfs_vgs_full_ret (xdr, &state->ret)) {
1001 error (g, "guestfs_vgs_full: failed to parse reply");
1006 g->main_loop->main_loop_quit (g->main_loop, g);
1009 struct guestfs_lvm_vg_list *guestfs_vgs_full (guestfs_h *g)
1011 struct vgs_full_state state;
1014 if (g->state != READY) {
1015 if (g->state == CONFIG)
1016 error (g, "%s: call launch() before using this function",
1017 "guestfs_vgs_full");
1018 else if (g->state == LAUNCHING)
1019 error (g, "%s: call wait_ready() before using this function",
1020 "guestfs_vgs_full");
1022 error (g, "%s called from the wrong state, %d != READY",
1023 "guestfs_vgs_full", g->state);
1027 memset (&state, 0, sizeof state);
1029 serial = dispatch (g, GUESTFS_PROC_VGS_FULL, NULL, NULL);
1034 g->reply_cb_internal = vgs_full_cb;
1035 g->reply_cb_internal_data = &state;
1036 (void) g->main_loop->main_loop_run (g->main_loop, g);
1037 g->reply_cb_internal = NULL;
1038 g->reply_cb_internal_data = NULL;
1039 if (!state.cb_done) {
1040 error (g, "guestfs_vgs_full failed, see earlier error messages");
1044 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_VGS_FULL, serial) == -1)
1047 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
1048 error (g, "%s", state.err.error);
1052 /* caller will free this */
1053 return safe_memdup (g, &state.ret.volgroups, sizeof (state.ret.volgroups));
1056 struct lvs_full_state {
1058 struct guestfs_message_header hdr;
1059 struct guestfs_message_error err;
1060 struct guestfs_lvs_full_ret ret;
1063 static void lvs_full_cb (guestfs_h *g, void *data, XDR *xdr)
1065 struct lvs_full_state *state = (struct lvs_full_state *) data;
1067 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
1068 error (g, "guestfs_lvs_full: failed to parse reply header");
1071 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
1072 if (!xdr_guestfs_message_error (xdr, &state->err)) {
1073 error (g, "guestfs_lvs_full: failed to parse reply error");
1078 if (!xdr_guestfs_lvs_full_ret (xdr, &state->ret)) {
1079 error (g, "guestfs_lvs_full: failed to parse reply");
1084 g->main_loop->main_loop_quit (g->main_loop, g);
1087 struct guestfs_lvm_lv_list *guestfs_lvs_full (guestfs_h *g)
1089 struct lvs_full_state state;
1092 if (g->state != READY) {
1093 if (g->state == CONFIG)
1094 error (g, "%s: call launch() before using this function",
1095 "guestfs_lvs_full");
1096 else if (g->state == LAUNCHING)
1097 error (g, "%s: call wait_ready() before using this function",
1098 "guestfs_lvs_full");
1100 error (g, "%s called from the wrong state, %d != READY",
1101 "guestfs_lvs_full", g->state);
1105 memset (&state, 0, sizeof state);
1107 serial = dispatch (g, GUESTFS_PROC_LVS_FULL, NULL, NULL);
1112 g->reply_cb_internal = lvs_full_cb;
1113 g->reply_cb_internal_data = &state;
1114 (void) g->main_loop->main_loop_run (g->main_loop, g);
1115 g->reply_cb_internal = NULL;
1116 g->reply_cb_internal_data = NULL;
1117 if (!state.cb_done) {
1118 error (g, "guestfs_lvs_full failed, see earlier error messages");
1122 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_LVS_FULL, serial) == -1)
1125 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
1126 error (g, "%s", state.err.error);
1130 /* caller will free this */
1131 return safe_memdup (g, &state.ret.logvols, sizeof (state.ret.logvols));
1134 struct read_lines_state {
1136 struct guestfs_message_header hdr;
1137 struct guestfs_message_error err;
1138 struct guestfs_read_lines_ret ret;
1141 static void read_lines_cb (guestfs_h *g, void *data, XDR *xdr)
1143 struct read_lines_state *state = (struct read_lines_state *) data;
1145 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
1146 error (g, "guestfs_read_lines: failed to parse reply header");
1149 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
1150 if (!xdr_guestfs_message_error (xdr, &state->err)) {
1151 error (g, "guestfs_read_lines: failed to parse reply error");
1156 if (!xdr_guestfs_read_lines_ret (xdr, &state->ret)) {
1157 error (g, "guestfs_read_lines: failed to parse reply");
1162 g->main_loop->main_loop_quit (g->main_loop, g);
1165 char **guestfs_read_lines (guestfs_h *g,
1168 struct guestfs_read_lines_args args;
1169 struct read_lines_state state;
1172 if (g->state != READY) {
1173 if (g->state == CONFIG)
1174 error (g, "%s: call launch() before using this function",
1175 "guestfs_read_lines");
1176 else if (g->state == LAUNCHING)
1177 error (g, "%s: call wait_ready() before using this function",
1178 "guestfs_read_lines");
1180 error (g, "%s called from the wrong state, %d != READY",
1181 "guestfs_read_lines", g->state);
1185 memset (&state, 0, sizeof state);
1187 args.path = (char *) path;
1188 serial = dispatch (g, GUESTFS_PROC_READ_LINES,
1189 (xdrproc_t) xdr_guestfs_read_lines_args, (char *) &args);
1194 g->reply_cb_internal = read_lines_cb;
1195 g->reply_cb_internal_data = &state;
1196 (void) g->main_loop->main_loop_run (g->main_loop, g);
1197 g->reply_cb_internal = NULL;
1198 g->reply_cb_internal_data = NULL;
1199 if (!state.cb_done) {
1200 error (g, "guestfs_read_lines failed, see earlier error messages");
1204 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_READ_LINES, serial) == -1)
1207 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
1208 error (g, "%s", state.err.error);
1212 /* caller will free this, but we need to add a NULL entry */
1213 state.ret.lines.lines_val = safe_realloc (g, state.ret.lines.lines_val,
1214 sizeof (char *) * (state.ret.lines.lines_len + 1));
1215 state.ret.lines.lines_val[state.ret.lines.lines_len] = NULL;
1216 return state.ret.lines.lines_val;
1219 struct aug_init_state {
1221 struct guestfs_message_header hdr;
1222 struct guestfs_message_error err;
1225 static void aug_init_cb (guestfs_h *g, void *data, XDR *xdr)
1227 struct aug_init_state *state = (struct aug_init_state *) data;
1229 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
1230 error (g, "guestfs_aug_init: failed to parse reply header");
1233 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
1234 if (!xdr_guestfs_message_error (xdr, &state->err)) {
1235 error (g, "guestfs_aug_init: failed to parse reply error");
1242 g->main_loop->main_loop_quit (g->main_loop, g);
1245 int guestfs_aug_init (guestfs_h *g,
1249 struct guestfs_aug_init_args args;
1250 struct aug_init_state state;
1253 if (g->state != READY) {
1254 if (g->state == CONFIG)
1255 error (g, "%s: call launch() before using this function",
1256 "guestfs_aug_init");
1257 else if (g->state == LAUNCHING)
1258 error (g, "%s: call wait_ready() before using this function",
1259 "guestfs_aug_init");
1261 error (g, "%s called from the wrong state, %d != READY",
1262 "guestfs_aug_init", g->state);
1266 memset (&state, 0, sizeof state);
1268 args.root = (char *) root;
1270 serial = dispatch (g, GUESTFS_PROC_AUG_INIT,
1271 (xdrproc_t) xdr_guestfs_aug_init_args, (char *) &args);
1276 g->reply_cb_internal = aug_init_cb;
1277 g->reply_cb_internal_data = &state;
1278 (void) g->main_loop->main_loop_run (g->main_loop, g);
1279 g->reply_cb_internal = NULL;
1280 g->reply_cb_internal_data = NULL;
1281 if (!state.cb_done) {
1282 error (g, "guestfs_aug_init failed, see earlier error messages");
1286 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_INIT, serial) == -1)
1289 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
1290 error (g, "%s", state.err.error);
1297 struct aug_close_state {
1299 struct guestfs_message_header hdr;
1300 struct guestfs_message_error err;
1303 static void aug_close_cb (guestfs_h *g, void *data, XDR *xdr)
1305 struct aug_close_state *state = (struct aug_close_state *) data;
1307 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
1308 error (g, "guestfs_aug_close: failed to parse reply header");
1311 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
1312 if (!xdr_guestfs_message_error (xdr, &state->err)) {
1313 error (g, "guestfs_aug_close: failed to parse reply error");
1320 g->main_loop->main_loop_quit (g->main_loop, g);
1323 int guestfs_aug_close (guestfs_h *g)
1325 struct aug_close_state state;
1328 if (g->state != READY) {
1329 if (g->state == CONFIG)
1330 error (g, "%s: call launch() before using this function",
1331 "guestfs_aug_close");
1332 else if (g->state == LAUNCHING)
1333 error (g, "%s: call wait_ready() before using this function",
1334 "guestfs_aug_close");
1336 error (g, "%s called from the wrong state, %d != READY",
1337 "guestfs_aug_close", g->state);
1341 memset (&state, 0, sizeof state);
1343 serial = dispatch (g, GUESTFS_PROC_AUG_CLOSE, NULL, NULL);
1348 g->reply_cb_internal = aug_close_cb;
1349 g->reply_cb_internal_data = &state;
1350 (void) g->main_loop->main_loop_run (g->main_loop, g);
1351 g->reply_cb_internal = NULL;
1352 g->reply_cb_internal_data = NULL;
1353 if (!state.cb_done) {
1354 error (g, "guestfs_aug_close failed, see earlier error messages");
1358 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_CLOSE, serial) == -1)
1361 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
1362 error (g, "%s", state.err.error);
1369 struct aug_defvar_state {
1371 struct guestfs_message_header hdr;
1372 struct guestfs_message_error err;
1373 struct guestfs_aug_defvar_ret ret;
1376 static void aug_defvar_cb (guestfs_h *g, void *data, XDR *xdr)
1378 struct aug_defvar_state *state = (struct aug_defvar_state *) data;
1380 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
1381 error (g, "guestfs_aug_defvar: failed to parse reply header");
1384 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
1385 if (!xdr_guestfs_message_error (xdr, &state->err)) {
1386 error (g, "guestfs_aug_defvar: failed to parse reply error");
1391 if (!xdr_guestfs_aug_defvar_ret (xdr, &state->ret)) {
1392 error (g, "guestfs_aug_defvar: failed to parse reply");
1397 g->main_loop->main_loop_quit (g->main_loop, g);
1400 int guestfs_aug_defvar (guestfs_h *g,
1404 struct guestfs_aug_defvar_args args;
1405 struct aug_defvar_state state;
1408 if (g->state != READY) {
1409 if (g->state == CONFIG)
1410 error (g, "%s: call launch() before using this function",
1411 "guestfs_aug_defvar");
1412 else if (g->state == LAUNCHING)
1413 error (g, "%s: call wait_ready() before using this function",
1414 "guestfs_aug_defvar");
1416 error (g, "%s called from the wrong state, %d != READY",
1417 "guestfs_aug_defvar", g->state);
1421 memset (&state, 0, sizeof state);
1423 args.name = (char *) name;
1424 args.expr = expr ? (char **) &expr : NULL;
1425 serial = dispatch (g, GUESTFS_PROC_AUG_DEFVAR,
1426 (xdrproc_t) xdr_guestfs_aug_defvar_args, (char *) &args);
1431 g->reply_cb_internal = aug_defvar_cb;
1432 g->reply_cb_internal_data = &state;
1433 (void) g->main_loop->main_loop_run (g->main_loop, g);
1434 g->reply_cb_internal = NULL;
1435 g->reply_cb_internal_data = NULL;
1436 if (!state.cb_done) {
1437 error (g, "guestfs_aug_defvar failed, see earlier error messages");
1441 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_DEFVAR, serial) == -1)
1444 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
1445 error (g, "%s", state.err.error);
1449 return state.ret.nrnodes;
1452 struct aug_defnode_state {
1454 struct guestfs_message_header hdr;
1455 struct guestfs_message_error err;
1456 struct guestfs_aug_defnode_ret ret;
1459 static void aug_defnode_cb (guestfs_h *g, void *data, XDR *xdr)
1461 struct aug_defnode_state *state = (struct aug_defnode_state *) data;
1463 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
1464 error (g, "guestfs_aug_defnode: failed to parse reply header");
1467 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
1468 if (!xdr_guestfs_message_error (xdr, &state->err)) {
1469 error (g, "guestfs_aug_defnode: failed to parse reply error");
1474 if (!xdr_guestfs_aug_defnode_ret (xdr, &state->ret)) {
1475 error (g, "guestfs_aug_defnode: failed to parse reply");
1480 g->main_loop->main_loop_quit (g->main_loop, g);
1483 struct guestfs_int_bool *guestfs_aug_defnode (guestfs_h *g,
1488 struct guestfs_aug_defnode_args args;
1489 struct aug_defnode_state state;
1492 if (g->state != READY) {
1493 if (g->state == CONFIG)
1494 error (g, "%s: call launch() before using this function",
1495 "guestfs_aug_defnode");
1496 else if (g->state == LAUNCHING)
1497 error (g, "%s: call wait_ready() before using this function",
1498 "guestfs_aug_defnode");
1500 error (g, "%s called from the wrong state, %d != READY",
1501 "guestfs_aug_defnode", g->state);
1505 memset (&state, 0, sizeof state);
1507 args.name = (char *) name;
1508 args.expr = (char *) expr;
1509 args.val = (char *) val;
1510 serial = dispatch (g, GUESTFS_PROC_AUG_DEFNODE,
1511 (xdrproc_t) xdr_guestfs_aug_defnode_args, (char *) &args);
1516 g->reply_cb_internal = aug_defnode_cb;
1517 g->reply_cb_internal_data = &state;
1518 (void) g->main_loop->main_loop_run (g->main_loop, g);
1519 g->reply_cb_internal = NULL;
1520 g->reply_cb_internal_data = NULL;
1521 if (!state.cb_done) {
1522 error (g, "guestfs_aug_defnode failed, see earlier error messages");
1526 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_DEFNODE, serial) == -1)
1529 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
1530 error (g, "%s", state.err.error);
1534 /* caller with free this */
1535 return safe_memdup (g, &state.ret, sizeof (state.ret));
1538 struct aug_get_state {
1540 struct guestfs_message_header hdr;
1541 struct guestfs_message_error err;
1542 struct guestfs_aug_get_ret ret;
1545 static void aug_get_cb (guestfs_h *g, void *data, XDR *xdr)
1547 struct aug_get_state *state = (struct aug_get_state *) data;
1549 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
1550 error (g, "guestfs_aug_get: failed to parse reply header");
1553 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
1554 if (!xdr_guestfs_message_error (xdr, &state->err)) {
1555 error (g, "guestfs_aug_get: failed to parse reply error");
1560 if (!xdr_guestfs_aug_get_ret (xdr, &state->ret)) {
1561 error (g, "guestfs_aug_get: failed to parse reply");
1566 g->main_loop->main_loop_quit (g->main_loop, g);
1569 char *guestfs_aug_get (guestfs_h *g,
1572 struct guestfs_aug_get_args args;
1573 struct aug_get_state state;
1576 if (g->state != READY) {
1577 if (g->state == CONFIG)
1578 error (g, "%s: call launch() before using this function",
1580 else if (g->state == LAUNCHING)
1581 error (g, "%s: call wait_ready() before using this function",
1584 error (g, "%s called from the wrong state, %d != READY",
1585 "guestfs_aug_get", g->state);
1589 memset (&state, 0, sizeof state);
1591 args.path = (char *) path;
1592 serial = dispatch (g, GUESTFS_PROC_AUG_GET,
1593 (xdrproc_t) xdr_guestfs_aug_get_args, (char *) &args);
1598 g->reply_cb_internal = aug_get_cb;
1599 g->reply_cb_internal_data = &state;
1600 (void) g->main_loop->main_loop_run (g->main_loop, g);
1601 g->reply_cb_internal = NULL;
1602 g->reply_cb_internal_data = NULL;
1603 if (!state.cb_done) {
1604 error (g, "guestfs_aug_get failed, see earlier error messages");
1608 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_GET, serial) == -1)
1611 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
1612 error (g, "%s", state.err.error);
1616 return state.ret.val; /* caller will free */
1619 struct aug_set_state {
1621 struct guestfs_message_header hdr;
1622 struct guestfs_message_error err;
1625 static void aug_set_cb (guestfs_h *g, void *data, XDR *xdr)
1627 struct aug_set_state *state = (struct aug_set_state *) data;
1629 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
1630 error (g, "guestfs_aug_set: failed to parse reply header");
1633 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
1634 if (!xdr_guestfs_message_error (xdr, &state->err)) {
1635 error (g, "guestfs_aug_set: failed to parse reply error");
1642 g->main_loop->main_loop_quit (g->main_loop, g);
1645 int guestfs_aug_set (guestfs_h *g,
1649 struct guestfs_aug_set_args args;
1650 struct aug_set_state state;
1653 if (g->state != READY) {
1654 if (g->state == CONFIG)
1655 error (g, "%s: call launch() before using this function",
1657 else if (g->state == LAUNCHING)
1658 error (g, "%s: call wait_ready() before using this function",
1661 error (g, "%s called from the wrong state, %d != READY",
1662 "guestfs_aug_set", g->state);
1666 memset (&state, 0, sizeof state);
1668 args.path = (char *) path;
1669 args.val = (char *) val;
1670 serial = dispatch (g, GUESTFS_PROC_AUG_SET,
1671 (xdrproc_t) xdr_guestfs_aug_set_args, (char *) &args);
1676 g->reply_cb_internal = aug_set_cb;
1677 g->reply_cb_internal_data = &state;
1678 (void) g->main_loop->main_loop_run (g->main_loop, g);
1679 g->reply_cb_internal = NULL;
1680 g->reply_cb_internal_data = NULL;
1681 if (!state.cb_done) {
1682 error (g, "guestfs_aug_set failed, see earlier error messages");
1686 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_SET, serial) == -1)
1689 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
1690 error (g, "%s", state.err.error);
1697 struct aug_insert_state {
1699 struct guestfs_message_header hdr;
1700 struct guestfs_message_error err;
1703 static void aug_insert_cb (guestfs_h *g, void *data, XDR *xdr)
1705 struct aug_insert_state *state = (struct aug_insert_state *) data;
1707 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
1708 error (g, "guestfs_aug_insert: failed to parse reply header");
1711 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
1712 if (!xdr_guestfs_message_error (xdr, &state->err)) {
1713 error (g, "guestfs_aug_insert: failed to parse reply error");
1720 g->main_loop->main_loop_quit (g->main_loop, g);
1723 int guestfs_aug_insert (guestfs_h *g,
1728 struct guestfs_aug_insert_args args;
1729 struct aug_insert_state state;
1732 if (g->state != READY) {
1733 if (g->state == CONFIG)
1734 error (g, "%s: call launch() before using this function",
1735 "guestfs_aug_insert");
1736 else if (g->state == LAUNCHING)
1737 error (g, "%s: call wait_ready() before using this function",
1738 "guestfs_aug_insert");
1740 error (g, "%s called from the wrong state, %d != READY",
1741 "guestfs_aug_insert", g->state);
1745 memset (&state, 0, sizeof state);
1747 args.path = (char *) path;
1748 args.label = (char *) label;
1749 args.before = before;
1750 serial = dispatch (g, GUESTFS_PROC_AUG_INSERT,
1751 (xdrproc_t) xdr_guestfs_aug_insert_args, (char *) &args);
1756 g->reply_cb_internal = aug_insert_cb;
1757 g->reply_cb_internal_data = &state;
1758 (void) g->main_loop->main_loop_run (g->main_loop, g);
1759 g->reply_cb_internal = NULL;
1760 g->reply_cb_internal_data = NULL;
1761 if (!state.cb_done) {
1762 error (g, "guestfs_aug_insert failed, see earlier error messages");
1766 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_INSERT, serial) == -1)
1769 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
1770 error (g, "%s", state.err.error);
1777 struct aug_rm_state {
1779 struct guestfs_message_header hdr;
1780 struct guestfs_message_error err;
1781 struct guestfs_aug_rm_ret ret;
1784 static void aug_rm_cb (guestfs_h *g, void *data, XDR *xdr)
1786 struct aug_rm_state *state = (struct aug_rm_state *) data;
1788 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
1789 error (g, "guestfs_aug_rm: failed to parse reply header");
1792 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
1793 if (!xdr_guestfs_message_error (xdr, &state->err)) {
1794 error (g, "guestfs_aug_rm: failed to parse reply error");
1799 if (!xdr_guestfs_aug_rm_ret (xdr, &state->ret)) {
1800 error (g, "guestfs_aug_rm: failed to parse reply");
1805 g->main_loop->main_loop_quit (g->main_loop, g);
1808 int guestfs_aug_rm (guestfs_h *g,
1811 struct guestfs_aug_rm_args args;
1812 struct aug_rm_state state;
1815 if (g->state != READY) {
1816 if (g->state == CONFIG)
1817 error (g, "%s: call launch() before using this function",
1819 else if (g->state == LAUNCHING)
1820 error (g, "%s: call wait_ready() before using this function",
1823 error (g, "%s called from the wrong state, %d != READY",
1824 "guestfs_aug_rm", g->state);
1828 memset (&state, 0, sizeof state);
1830 args.path = (char *) path;
1831 serial = dispatch (g, GUESTFS_PROC_AUG_RM,
1832 (xdrproc_t) xdr_guestfs_aug_rm_args, (char *) &args);
1837 g->reply_cb_internal = aug_rm_cb;
1838 g->reply_cb_internal_data = &state;
1839 (void) g->main_loop->main_loop_run (g->main_loop, g);
1840 g->reply_cb_internal = NULL;
1841 g->reply_cb_internal_data = NULL;
1842 if (!state.cb_done) {
1843 error (g, "guestfs_aug_rm failed, see earlier error messages");
1847 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_RM, serial) == -1)
1850 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
1851 error (g, "%s", state.err.error);
1855 return state.ret.nrnodes;
1858 struct aug_mv_state {
1860 struct guestfs_message_header hdr;
1861 struct guestfs_message_error err;
1864 static void aug_mv_cb (guestfs_h *g, void *data, XDR *xdr)
1866 struct aug_mv_state *state = (struct aug_mv_state *) data;
1868 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
1869 error (g, "guestfs_aug_mv: failed to parse reply header");
1872 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
1873 if (!xdr_guestfs_message_error (xdr, &state->err)) {
1874 error (g, "guestfs_aug_mv: failed to parse reply error");
1881 g->main_loop->main_loop_quit (g->main_loop, g);
1884 int guestfs_aug_mv (guestfs_h *g,
1888 struct guestfs_aug_mv_args args;
1889 struct aug_mv_state state;
1892 if (g->state != READY) {
1893 if (g->state == CONFIG)
1894 error (g, "%s: call launch() before using this function",
1896 else if (g->state == LAUNCHING)
1897 error (g, "%s: call wait_ready() before using this function",
1900 error (g, "%s called from the wrong state, %d != READY",
1901 "guestfs_aug_mv", g->state);
1905 memset (&state, 0, sizeof state);
1907 args.src = (char *) src;
1908 args.dest = (char *) dest;
1909 serial = dispatch (g, GUESTFS_PROC_AUG_MV,
1910 (xdrproc_t) xdr_guestfs_aug_mv_args, (char *) &args);
1915 g->reply_cb_internal = aug_mv_cb;
1916 g->reply_cb_internal_data = &state;
1917 (void) g->main_loop->main_loop_run (g->main_loop, g);
1918 g->reply_cb_internal = NULL;
1919 g->reply_cb_internal_data = NULL;
1920 if (!state.cb_done) {
1921 error (g, "guestfs_aug_mv failed, see earlier error messages");
1925 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_MV, serial) == -1)
1928 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
1929 error (g, "%s", state.err.error);
1936 struct aug_match_state {
1938 struct guestfs_message_header hdr;
1939 struct guestfs_message_error err;
1940 struct guestfs_aug_match_ret ret;
1943 static void aug_match_cb (guestfs_h *g, void *data, XDR *xdr)
1945 struct aug_match_state *state = (struct aug_match_state *) data;
1947 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
1948 error (g, "guestfs_aug_match: failed to parse reply header");
1951 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
1952 if (!xdr_guestfs_message_error (xdr, &state->err)) {
1953 error (g, "guestfs_aug_match: failed to parse reply error");
1958 if (!xdr_guestfs_aug_match_ret (xdr, &state->ret)) {
1959 error (g, "guestfs_aug_match: failed to parse reply");
1964 g->main_loop->main_loop_quit (g->main_loop, g);
1967 char **guestfs_aug_match (guestfs_h *g,
1970 struct guestfs_aug_match_args args;
1971 struct aug_match_state state;
1974 if (g->state != READY) {
1975 if (g->state == CONFIG)
1976 error (g, "%s: call launch() before using this function",
1977 "guestfs_aug_match");
1978 else if (g->state == LAUNCHING)
1979 error (g, "%s: call wait_ready() before using this function",
1980 "guestfs_aug_match");
1982 error (g, "%s called from the wrong state, %d != READY",
1983 "guestfs_aug_match", g->state);
1987 memset (&state, 0, sizeof state);
1989 args.path = (char *) path;
1990 serial = dispatch (g, GUESTFS_PROC_AUG_MATCH,
1991 (xdrproc_t) xdr_guestfs_aug_match_args, (char *) &args);
1996 g->reply_cb_internal = aug_match_cb;
1997 g->reply_cb_internal_data = &state;
1998 (void) g->main_loop->main_loop_run (g->main_loop, g);
1999 g->reply_cb_internal = NULL;
2000 g->reply_cb_internal_data = NULL;
2001 if (!state.cb_done) {
2002 error (g, "guestfs_aug_match failed, see earlier error messages");
2006 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_MATCH, serial) == -1)
2009 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2010 error (g, "%s", state.err.error);
2014 /* caller will free this, but we need to add a NULL entry */
2015 state.ret.matches.matches_val = safe_realloc (g, state.ret.matches.matches_val,
2016 sizeof (char *) * (state.ret.matches.matches_len + 1));
2017 state.ret.matches.matches_val[state.ret.matches.matches_len] = NULL;
2018 return state.ret.matches.matches_val;
2021 struct aug_save_state {
2023 struct guestfs_message_header hdr;
2024 struct guestfs_message_error err;
2027 static void aug_save_cb (guestfs_h *g, void *data, XDR *xdr)
2029 struct aug_save_state *state = (struct aug_save_state *) data;
2031 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2032 error (g, "guestfs_aug_save: failed to parse reply header");
2035 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2036 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2037 error (g, "guestfs_aug_save: failed to parse reply error");
2044 g->main_loop->main_loop_quit (g->main_loop, g);
2047 int guestfs_aug_save (guestfs_h *g)
2049 struct aug_save_state state;
2052 if (g->state != READY) {
2053 if (g->state == CONFIG)
2054 error (g, "%s: call launch() before using this function",
2055 "guestfs_aug_save");
2056 else if (g->state == LAUNCHING)
2057 error (g, "%s: call wait_ready() before using this function",
2058 "guestfs_aug_save");
2060 error (g, "%s called from the wrong state, %d != READY",
2061 "guestfs_aug_save", g->state);
2065 memset (&state, 0, sizeof state);
2067 serial = dispatch (g, GUESTFS_PROC_AUG_SAVE, NULL, NULL);
2072 g->reply_cb_internal = aug_save_cb;
2073 g->reply_cb_internal_data = &state;
2074 (void) g->main_loop->main_loop_run (g->main_loop, g);
2075 g->reply_cb_internal = NULL;
2076 g->reply_cb_internal_data = NULL;
2077 if (!state.cb_done) {
2078 error (g, "guestfs_aug_save failed, see earlier error messages");
2082 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_SAVE, serial) == -1)
2085 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2086 error (g, "%s", state.err.error);
2093 struct aug_load_state {
2095 struct guestfs_message_header hdr;
2096 struct guestfs_message_error err;
2099 static void aug_load_cb (guestfs_h *g, void *data, XDR *xdr)
2101 struct aug_load_state *state = (struct aug_load_state *) data;
2103 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2104 error (g, "guestfs_aug_load: failed to parse reply header");
2107 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2108 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2109 error (g, "guestfs_aug_load: failed to parse reply error");
2116 g->main_loop->main_loop_quit (g->main_loop, g);
2119 int guestfs_aug_load (guestfs_h *g)
2121 struct aug_load_state state;
2124 if (g->state != READY) {
2125 if (g->state == CONFIG)
2126 error (g, "%s: call launch() before using this function",
2127 "guestfs_aug_load");
2128 else if (g->state == LAUNCHING)
2129 error (g, "%s: call wait_ready() before using this function",
2130 "guestfs_aug_load");
2132 error (g, "%s called from the wrong state, %d != READY",
2133 "guestfs_aug_load", g->state);
2137 memset (&state, 0, sizeof state);
2139 serial = dispatch (g, GUESTFS_PROC_AUG_LOAD, NULL, NULL);
2144 g->reply_cb_internal = aug_load_cb;
2145 g->reply_cb_internal_data = &state;
2146 (void) g->main_loop->main_loop_run (g->main_loop, g);
2147 g->reply_cb_internal = NULL;
2148 g->reply_cb_internal_data = NULL;
2149 if (!state.cb_done) {
2150 error (g, "guestfs_aug_load failed, see earlier error messages");
2154 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_LOAD, serial) == -1)
2157 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2158 error (g, "%s", state.err.error);
2165 struct aug_ls_state {
2167 struct guestfs_message_header hdr;
2168 struct guestfs_message_error err;
2169 struct guestfs_aug_ls_ret ret;
2172 static void aug_ls_cb (guestfs_h *g, void *data, XDR *xdr)
2174 struct aug_ls_state *state = (struct aug_ls_state *) data;
2176 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2177 error (g, "guestfs_aug_ls: failed to parse reply header");
2180 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2181 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2182 error (g, "guestfs_aug_ls: failed to parse reply error");
2187 if (!xdr_guestfs_aug_ls_ret (xdr, &state->ret)) {
2188 error (g, "guestfs_aug_ls: failed to parse reply");
2193 g->main_loop->main_loop_quit (g->main_loop, g);
2196 char **guestfs_aug_ls (guestfs_h *g,
2199 struct guestfs_aug_ls_args args;
2200 struct aug_ls_state state;
2203 if (g->state != READY) {
2204 if (g->state == CONFIG)
2205 error (g, "%s: call launch() before using this function",
2207 else if (g->state == LAUNCHING)
2208 error (g, "%s: call wait_ready() before using this function",
2211 error (g, "%s called from the wrong state, %d != READY",
2212 "guestfs_aug_ls", g->state);
2216 memset (&state, 0, sizeof state);
2218 args.path = (char *) path;
2219 serial = dispatch (g, GUESTFS_PROC_AUG_LS,
2220 (xdrproc_t) xdr_guestfs_aug_ls_args, (char *) &args);
2225 g->reply_cb_internal = aug_ls_cb;
2226 g->reply_cb_internal_data = &state;
2227 (void) g->main_loop->main_loop_run (g->main_loop, g);
2228 g->reply_cb_internal = NULL;
2229 g->reply_cb_internal_data = NULL;
2230 if (!state.cb_done) {
2231 error (g, "guestfs_aug_ls failed, see earlier error messages");
2235 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_AUG_LS, serial) == -1)
2238 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2239 error (g, "%s", state.err.error);
2243 /* caller will free this, but we need to add a NULL entry */
2244 state.ret.matches.matches_val = safe_realloc (g, state.ret.matches.matches_val,
2245 sizeof (char *) * (state.ret.matches.matches_len + 1));
2246 state.ret.matches.matches_val[state.ret.matches.matches_len] = NULL;
2247 return state.ret.matches.matches_val;
2252 struct guestfs_message_header hdr;
2253 struct guestfs_message_error err;
2256 static void rm_cb (guestfs_h *g, void *data, XDR *xdr)
2258 struct rm_state *state = (struct rm_state *) data;
2260 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2261 error (g, "guestfs_rm: failed to parse reply header");
2264 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2265 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2266 error (g, "guestfs_rm: failed to parse reply error");
2273 g->main_loop->main_loop_quit (g->main_loop, g);
2276 int guestfs_rm (guestfs_h *g,
2279 struct guestfs_rm_args args;
2280 struct rm_state state;
2283 if (g->state != READY) {
2284 if (g->state == CONFIG)
2285 error (g, "%s: call launch() before using this function",
2287 else if (g->state == LAUNCHING)
2288 error (g, "%s: call wait_ready() before using this function",
2291 error (g, "%s called from the wrong state, %d != READY",
2292 "guestfs_rm", g->state);
2296 memset (&state, 0, sizeof state);
2298 args.path = (char *) path;
2299 serial = dispatch (g, GUESTFS_PROC_RM,
2300 (xdrproc_t) xdr_guestfs_rm_args, (char *) &args);
2305 g->reply_cb_internal = rm_cb;
2306 g->reply_cb_internal_data = &state;
2307 (void) g->main_loop->main_loop_run (g->main_loop, g);
2308 g->reply_cb_internal = NULL;
2309 g->reply_cb_internal_data = NULL;
2310 if (!state.cb_done) {
2311 error (g, "guestfs_rm failed, see earlier error messages");
2315 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_RM, serial) == -1)
2318 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2319 error (g, "%s", state.err.error);
2326 struct rmdir_state {
2328 struct guestfs_message_header hdr;
2329 struct guestfs_message_error err;
2332 static void rmdir_cb (guestfs_h *g, void *data, XDR *xdr)
2334 struct rmdir_state *state = (struct rmdir_state *) data;
2336 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2337 error (g, "guestfs_rmdir: failed to parse reply header");
2340 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2341 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2342 error (g, "guestfs_rmdir: failed to parse reply error");
2349 g->main_loop->main_loop_quit (g->main_loop, g);
2352 int guestfs_rmdir (guestfs_h *g,
2355 struct guestfs_rmdir_args args;
2356 struct rmdir_state state;
2359 if (g->state != READY) {
2360 if (g->state == CONFIG)
2361 error (g, "%s: call launch() before using this function",
2363 else if (g->state == LAUNCHING)
2364 error (g, "%s: call wait_ready() before using this function",
2367 error (g, "%s called from the wrong state, %d != READY",
2368 "guestfs_rmdir", g->state);
2372 memset (&state, 0, sizeof state);
2374 args.path = (char *) path;
2375 serial = dispatch (g, GUESTFS_PROC_RMDIR,
2376 (xdrproc_t) xdr_guestfs_rmdir_args, (char *) &args);
2381 g->reply_cb_internal = rmdir_cb;
2382 g->reply_cb_internal_data = &state;
2383 (void) g->main_loop->main_loop_run (g->main_loop, g);
2384 g->reply_cb_internal = NULL;
2385 g->reply_cb_internal_data = NULL;
2386 if (!state.cb_done) {
2387 error (g, "guestfs_rmdir failed, see earlier error messages");
2391 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_RMDIR, serial) == -1)
2394 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2395 error (g, "%s", state.err.error);
2402 struct rm_rf_state {
2404 struct guestfs_message_header hdr;
2405 struct guestfs_message_error err;
2408 static void rm_rf_cb (guestfs_h *g, void *data, XDR *xdr)
2410 struct rm_rf_state *state = (struct rm_rf_state *) data;
2412 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2413 error (g, "guestfs_rm_rf: failed to parse reply header");
2416 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2417 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2418 error (g, "guestfs_rm_rf: failed to parse reply error");
2425 g->main_loop->main_loop_quit (g->main_loop, g);
2428 int guestfs_rm_rf (guestfs_h *g,
2431 struct guestfs_rm_rf_args args;
2432 struct rm_rf_state state;
2435 if (g->state != READY) {
2436 if (g->state == CONFIG)
2437 error (g, "%s: call launch() before using this function",
2439 else if (g->state == LAUNCHING)
2440 error (g, "%s: call wait_ready() before using this function",
2443 error (g, "%s called from the wrong state, %d != READY",
2444 "guestfs_rm_rf", g->state);
2448 memset (&state, 0, sizeof state);
2450 args.path = (char *) path;
2451 serial = dispatch (g, GUESTFS_PROC_RM_RF,
2452 (xdrproc_t) xdr_guestfs_rm_rf_args, (char *) &args);
2457 g->reply_cb_internal = rm_rf_cb;
2458 g->reply_cb_internal_data = &state;
2459 (void) g->main_loop->main_loop_run (g->main_loop, g);
2460 g->reply_cb_internal = NULL;
2461 g->reply_cb_internal_data = NULL;
2462 if (!state.cb_done) {
2463 error (g, "guestfs_rm_rf failed, see earlier error messages");
2467 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_RM_RF, serial) == -1)
2470 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2471 error (g, "%s", state.err.error);
2478 struct mkdir_state {
2480 struct guestfs_message_header hdr;
2481 struct guestfs_message_error err;
2484 static void mkdir_cb (guestfs_h *g, void *data, XDR *xdr)
2486 struct mkdir_state *state = (struct mkdir_state *) data;
2488 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2489 error (g, "guestfs_mkdir: failed to parse reply header");
2492 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2493 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2494 error (g, "guestfs_mkdir: failed to parse reply error");
2501 g->main_loop->main_loop_quit (g->main_loop, g);
2504 int guestfs_mkdir (guestfs_h *g,
2507 struct guestfs_mkdir_args args;
2508 struct mkdir_state state;
2511 if (g->state != READY) {
2512 if (g->state == CONFIG)
2513 error (g, "%s: call launch() before using this function",
2515 else if (g->state == LAUNCHING)
2516 error (g, "%s: call wait_ready() before using this function",
2519 error (g, "%s called from the wrong state, %d != READY",
2520 "guestfs_mkdir", g->state);
2524 memset (&state, 0, sizeof state);
2526 args.path = (char *) path;
2527 serial = dispatch (g, GUESTFS_PROC_MKDIR,
2528 (xdrproc_t) xdr_guestfs_mkdir_args, (char *) &args);
2533 g->reply_cb_internal = mkdir_cb;
2534 g->reply_cb_internal_data = &state;
2535 (void) g->main_loop->main_loop_run (g->main_loop, g);
2536 g->reply_cb_internal = NULL;
2537 g->reply_cb_internal_data = NULL;
2538 if (!state.cb_done) {
2539 error (g, "guestfs_mkdir failed, see earlier error messages");
2543 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_MKDIR, serial) == -1)
2546 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2547 error (g, "%s", state.err.error);
2554 struct mkdir_p_state {
2556 struct guestfs_message_header hdr;
2557 struct guestfs_message_error err;
2560 static void mkdir_p_cb (guestfs_h *g, void *data, XDR *xdr)
2562 struct mkdir_p_state *state = (struct mkdir_p_state *) data;
2564 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2565 error (g, "guestfs_mkdir_p: failed to parse reply header");
2568 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2569 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2570 error (g, "guestfs_mkdir_p: failed to parse reply error");
2577 g->main_loop->main_loop_quit (g->main_loop, g);
2580 int guestfs_mkdir_p (guestfs_h *g,
2583 struct guestfs_mkdir_p_args args;
2584 struct mkdir_p_state state;
2587 if (g->state != READY) {
2588 if (g->state == CONFIG)
2589 error (g, "%s: call launch() before using this function",
2591 else if (g->state == LAUNCHING)
2592 error (g, "%s: call wait_ready() before using this function",
2595 error (g, "%s called from the wrong state, %d != READY",
2596 "guestfs_mkdir_p", g->state);
2600 memset (&state, 0, sizeof state);
2602 args.path = (char *) path;
2603 serial = dispatch (g, GUESTFS_PROC_MKDIR_P,
2604 (xdrproc_t) xdr_guestfs_mkdir_p_args, (char *) &args);
2609 g->reply_cb_internal = mkdir_p_cb;
2610 g->reply_cb_internal_data = &state;
2611 (void) g->main_loop->main_loop_run (g->main_loop, g);
2612 g->reply_cb_internal = NULL;
2613 g->reply_cb_internal_data = NULL;
2614 if (!state.cb_done) {
2615 error (g, "guestfs_mkdir_p failed, see earlier error messages");
2619 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_MKDIR_P, serial) == -1)
2622 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2623 error (g, "%s", state.err.error);
2630 struct chmod_state {
2632 struct guestfs_message_header hdr;
2633 struct guestfs_message_error err;
2636 static void chmod_cb (guestfs_h *g, void *data, XDR *xdr)
2638 struct chmod_state *state = (struct chmod_state *) data;
2640 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2641 error (g, "guestfs_chmod: failed to parse reply header");
2644 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2645 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2646 error (g, "guestfs_chmod: failed to parse reply error");
2653 g->main_loop->main_loop_quit (g->main_loop, g);
2656 int guestfs_chmod (guestfs_h *g,
2660 struct guestfs_chmod_args args;
2661 struct chmod_state state;
2664 if (g->state != READY) {
2665 if (g->state == CONFIG)
2666 error (g, "%s: call launch() before using this function",
2668 else if (g->state == LAUNCHING)
2669 error (g, "%s: call wait_ready() before using this function",
2672 error (g, "%s called from the wrong state, %d != READY",
2673 "guestfs_chmod", g->state);
2677 memset (&state, 0, sizeof state);
2680 args.path = (char *) path;
2681 serial = dispatch (g, GUESTFS_PROC_CHMOD,
2682 (xdrproc_t) xdr_guestfs_chmod_args, (char *) &args);
2687 g->reply_cb_internal = chmod_cb;
2688 g->reply_cb_internal_data = &state;
2689 (void) g->main_loop->main_loop_run (g->main_loop, g);
2690 g->reply_cb_internal = NULL;
2691 g->reply_cb_internal_data = NULL;
2692 if (!state.cb_done) {
2693 error (g, "guestfs_chmod failed, see earlier error messages");
2697 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_CHMOD, serial) == -1)
2700 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2701 error (g, "%s", state.err.error);
2708 struct chown_state {
2710 struct guestfs_message_header hdr;
2711 struct guestfs_message_error err;
2714 static void chown_cb (guestfs_h *g, void *data, XDR *xdr)
2716 struct chown_state *state = (struct chown_state *) data;
2718 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2719 error (g, "guestfs_chown: failed to parse reply header");
2722 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2723 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2724 error (g, "guestfs_chown: failed to parse reply error");
2731 g->main_loop->main_loop_quit (g->main_loop, g);
2734 int guestfs_chown (guestfs_h *g,
2739 struct guestfs_chown_args args;
2740 struct chown_state state;
2743 if (g->state != READY) {
2744 if (g->state == CONFIG)
2745 error (g, "%s: call launch() before using this function",
2747 else if (g->state == LAUNCHING)
2748 error (g, "%s: call wait_ready() before using this function",
2751 error (g, "%s called from the wrong state, %d != READY",
2752 "guestfs_chown", g->state);
2756 memset (&state, 0, sizeof state);
2760 args.path = (char *) path;
2761 serial = dispatch (g, GUESTFS_PROC_CHOWN,
2762 (xdrproc_t) xdr_guestfs_chown_args, (char *) &args);
2767 g->reply_cb_internal = chown_cb;
2768 g->reply_cb_internal_data = &state;
2769 (void) g->main_loop->main_loop_run (g->main_loop, g);
2770 g->reply_cb_internal = NULL;
2771 g->reply_cb_internal_data = NULL;
2772 if (!state.cb_done) {
2773 error (g, "guestfs_chown failed, see earlier error messages");
2777 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_CHOWN, serial) == -1)
2780 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2781 error (g, "%s", state.err.error);
2788 struct exists_state {
2790 struct guestfs_message_header hdr;
2791 struct guestfs_message_error err;
2792 struct guestfs_exists_ret ret;
2795 static void exists_cb (guestfs_h *g, void *data, XDR *xdr)
2797 struct exists_state *state = (struct exists_state *) data;
2799 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2800 error (g, "guestfs_exists: failed to parse reply header");
2803 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2804 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2805 error (g, "guestfs_exists: failed to parse reply error");
2810 if (!xdr_guestfs_exists_ret (xdr, &state->ret)) {
2811 error (g, "guestfs_exists: failed to parse reply");
2816 g->main_loop->main_loop_quit (g->main_loop, g);
2819 int guestfs_exists (guestfs_h *g,
2822 struct guestfs_exists_args args;
2823 struct exists_state state;
2826 if (g->state != READY) {
2827 if (g->state == CONFIG)
2828 error (g, "%s: call launch() before using this function",
2830 else if (g->state == LAUNCHING)
2831 error (g, "%s: call wait_ready() before using this function",
2834 error (g, "%s called from the wrong state, %d != READY",
2835 "guestfs_exists", g->state);
2839 memset (&state, 0, sizeof state);
2841 args.path = (char *) path;
2842 serial = dispatch (g, GUESTFS_PROC_EXISTS,
2843 (xdrproc_t) xdr_guestfs_exists_args, (char *) &args);
2848 g->reply_cb_internal = exists_cb;
2849 g->reply_cb_internal_data = &state;
2850 (void) g->main_loop->main_loop_run (g->main_loop, g);
2851 g->reply_cb_internal = NULL;
2852 g->reply_cb_internal_data = NULL;
2853 if (!state.cb_done) {
2854 error (g, "guestfs_exists failed, see earlier error messages");
2858 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_EXISTS, serial) == -1)
2861 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2862 error (g, "%s", state.err.error);
2866 return state.ret.existsflag;
2869 struct is_file_state {
2871 struct guestfs_message_header hdr;
2872 struct guestfs_message_error err;
2873 struct guestfs_is_file_ret ret;
2876 static void is_file_cb (guestfs_h *g, void *data, XDR *xdr)
2878 struct is_file_state *state = (struct is_file_state *) data;
2880 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2881 error (g, "guestfs_is_file: failed to parse reply header");
2884 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2885 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2886 error (g, "guestfs_is_file: failed to parse reply error");
2891 if (!xdr_guestfs_is_file_ret (xdr, &state->ret)) {
2892 error (g, "guestfs_is_file: failed to parse reply");
2897 g->main_loop->main_loop_quit (g->main_loop, g);
2900 int guestfs_is_file (guestfs_h *g,
2903 struct guestfs_is_file_args args;
2904 struct is_file_state state;
2907 if (g->state != READY) {
2908 if (g->state == CONFIG)
2909 error (g, "%s: call launch() before using this function",
2911 else if (g->state == LAUNCHING)
2912 error (g, "%s: call wait_ready() before using this function",
2915 error (g, "%s called from the wrong state, %d != READY",
2916 "guestfs_is_file", g->state);
2920 memset (&state, 0, sizeof state);
2922 args.path = (char *) path;
2923 serial = dispatch (g, GUESTFS_PROC_IS_FILE,
2924 (xdrproc_t) xdr_guestfs_is_file_args, (char *) &args);
2929 g->reply_cb_internal = is_file_cb;
2930 g->reply_cb_internal_data = &state;
2931 (void) g->main_loop->main_loop_run (g->main_loop, g);
2932 g->reply_cb_internal = NULL;
2933 g->reply_cb_internal_data = NULL;
2934 if (!state.cb_done) {
2935 error (g, "guestfs_is_file failed, see earlier error messages");
2939 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_IS_FILE, serial) == -1)
2942 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
2943 error (g, "%s", state.err.error);
2947 return state.ret.fileflag;
2950 struct is_dir_state {
2952 struct guestfs_message_header hdr;
2953 struct guestfs_message_error err;
2954 struct guestfs_is_dir_ret ret;
2957 static void is_dir_cb (guestfs_h *g, void *data, XDR *xdr)
2959 struct is_dir_state *state = (struct is_dir_state *) data;
2961 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
2962 error (g, "guestfs_is_dir: failed to parse reply header");
2965 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
2966 if (!xdr_guestfs_message_error (xdr, &state->err)) {
2967 error (g, "guestfs_is_dir: failed to parse reply error");
2972 if (!xdr_guestfs_is_dir_ret (xdr, &state->ret)) {
2973 error (g, "guestfs_is_dir: failed to parse reply");
2978 g->main_loop->main_loop_quit (g->main_loop, g);
2981 int guestfs_is_dir (guestfs_h *g,
2984 struct guestfs_is_dir_args args;
2985 struct is_dir_state state;
2988 if (g->state != READY) {
2989 if (g->state == CONFIG)
2990 error (g, "%s: call launch() before using this function",
2992 else if (g->state == LAUNCHING)
2993 error (g, "%s: call wait_ready() before using this function",
2996 error (g, "%s called from the wrong state, %d != READY",
2997 "guestfs_is_dir", g->state);
3001 memset (&state, 0, sizeof state);
3003 args.path = (char *) path;
3004 serial = dispatch (g, GUESTFS_PROC_IS_DIR,
3005 (xdrproc_t) xdr_guestfs_is_dir_args, (char *) &args);
3010 g->reply_cb_internal = is_dir_cb;
3011 g->reply_cb_internal_data = &state;
3012 (void) g->main_loop->main_loop_run (g->main_loop, g);
3013 g->reply_cb_internal = NULL;
3014 g->reply_cb_internal_data = NULL;
3015 if (!state.cb_done) {
3016 error (g, "guestfs_is_dir failed, see earlier error messages");
3020 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_IS_DIR, serial) == -1)
3023 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
3024 error (g, "%s", state.err.error);
3028 return state.ret.dirflag;
3031 struct pvcreate_state {
3033 struct guestfs_message_header hdr;
3034 struct guestfs_message_error err;
3037 static void pvcreate_cb (guestfs_h *g, void *data, XDR *xdr)
3039 struct pvcreate_state *state = (struct pvcreate_state *) data;
3041 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
3042 error (g, "guestfs_pvcreate: failed to parse reply header");
3045 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
3046 if (!xdr_guestfs_message_error (xdr, &state->err)) {
3047 error (g, "guestfs_pvcreate: failed to parse reply error");
3054 g->main_loop->main_loop_quit (g->main_loop, g);
3057 int guestfs_pvcreate (guestfs_h *g,
3060 struct guestfs_pvcreate_args args;
3061 struct pvcreate_state state;
3064 if (g->state != READY) {
3065 if (g->state == CONFIG)
3066 error (g, "%s: call launch() before using this function",
3067 "guestfs_pvcreate");
3068 else if (g->state == LAUNCHING)
3069 error (g, "%s: call wait_ready() before using this function",
3070 "guestfs_pvcreate");
3072 error (g, "%s called from the wrong state, %d != READY",
3073 "guestfs_pvcreate", g->state);
3077 memset (&state, 0, sizeof state);
3079 args.device = (char *) device;
3080 serial = dispatch (g, GUESTFS_PROC_PVCREATE,
3081 (xdrproc_t) xdr_guestfs_pvcreate_args, (char *) &args);
3086 g->reply_cb_internal = pvcreate_cb;
3087 g->reply_cb_internal_data = &state;
3088 (void) g->main_loop->main_loop_run (g->main_loop, g);
3089 g->reply_cb_internal = NULL;
3090 g->reply_cb_internal_data = NULL;
3091 if (!state.cb_done) {
3092 error (g, "guestfs_pvcreate failed, see earlier error messages");
3096 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_PVCREATE, serial) == -1)
3099 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
3100 error (g, "%s", state.err.error);
3107 struct vgcreate_state {
3109 struct guestfs_message_header hdr;
3110 struct guestfs_message_error err;
3113 static void vgcreate_cb (guestfs_h *g, void *data, XDR *xdr)
3115 struct vgcreate_state *state = (struct vgcreate_state *) data;
3117 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
3118 error (g, "guestfs_vgcreate: failed to parse reply header");
3121 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
3122 if (!xdr_guestfs_message_error (xdr, &state->err)) {
3123 error (g, "guestfs_vgcreate: failed to parse reply error");
3130 g->main_loop->main_loop_quit (g->main_loop, g);
3133 int guestfs_vgcreate (guestfs_h *g,
3134 const char *volgroup,
3135 char * const* const physvols)
3137 struct guestfs_vgcreate_args args;
3138 struct vgcreate_state state;
3141 if (g->state != READY) {
3142 if (g->state == CONFIG)
3143 error (g, "%s: call launch() before using this function",
3144 "guestfs_vgcreate");
3145 else if (g->state == LAUNCHING)
3146 error (g, "%s: call wait_ready() before using this function",
3147 "guestfs_vgcreate");
3149 error (g, "%s called from the wrong state, %d != READY",
3150 "guestfs_vgcreate", g->state);
3154 memset (&state, 0, sizeof state);
3156 args.volgroup = (char *) volgroup;
3157 args.physvols.physvols_val = (char **) physvols;
3158 for (args.physvols.physvols_len = 0; physvols[args.physvols.physvols_len]; args.physvols.physvols_len++) ;
3159 serial = dispatch (g, GUESTFS_PROC_VGCREATE,
3160 (xdrproc_t) xdr_guestfs_vgcreate_args, (char *) &args);
3165 g->reply_cb_internal = vgcreate_cb;
3166 g->reply_cb_internal_data = &state;
3167 (void) g->main_loop->main_loop_run (g->main_loop, g);
3168 g->reply_cb_internal = NULL;
3169 g->reply_cb_internal_data = NULL;
3170 if (!state.cb_done) {
3171 error (g, "guestfs_vgcreate failed, see earlier error messages");
3175 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_VGCREATE, serial) == -1)
3178 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
3179 error (g, "%s", state.err.error);
3186 struct lvcreate_state {
3188 struct guestfs_message_header hdr;
3189 struct guestfs_message_error err;
3192 static void lvcreate_cb (guestfs_h *g, void *data, XDR *xdr)
3194 struct lvcreate_state *state = (struct lvcreate_state *) data;
3196 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
3197 error (g, "guestfs_lvcreate: failed to parse reply header");
3200 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
3201 if (!xdr_guestfs_message_error (xdr, &state->err)) {
3202 error (g, "guestfs_lvcreate: failed to parse reply error");
3209 g->main_loop->main_loop_quit (g->main_loop, g);
3212 int guestfs_lvcreate (guestfs_h *g,
3214 const char *volgroup,
3217 struct guestfs_lvcreate_args args;
3218 struct lvcreate_state state;
3221 if (g->state != READY) {
3222 if (g->state == CONFIG)
3223 error (g, "%s: call launch() before using this function",
3224 "guestfs_lvcreate");
3225 else if (g->state == LAUNCHING)
3226 error (g, "%s: call wait_ready() before using this function",
3227 "guestfs_lvcreate");
3229 error (g, "%s called from the wrong state, %d != READY",
3230 "guestfs_lvcreate", g->state);
3234 memset (&state, 0, sizeof state);
3236 args.logvol = (char *) logvol;
3237 args.volgroup = (char *) volgroup;
3238 args.mbytes = mbytes;
3239 serial = dispatch (g, GUESTFS_PROC_LVCREATE,
3240 (xdrproc_t) xdr_guestfs_lvcreate_args, (char *) &args);
3245 g->reply_cb_internal = lvcreate_cb;
3246 g->reply_cb_internal_data = &state;
3247 (void) g->main_loop->main_loop_run (g->main_loop, g);
3248 g->reply_cb_internal = NULL;
3249 g->reply_cb_internal_data = NULL;
3250 if (!state.cb_done) {
3251 error (g, "guestfs_lvcreate failed, see earlier error messages");
3255 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_LVCREATE, serial) == -1)
3258 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
3259 error (g, "%s", state.err.error);
3268 struct guestfs_message_header hdr;
3269 struct guestfs_message_error err;
3272 static void mkfs_cb (guestfs_h *g, void *data, XDR *xdr)
3274 struct mkfs_state *state = (struct mkfs_state *) data;
3276 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
3277 error (g, "guestfs_mkfs: failed to parse reply header");
3280 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
3281 if (!xdr_guestfs_message_error (xdr, &state->err)) {
3282 error (g, "guestfs_mkfs: failed to parse reply error");
3289 g->main_loop->main_loop_quit (g->main_loop, g);
3292 int guestfs_mkfs (guestfs_h *g,
3296 struct guestfs_mkfs_args args;
3297 struct mkfs_state state;
3300 if (g->state != READY) {
3301 if (g->state == CONFIG)
3302 error (g, "%s: call launch() before using this function",
3304 else if (g->state == LAUNCHING)
3305 error (g, "%s: call wait_ready() before using this function",
3308 error (g, "%s called from the wrong state, %d != READY",
3309 "guestfs_mkfs", g->state);
3313 memset (&state, 0, sizeof state);
3315 args.fstype = (char *) fstype;
3316 args.device = (char *) device;
3317 serial = dispatch (g, GUESTFS_PROC_MKFS,
3318 (xdrproc_t) xdr_guestfs_mkfs_args, (char *) &args);
3323 g->reply_cb_internal = mkfs_cb;
3324 g->reply_cb_internal_data = &state;
3325 (void) g->main_loop->main_loop_run (g->main_loop, g);
3326 g->reply_cb_internal = NULL;
3327 g->reply_cb_internal_data = NULL;
3328 if (!state.cb_done) {
3329 error (g, "guestfs_mkfs failed, see earlier error messages");
3333 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_MKFS, serial) == -1)
3336 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
3337 error (g, "%s", state.err.error);
3344 struct sfdisk_state {
3346 struct guestfs_message_header hdr;
3347 struct guestfs_message_error err;
3350 static void sfdisk_cb (guestfs_h *g, void *data, XDR *xdr)
3352 struct sfdisk_state *state = (struct sfdisk_state *) data;
3354 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
3355 error (g, "guestfs_sfdisk: failed to parse reply header");
3358 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
3359 if (!xdr_guestfs_message_error (xdr, &state->err)) {
3360 error (g, "guestfs_sfdisk: failed to parse reply error");
3367 g->main_loop->main_loop_quit (g->main_loop, g);
3370 int guestfs_sfdisk (guestfs_h *g,
3375 char * const* const lines)
3377 struct guestfs_sfdisk_args args;
3378 struct sfdisk_state state;
3381 if (g->state != READY) {
3382 if (g->state == CONFIG)
3383 error (g, "%s: call launch() before using this function",
3385 else if (g->state == LAUNCHING)
3386 error (g, "%s: call wait_ready() before using this function",
3389 error (g, "%s called from the wrong state, %d != READY",
3390 "guestfs_sfdisk", g->state);
3394 memset (&state, 0, sizeof state);
3396 args.device = (char *) device;
3399 args.sectors = sectors;
3400 args.lines.lines_val = (char **) lines;
3401 for (args.lines.lines_len = 0; lines[args.lines.lines_len]; args.lines.lines_len++) ;
3402 serial = dispatch (g, GUESTFS_PROC_SFDISK,
3403 (xdrproc_t) xdr_guestfs_sfdisk_args, (char *) &args);
3408 g->reply_cb_internal = sfdisk_cb;
3409 g->reply_cb_internal_data = &state;
3410 (void) g->main_loop->main_loop_run (g->main_loop, g);
3411 g->reply_cb_internal = NULL;
3412 g->reply_cb_internal_data = NULL;
3413 if (!state.cb_done) {
3414 error (g, "guestfs_sfdisk failed, see earlier error messages");
3418 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_SFDISK, serial) == -1)
3421 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
3422 error (g, "%s", state.err.error);
3429 struct write_file_state {
3431 struct guestfs_message_header hdr;
3432 struct guestfs_message_error err;
3435 static void write_file_cb (guestfs_h *g, void *data, XDR *xdr)
3437 struct write_file_state *state = (struct write_file_state *) data;
3439 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
3440 error (g, "guestfs_write_file: failed to parse reply header");
3443 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
3444 if (!xdr_guestfs_message_error (xdr, &state->err)) {
3445 error (g, "guestfs_write_file: failed to parse reply error");
3452 g->main_loop->main_loop_quit (g->main_loop, g);
3455 int guestfs_write_file (guestfs_h *g,
3457 const char *content,
3460 struct guestfs_write_file_args args;
3461 struct write_file_state state;
3464 if (g->state != READY) {
3465 if (g->state == CONFIG)
3466 error (g, "%s: call launch() before using this function",
3467 "guestfs_write_file");
3468 else if (g->state == LAUNCHING)
3469 error (g, "%s: call wait_ready() before using this function",
3470 "guestfs_write_file");
3472 error (g, "%s called from the wrong state, %d != READY",
3473 "guestfs_write_file", g->state);
3477 memset (&state, 0, sizeof state);
3479 args.path = (char *) path;
3480 args.content = (char *) content;
3482 serial = dispatch (g, GUESTFS_PROC_WRITE_FILE,
3483 (xdrproc_t) xdr_guestfs_write_file_args, (char *) &args);
3488 g->reply_cb_internal = write_file_cb;
3489 g->reply_cb_internal_data = &state;
3490 (void) g->main_loop->main_loop_run (g->main_loop, g);
3491 g->reply_cb_internal = NULL;
3492 g->reply_cb_internal_data = NULL;
3493 if (!state.cb_done) {
3494 error (g, "guestfs_write_file failed, see earlier error messages");
3498 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_WRITE_FILE, serial) == -1)
3501 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
3502 error (g, "%s", state.err.error);
3509 struct umount_state {
3511 struct guestfs_message_header hdr;
3512 struct guestfs_message_error err;
3515 static void umount_cb (guestfs_h *g, void *data, XDR *xdr)
3517 struct umount_state *state = (struct umount_state *) data;
3519 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
3520 error (g, "guestfs_umount: failed to parse reply header");
3523 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
3524 if (!xdr_guestfs_message_error (xdr, &state->err)) {
3525 error (g, "guestfs_umount: failed to parse reply error");
3532 g->main_loop->main_loop_quit (g->main_loop, g);
3535 int guestfs_umount (guestfs_h *g,
3536 const char *pathordevice)
3538 struct guestfs_umount_args args;
3539 struct umount_state state;
3542 if (g->state != READY) {
3543 if (g->state == CONFIG)
3544 error (g, "%s: call launch() before using this function",
3546 else if (g->state == LAUNCHING)
3547 error (g, "%s: call wait_ready() before using this function",
3550 error (g, "%s called from the wrong state, %d != READY",
3551 "guestfs_umount", g->state);
3555 memset (&state, 0, sizeof state);
3557 args.pathordevice = (char *) pathordevice;
3558 serial = dispatch (g, GUESTFS_PROC_UMOUNT,
3559 (xdrproc_t) xdr_guestfs_umount_args, (char *) &args);
3564 g->reply_cb_internal = umount_cb;
3565 g->reply_cb_internal_data = &state;
3566 (void) g->main_loop->main_loop_run (g->main_loop, g);
3567 g->reply_cb_internal = NULL;
3568 g->reply_cb_internal_data = NULL;
3569 if (!state.cb_done) {
3570 error (g, "guestfs_umount failed, see earlier error messages");
3574 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_UMOUNT, serial) == -1)
3577 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
3578 error (g, "%s", state.err.error);
3585 struct mounts_state {
3587 struct guestfs_message_header hdr;
3588 struct guestfs_message_error err;
3589 struct guestfs_mounts_ret ret;
3592 static void mounts_cb (guestfs_h *g, void *data, XDR *xdr)
3594 struct mounts_state *state = (struct mounts_state *) data;
3596 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
3597 error (g, "guestfs_mounts: failed to parse reply header");
3600 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
3601 if (!xdr_guestfs_message_error (xdr, &state->err)) {
3602 error (g, "guestfs_mounts: failed to parse reply error");
3607 if (!xdr_guestfs_mounts_ret (xdr, &state->ret)) {
3608 error (g, "guestfs_mounts: failed to parse reply");
3613 g->main_loop->main_loop_quit (g->main_loop, g);
3616 char **guestfs_mounts (guestfs_h *g)
3618 struct mounts_state state;
3621 if (g->state != READY) {
3622 if (g->state == CONFIG)
3623 error (g, "%s: call launch() before using this function",
3625 else if (g->state == LAUNCHING)
3626 error (g, "%s: call wait_ready() before using this function",
3629 error (g, "%s called from the wrong state, %d != READY",
3630 "guestfs_mounts", g->state);
3634 memset (&state, 0, sizeof state);
3636 serial = dispatch (g, GUESTFS_PROC_MOUNTS, NULL, NULL);
3641 g->reply_cb_internal = mounts_cb;
3642 g->reply_cb_internal_data = &state;
3643 (void) g->main_loop->main_loop_run (g->main_loop, g);
3644 g->reply_cb_internal = NULL;
3645 g->reply_cb_internal_data = NULL;
3646 if (!state.cb_done) {
3647 error (g, "guestfs_mounts failed, see earlier error messages");
3651 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_MOUNTS, serial) == -1)
3654 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
3655 error (g, "%s", state.err.error);
3659 /* caller will free this, but we need to add a NULL entry */
3660 state.ret.devices.devices_val = safe_realloc (g, state.ret.devices.devices_val,
3661 sizeof (char *) * (state.ret.devices.devices_len + 1));
3662 state.ret.devices.devices_val[state.ret.devices.devices_len] = NULL;
3663 return state.ret.devices.devices_val;
3666 struct umount_all_state {
3668 struct guestfs_message_header hdr;
3669 struct guestfs_message_error err;
3672 static void umount_all_cb (guestfs_h *g, void *data, XDR *xdr)
3674 struct umount_all_state *state = (struct umount_all_state *) data;
3676 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
3677 error (g, "guestfs_umount_all: failed to parse reply header");
3680 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
3681 if (!xdr_guestfs_message_error (xdr, &state->err)) {
3682 error (g, "guestfs_umount_all: failed to parse reply error");
3689 g->main_loop->main_loop_quit (g->main_loop, g);
3692 int guestfs_umount_all (guestfs_h *g)
3694 struct umount_all_state state;
3697 if (g->state != READY) {
3698 if (g->state == CONFIG)
3699 error (g, "%s: call launch() before using this function",
3700 "guestfs_umount_all");
3701 else if (g->state == LAUNCHING)
3702 error (g, "%s: call wait_ready() before using this function",
3703 "guestfs_umount_all");
3705 error (g, "%s called from the wrong state, %d != READY",
3706 "guestfs_umount_all", g->state);
3710 memset (&state, 0, sizeof state);
3712 serial = dispatch (g, GUESTFS_PROC_UMOUNT_ALL, NULL, NULL);
3717 g->reply_cb_internal = umount_all_cb;
3718 g->reply_cb_internal_data = &state;
3719 (void) g->main_loop->main_loop_run (g->main_loop, g);
3720 g->reply_cb_internal = NULL;
3721 g->reply_cb_internal_data = NULL;
3722 if (!state.cb_done) {
3723 error (g, "guestfs_umount_all failed, see earlier error messages");
3727 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_UMOUNT_ALL, serial) == -1)
3730 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
3731 error (g, "%s", state.err.error);
3738 struct lvm_remove_all_state {
3740 struct guestfs_message_header hdr;
3741 struct guestfs_message_error err;
3744 static void lvm_remove_all_cb (guestfs_h *g, void *data, XDR *xdr)
3746 struct lvm_remove_all_state *state = (struct lvm_remove_all_state *) data;
3748 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
3749 error (g, "guestfs_lvm_remove_all: failed to parse reply header");
3752 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
3753 if (!xdr_guestfs_message_error (xdr, &state->err)) {
3754 error (g, "guestfs_lvm_remove_all: failed to parse reply error");
3761 g->main_loop->main_loop_quit (g->main_loop, g);
3764 int guestfs_lvm_remove_all (guestfs_h *g)
3766 struct lvm_remove_all_state state;
3769 if (g->state != READY) {
3770 if (g->state == CONFIG)
3771 error (g, "%s: call launch() before using this function",
3772 "guestfs_lvm_remove_all");
3773 else if (g->state == LAUNCHING)
3774 error (g, "%s: call wait_ready() before using this function",
3775 "guestfs_lvm_remove_all");
3777 error (g, "%s called from the wrong state, %d != READY",
3778 "guestfs_lvm_remove_all", g->state);
3782 memset (&state, 0, sizeof state);
3784 serial = dispatch (g, GUESTFS_PROC_LVM_REMOVE_ALL, NULL, NULL);
3789 g->reply_cb_internal = lvm_remove_all_cb;
3790 g->reply_cb_internal_data = &state;
3791 (void) g->main_loop->main_loop_run (g->main_loop, g);
3792 g->reply_cb_internal = NULL;
3793 g->reply_cb_internal_data = NULL;
3794 if (!state.cb_done) {
3795 error (g, "guestfs_lvm_remove_all failed, see earlier error messages");
3799 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_LVM_REMOVE_ALL, serial) == -1)
3802 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
3803 error (g, "%s", state.err.error);
3812 struct guestfs_message_header hdr;
3813 struct guestfs_message_error err;
3814 struct guestfs_file_ret ret;
3817 static void file_cb (guestfs_h *g, void *data, XDR *xdr)
3819 struct file_state *state = (struct file_state *) data;
3821 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
3822 error (g, "guestfs_file: failed to parse reply header");
3825 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
3826 if (!xdr_guestfs_message_error (xdr, &state->err)) {
3827 error (g, "guestfs_file: failed to parse reply error");
3832 if (!xdr_guestfs_file_ret (xdr, &state->ret)) {
3833 error (g, "guestfs_file: failed to parse reply");
3838 g->main_loop->main_loop_quit (g->main_loop, g);
3841 char *guestfs_file (guestfs_h *g,
3844 struct guestfs_file_args args;
3845 struct file_state state;
3848 if (g->state != READY) {
3849 if (g->state == CONFIG)
3850 error (g, "%s: call launch() before using this function",
3852 else if (g->state == LAUNCHING)
3853 error (g, "%s: call wait_ready() before using this function",
3856 error (g, "%s called from the wrong state, %d != READY",
3857 "guestfs_file", g->state);
3861 memset (&state, 0, sizeof state);
3863 args.path = (char *) path;
3864 serial = dispatch (g, GUESTFS_PROC_FILE,
3865 (xdrproc_t) xdr_guestfs_file_args, (char *) &args);
3870 g->reply_cb_internal = file_cb;
3871 g->reply_cb_internal_data = &state;
3872 (void) g->main_loop->main_loop_run (g->main_loop, g);
3873 g->reply_cb_internal = NULL;
3874 g->reply_cb_internal_data = NULL;
3875 if (!state.cb_done) {
3876 error (g, "guestfs_file failed, see earlier error messages");
3880 if (check_reply_header (g, &state.hdr, GUESTFS_PROC_FILE, serial) == -1)
3883 if (state.hdr.status == GUESTFS_STATUS_ERROR) {
3884 error (g, "%s", state.err.error);
3888 return state.ret.description; /* caller will free */
3891 struct command_state {
3893 struct guestfs_message_header hdr;
3894 struct guestfs_message_error err;
3895 struct guestfs_command_ret ret;
3898 static void command_cb (guestfs_h *g, void *data, XDR *xdr)
3900 struct command_state *state = (struct command_state *) data;
3902 if (!xdr_guestfs_message_header (xdr, &state->hdr)) {
3903 error (g, "guestfs_command: failed to parse reply header");
3906 if (state->hdr.status == GUESTFS_STATUS_ERROR) {
3907 if (!xdr_guestfs_message_error (xdr, &state->err)) {
3908 error (g, "guestfs_command: failed to parse reply error");
3913 if (!xdr_guestfs_command_ret (xdr, &state->ret)) {
3914 error (g, "guestfs_command: failed to parse reply");
3919 g->main_loop->main_loop_quit (g->main_loop, g);
3922 char *guestfs_command (guestfs_h *g,
3923 char * const* const arguments)
3925 struct guestfs_command_args args;
3926 struct command_state state;
3929 if (g->state != READY) {
3930 if (g->state == CONFIG)
3931 error (g, "%s: call launch() before using this function",
3933 else if (g->state == LAUNCHING)
3934 error (g, "%s: call wait_ready() before using this function",
3937 error (g, "%s called from the wrong state, %d != READY",
3938 "guestfs_command", g->state);