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 program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program 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
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #define _GNU_SOURCE // for strchrnul
29 #include <rpc/types.h>
33 #include "../src/guestfs_protocol.h"
36 static void mount_stub (XDR *xdr_in)
39 struct guestfs_mount_args args;
41 const char *mountpoint;
43 memset (&args, 0, sizeof args);
45 if (!xdr_guestfs_mount_args (xdr_in, &args)) {
46 reply_with_error ("%s: daemon failed to decode procedure arguments", "mount");
50 mountpoint = args.mountpoint;
52 r = do_mount (device, mountpoint);
54 /* do_mount has already called reply_with_error */
59 xdr_free ((xdrproc_t) xdr_guestfs_mount_args, (char *) &args);
62 static void sync_stub (XDR *xdr_in)
68 /* do_sync has already called reply_with_error */
75 static void touch_stub (XDR *xdr_in)
78 struct guestfs_touch_args args;
81 memset (&args, 0, sizeof args);
83 if (!xdr_guestfs_touch_args (xdr_in, &args)) {
84 reply_with_error ("%s: daemon failed to decode procedure arguments", "touch");
91 /* do_touch has already called reply_with_error */
96 xdr_free ((xdrproc_t) xdr_guestfs_touch_args, (char *) &args);
99 static void cat_stub (XDR *xdr_in)
102 struct guestfs_cat_args args;
105 memset (&args, 0, sizeof args);
107 if (!xdr_guestfs_cat_args (xdr_in, &args)) {
108 reply_with_error ("%s: daemon failed to decode procedure arguments", "cat");
115 /* do_cat has already called reply_with_error */
118 struct guestfs_cat_ret ret;
120 reply ((xdrproc_t) &xdr_guestfs_cat_ret, (char *) &ret);
123 xdr_free ((xdrproc_t) xdr_guestfs_cat_args, (char *) &args);
126 static void ll_stub (XDR *xdr_in)
129 struct guestfs_ll_args args;
130 const char *directory;
132 memset (&args, 0, sizeof args);
134 if (!xdr_guestfs_ll_args (xdr_in, &args)) {
135 reply_with_error ("%s: daemon failed to decode procedure arguments", "ll");
138 directory = args.directory;
140 r = do_ll (directory);
142 /* do_ll has already called reply_with_error */
145 struct guestfs_ll_ret ret;
147 reply ((xdrproc_t) &xdr_guestfs_ll_ret, (char *) &ret);
150 xdr_free ((xdrproc_t) xdr_guestfs_ll_args, (char *) &args);
153 static void ls_stub (XDR *xdr_in)
156 struct guestfs_ls_args args;
157 const char *directory;
159 memset (&args, 0, sizeof args);
161 if (!xdr_guestfs_ls_args (xdr_in, &args)) {
162 reply_with_error ("%s: daemon failed to decode procedure arguments", "ls");
165 directory = args.directory;
167 r = do_ls (directory);
169 /* do_ls has already called reply_with_error */
172 struct guestfs_ls_ret ret;
173 ret.listing.listing_len = count_strings (r);
174 ret.listing.listing_val = r;
175 reply ((xdrproc_t) &xdr_guestfs_ls_ret, (char *) &ret);
178 xdr_free ((xdrproc_t) xdr_guestfs_ls_args, (char *) &args);
181 static void list_devices_stub (XDR *xdr_in)
185 r = do_list_devices ();
187 /* do_list_devices has already called reply_with_error */
190 struct guestfs_list_devices_ret ret;
191 ret.devices.devices_len = count_strings (r);
192 ret.devices.devices_val = r;
193 reply ((xdrproc_t) &xdr_guestfs_list_devices_ret, (char *) &ret);
198 static void list_partitions_stub (XDR *xdr_in)
202 r = do_list_partitions ();
204 /* do_list_partitions has already called reply_with_error */
207 struct guestfs_list_partitions_ret ret;
208 ret.partitions.partitions_len = count_strings (r);
209 ret.partitions.partitions_val = r;
210 reply ((xdrproc_t) &xdr_guestfs_list_partitions_ret, (char *) &ret);
215 static void pvs_stub (XDR *xdr_in)
221 /* do_pvs has already called reply_with_error */
224 struct guestfs_pvs_ret ret;
225 ret.physvols.physvols_len = count_strings (r);
226 ret.physvols.physvols_val = r;
227 reply ((xdrproc_t) &xdr_guestfs_pvs_ret, (char *) &ret);
232 static void vgs_stub (XDR *xdr_in)
238 /* do_vgs has already called reply_with_error */
241 struct guestfs_vgs_ret ret;
242 ret.volgroups.volgroups_len = count_strings (r);
243 ret.volgroups.volgroups_val = r;
244 reply ((xdrproc_t) &xdr_guestfs_vgs_ret, (char *) &ret);
249 static void lvs_stub (XDR *xdr_in)
255 /* do_lvs has already called reply_with_error */
258 struct guestfs_lvs_ret ret;
259 ret.logvols.logvols_len = count_strings (r);
260 ret.logvols.logvols_val = r;
261 reply ((xdrproc_t) &xdr_guestfs_lvs_ret, (char *) &ret);
266 static void pvs_full_stub (XDR *xdr_in)
268 guestfs_lvm_int_pv_list *r;
272 /* do_pvs_full has already called reply_with_error */
275 struct guestfs_pvs_full_ret ret;
277 reply ((xdrproc_t) xdr_guestfs_pvs_full_ret, (char *) &ret);
278 xdr_free ((xdrproc_t) xdr_guestfs_pvs_full_ret, (char *) &ret);
282 static void vgs_full_stub (XDR *xdr_in)
284 guestfs_lvm_int_vg_list *r;
288 /* do_vgs_full has already called reply_with_error */
291 struct guestfs_vgs_full_ret ret;
293 reply ((xdrproc_t) xdr_guestfs_vgs_full_ret, (char *) &ret);
294 xdr_free ((xdrproc_t) xdr_guestfs_vgs_full_ret, (char *) &ret);
298 static void lvs_full_stub (XDR *xdr_in)
300 guestfs_lvm_int_lv_list *r;
304 /* do_lvs_full has already called reply_with_error */
307 struct guestfs_lvs_full_ret ret;
309 reply ((xdrproc_t) xdr_guestfs_lvs_full_ret, (char *) &ret);
310 xdr_free ((xdrproc_t) xdr_guestfs_lvs_full_ret, (char *) &ret);
314 static void read_lines_stub (XDR *xdr_in)
317 struct guestfs_read_lines_args args;
320 memset (&args, 0, sizeof args);
322 if (!xdr_guestfs_read_lines_args (xdr_in, &args)) {
323 reply_with_error ("%s: daemon failed to decode procedure arguments", "read_lines");
328 r = do_read_lines (path);
330 /* do_read_lines has already called reply_with_error */
333 struct guestfs_read_lines_ret ret;
334 ret.lines.lines_len = count_strings (r);
335 ret.lines.lines_val = r;
336 reply ((xdrproc_t) &xdr_guestfs_read_lines_ret, (char *) &ret);
339 xdr_free ((xdrproc_t) xdr_guestfs_read_lines_args, (char *) &args);
342 static void aug_init_stub (XDR *xdr_in)
345 struct guestfs_aug_init_args args;
349 memset (&args, 0, sizeof args);
351 if (!xdr_guestfs_aug_init_args (xdr_in, &args)) {
352 reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_init");
358 r = do_aug_init (root, flags);
360 /* do_aug_init has already called reply_with_error */
365 xdr_free ((xdrproc_t) xdr_guestfs_aug_init_args, (char *) &args);
368 static void aug_close_stub (XDR *xdr_in)
374 /* do_aug_close has already called reply_with_error */
381 static void aug_defvar_stub (XDR *xdr_in)
384 struct guestfs_aug_defvar_args args;
388 memset (&args, 0, sizeof args);
390 if (!xdr_guestfs_aug_defvar_args (xdr_in, &args)) {
391 reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_defvar");
395 expr = args.expr ? *args.expr : NULL;
397 r = do_aug_defvar (name, expr);
399 /* do_aug_defvar has already called reply_with_error */
402 struct guestfs_aug_defvar_ret ret;
404 reply ((xdrproc_t) &xdr_guestfs_aug_defvar_ret, (char *) &ret);
406 xdr_free ((xdrproc_t) xdr_guestfs_aug_defvar_args, (char *) &args);
409 static void aug_defnode_stub (XDR *xdr_in)
411 guestfs_aug_defnode_ret *r;
412 struct guestfs_aug_defnode_args args;
417 memset (&args, 0, sizeof args);
419 if (!xdr_guestfs_aug_defnode_args (xdr_in, &args)) {
420 reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_defnode");
427 r = do_aug_defnode (name, expr, val);
429 /* do_aug_defnode has already called reply_with_error */
432 reply ((xdrproc_t) xdr_guestfs_aug_defnode_ret, (char *) r);
433 xdr_free ((xdrproc_t) xdr_guestfs_aug_defnode_ret, (char *) r);
435 xdr_free ((xdrproc_t) xdr_guestfs_aug_defnode_args, (char *) &args);
438 static void aug_get_stub (XDR *xdr_in)
441 struct guestfs_aug_get_args args;
444 memset (&args, 0, sizeof args);
446 if (!xdr_guestfs_aug_get_args (xdr_in, &args)) {
447 reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_get");
452 r = do_aug_get (path);
454 /* do_aug_get has already called reply_with_error */
457 struct guestfs_aug_get_ret ret;
459 reply ((xdrproc_t) &xdr_guestfs_aug_get_ret, (char *) &ret);
462 xdr_free ((xdrproc_t) xdr_guestfs_aug_get_args, (char *) &args);
465 static void aug_set_stub (XDR *xdr_in)
468 struct guestfs_aug_set_args args;
472 memset (&args, 0, sizeof args);
474 if (!xdr_guestfs_aug_set_args (xdr_in, &args)) {
475 reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_set");
481 r = do_aug_set (path, val);
483 /* do_aug_set has already called reply_with_error */
488 xdr_free ((xdrproc_t) xdr_guestfs_aug_set_args, (char *) &args);
491 static void aug_insert_stub (XDR *xdr_in)
494 struct guestfs_aug_insert_args args;
499 memset (&args, 0, sizeof args);
501 if (!xdr_guestfs_aug_insert_args (xdr_in, &args)) {
502 reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_insert");
507 before = args.before;
509 r = do_aug_insert (path, label, before);
511 /* do_aug_insert has already called reply_with_error */
516 xdr_free ((xdrproc_t) xdr_guestfs_aug_insert_args, (char *) &args);
519 static void aug_rm_stub (XDR *xdr_in)
522 struct guestfs_aug_rm_args args;
525 memset (&args, 0, sizeof args);
527 if (!xdr_guestfs_aug_rm_args (xdr_in, &args)) {
528 reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_rm");
533 r = do_aug_rm (path);
535 /* do_aug_rm has already called reply_with_error */
538 struct guestfs_aug_rm_ret ret;
540 reply ((xdrproc_t) &xdr_guestfs_aug_rm_ret, (char *) &ret);
542 xdr_free ((xdrproc_t) xdr_guestfs_aug_rm_args, (char *) &args);
545 static void aug_mv_stub (XDR *xdr_in)
548 struct guestfs_aug_mv_args args;
552 memset (&args, 0, sizeof args);
554 if (!xdr_guestfs_aug_mv_args (xdr_in, &args)) {
555 reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_mv");
561 r = do_aug_mv (src, dest);
563 /* do_aug_mv has already called reply_with_error */
568 xdr_free ((xdrproc_t) xdr_guestfs_aug_mv_args, (char *) &args);
571 static void aug_match_stub (XDR *xdr_in)
574 struct guestfs_aug_match_args args;
577 memset (&args, 0, sizeof args);
579 if (!xdr_guestfs_aug_match_args (xdr_in, &args)) {
580 reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_match");
585 r = do_aug_match (path);
587 /* do_aug_match has already called reply_with_error */
590 struct guestfs_aug_match_ret ret;
591 ret.matches.matches_len = count_strings (r);
592 ret.matches.matches_val = r;
593 reply ((xdrproc_t) &xdr_guestfs_aug_match_ret, (char *) &ret);
596 xdr_free ((xdrproc_t) xdr_guestfs_aug_match_args, (char *) &args);
599 static void aug_save_stub (XDR *xdr_in)
605 /* do_aug_save has already called reply_with_error */
612 static void aug_load_stub (XDR *xdr_in)
618 /* do_aug_load has already called reply_with_error */
625 static void aug_ls_stub (XDR *xdr_in)
628 struct guestfs_aug_ls_args args;
631 memset (&args, 0, sizeof args);
633 if (!xdr_guestfs_aug_ls_args (xdr_in, &args)) {
634 reply_with_error ("%s: daemon failed to decode procedure arguments", "aug_ls");
639 r = do_aug_ls (path);
641 /* do_aug_ls has already called reply_with_error */
644 struct guestfs_aug_ls_ret ret;
645 ret.matches.matches_len = count_strings (r);
646 ret.matches.matches_val = r;
647 reply ((xdrproc_t) &xdr_guestfs_aug_ls_ret, (char *) &ret);
650 xdr_free ((xdrproc_t) xdr_guestfs_aug_ls_args, (char *) &args);
653 static void rm_stub (XDR *xdr_in)
656 struct guestfs_rm_args args;
659 memset (&args, 0, sizeof args);
661 if (!xdr_guestfs_rm_args (xdr_in, &args)) {
662 reply_with_error ("%s: daemon failed to decode procedure arguments", "rm");
669 /* do_rm has already called reply_with_error */
674 xdr_free ((xdrproc_t) xdr_guestfs_rm_args, (char *) &args);
677 static void rmdir_stub (XDR *xdr_in)
680 struct guestfs_rmdir_args args;
683 memset (&args, 0, sizeof args);
685 if (!xdr_guestfs_rmdir_args (xdr_in, &args)) {
686 reply_with_error ("%s: daemon failed to decode procedure arguments", "rmdir");
693 /* do_rmdir has already called reply_with_error */
698 xdr_free ((xdrproc_t) xdr_guestfs_rmdir_args, (char *) &args);
701 static void rm_rf_stub (XDR *xdr_in)
704 struct guestfs_rm_rf_args args;
707 memset (&args, 0, sizeof args);
709 if (!xdr_guestfs_rm_rf_args (xdr_in, &args)) {
710 reply_with_error ("%s: daemon failed to decode procedure arguments", "rm_rf");
717 /* do_rm_rf has already called reply_with_error */
722 xdr_free ((xdrproc_t) xdr_guestfs_rm_rf_args, (char *) &args);
725 static void mkdir_stub (XDR *xdr_in)
728 struct guestfs_mkdir_args args;
731 memset (&args, 0, sizeof args);
733 if (!xdr_guestfs_mkdir_args (xdr_in, &args)) {
734 reply_with_error ("%s: daemon failed to decode procedure arguments", "mkdir");
741 /* do_mkdir has already called reply_with_error */
746 xdr_free ((xdrproc_t) xdr_guestfs_mkdir_args, (char *) &args);
749 static void mkdir_p_stub (XDR *xdr_in)
752 struct guestfs_mkdir_p_args args;
755 memset (&args, 0, sizeof args);
757 if (!xdr_guestfs_mkdir_p_args (xdr_in, &args)) {
758 reply_with_error ("%s: daemon failed to decode procedure arguments", "mkdir_p");
763 r = do_mkdir_p (path);
765 /* do_mkdir_p has already called reply_with_error */
770 xdr_free ((xdrproc_t) xdr_guestfs_mkdir_p_args, (char *) &args);
773 static void chmod_stub (XDR *xdr_in)
776 struct guestfs_chmod_args args;
780 memset (&args, 0, sizeof args);
782 if (!xdr_guestfs_chmod_args (xdr_in, &args)) {
783 reply_with_error ("%s: daemon failed to decode procedure arguments", "chmod");
789 r = do_chmod (mode, path);
791 /* do_chmod has already called reply_with_error */
796 xdr_free ((xdrproc_t) xdr_guestfs_chmod_args, (char *) &args);
799 static void chown_stub (XDR *xdr_in)
802 struct guestfs_chown_args args;
807 memset (&args, 0, sizeof args);
809 if (!xdr_guestfs_chown_args (xdr_in, &args)) {
810 reply_with_error ("%s: daemon failed to decode procedure arguments", "chown");
817 r = do_chown (owner, group, path);
819 /* do_chown has already called reply_with_error */
824 xdr_free ((xdrproc_t) xdr_guestfs_chown_args, (char *) &args);
827 static void exists_stub (XDR *xdr_in)
830 struct guestfs_exists_args args;
833 memset (&args, 0, sizeof args);
835 if (!xdr_guestfs_exists_args (xdr_in, &args)) {
836 reply_with_error ("%s: daemon failed to decode procedure arguments", "exists");
841 r = do_exists (path);
843 /* do_exists has already called reply_with_error */
846 struct guestfs_exists_ret ret;
848 reply ((xdrproc_t) &xdr_guestfs_exists_ret, (char *) &ret);
850 xdr_free ((xdrproc_t) xdr_guestfs_exists_args, (char *) &args);
853 static void is_file_stub (XDR *xdr_in)
856 struct guestfs_is_file_args args;
859 memset (&args, 0, sizeof args);
861 if (!xdr_guestfs_is_file_args (xdr_in, &args)) {
862 reply_with_error ("%s: daemon failed to decode procedure arguments", "is_file");
867 r = do_is_file (path);
869 /* do_is_file has already called reply_with_error */
872 struct guestfs_is_file_ret ret;
874 reply ((xdrproc_t) &xdr_guestfs_is_file_ret, (char *) &ret);
876 xdr_free ((xdrproc_t) xdr_guestfs_is_file_args, (char *) &args);
879 static void is_dir_stub (XDR *xdr_in)
882 struct guestfs_is_dir_args args;
885 memset (&args, 0, sizeof args);
887 if (!xdr_guestfs_is_dir_args (xdr_in, &args)) {
888 reply_with_error ("%s: daemon failed to decode procedure arguments", "is_dir");
893 r = do_is_dir (path);
895 /* do_is_dir has already called reply_with_error */
898 struct guestfs_is_dir_ret ret;
900 reply ((xdrproc_t) &xdr_guestfs_is_dir_ret, (char *) &ret);
902 xdr_free ((xdrproc_t) xdr_guestfs_is_dir_args, (char *) &args);
905 static void pvcreate_stub (XDR *xdr_in)
908 struct guestfs_pvcreate_args args;
911 memset (&args, 0, sizeof args);
913 if (!xdr_guestfs_pvcreate_args (xdr_in, &args)) {
914 reply_with_error ("%s: daemon failed to decode procedure arguments", "pvcreate");
917 device = args.device;
919 r = do_pvcreate (device);
921 /* do_pvcreate has already called reply_with_error */
926 xdr_free ((xdrproc_t) xdr_guestfs_pvcreate_args, (char *) &args);
929 static void vgcreate_stub (XDR *xdr_in)
932 struct guestfs_vgcreate_args args;
933 const char *volgroup;
936 memset (&args, 0, sizeof args);
938 if (!xdr_guestfs_vgcreate_args (xdr_in, &args)) {
939 reply_with_error ("%s: daemon failed to decode procedure arguments", "vgcreate");
942 volgroup = args.volgroup;
943 args.physvols.physvols_val = realloc (args.physvols.physvols_val, sizeof (char *) * (args.physvols.physvols_len+1));
944 args.physvols.physvols_val[args.physvols.physvols_len] = NULL;
945 physvols = args.physvols.physvols_val;
947 r = do_vgcreate (volgroup, physvols);
949 /* do_vgcreate has already called reply_with_error */
954 xdr_free ((xdrproc_t) xdr_guestfs_vgcreate_args, (char *) &args);
957 static void lvcreate_stub (XDR *xdr_in)
960 struct guestfs_lvcreate_args args;
962 const char *volgroup;
965 memset (&args, 0, sizeof args);
967 if (!xdr_guestfs_lvcreate_args (xdr_in, &args)) {
968 reply_with_error ("%s: daemon failed to decode procedure arguments", "lvcreate");
971 logvol = args.logvol;
972 volgroup = args.volgroup;
973 mbytes = args.mbytes;
975 r = do_lvcreate (logvol, volgroup, mbytes);
977 /* do_lvcreate has already called reply_with_error */
982 xdr_free ((xdrproc_t) xdr_guestfs_lvcreate_args, (char *) &args);
985 static void mkfs_stub (XDR *xdr_in)
988 struct guestfs_mkfs_args args;
992 memset (&args, 0, sizeof args);
994 if (!xdr_guestfs_mkfs_args (xdr_in, &args)) {
995 reply_with_error ("%s: daemon failed to decode procedure arguments", "mkfs");
998 fstype = args.fstype;
999 device = args.device;
1001 r = do_mkfs (fstype, device);
1003 /* do_mkfs has already called reply_with_error */
1008 xdr_free ((xdrproc_t) xdr_guestfs_mkfs_args, (char *) &args);
1011 static void sfdisk_stub (XDR *xdr_in)
1014 struct guestfs_sfdisk_args args;
1021 memset (&args, 0, sizeof args);
1023 if (!xdr_guestfs_sfdisk_args (xdr_in, &args)) {
1024 reply_with_error ("%s: daemon failed to decode procedure arguments", "sfdisk");
1027 device = args.device;
1030 sectors = args.sectors;
1031 args.lines.lines_val = realloc (args.lines.lines_val, sizeof (char *) * (args.lines.lines_len+1));
1032 args.lines.lines_val[args.lines.lines_len] = NULL;
1033 lines = args.lines.lines_val;
1035 r = do_sfdisk (device, cyls, heads, sectors, lines);
1037 /* do_sfdisk has already called reply_with_error */
1042 xdr_free ((xdrproc_t) xdr_guestfs_sfdisk_args, (char *) &args);
1045 static void write_file_stub (XDR *xdr_in)
1048 struct guestfs_write_file_args args;
1050 const char *content;
1053 memset (&args, 0, sizeof args);
1055 if (!xdr_guestfs_write_file_args (xdr_in, &args)) {
1056 reply_with_error ("%s: daemon failed to decode procedure arguments", "write_file");
1060 content = args.content;
1063 r = do_write_file (path, content, size);
1065 /* do_write_file has already called reply_with_error */
1070 xdr_free ((xdrproc_t) xdr_guestfs_write_file_args, (char *) &args);
1073 static void umount_stub (XDR *xdr_in)
1076 struct guestfs_umount_args args;
1077 const char *pathordevice;
1079 memset (&args, 0, sizeof args);
1081 if (!xdr_guestfs_umount_args (xdr_in, &args)) {
1082 reply_with_error ("%s: daemon failed to decode procedure arguments", "umount");
1085 pathordevice = args.pathordevice;
1087 r = do_umount (pathordevice);
1089 /* do_umount has already called reply_with_error */
1094 xdr_free ((xdrproc_t) xdr_guestfs_umount_args, (char *) &args);
1097 static void mounts_stub (XDR *xdr_in)
1103 /* do_mounts has already called reply_with_error */
1106 struct guestfs_mounts_ret ret;
1107 ret.devices.devices_len = count_strings (r);
1108 ret.devices.devices_val = r;
1109 reply ((xdrproc_t) &xdr_guestfs_mounts_ret, (char *) &ret);
1114 static void umount_all_stub (XDR *xdr_in)
1118 r = do_umount_all ();
1120 /* do_umount_all has already called reply_with_error */
1127 static void lvm_remove_all_stub (XDR *xdr_in)
1131 r = do_lvm_remove_all ();
1133 /* do_lvm_remove_all has already called reply_with_error */
1140 static void file_stub (XDR *xdr_in)
1143 struct guestfs_file_args args;
1146 memset (&args, 0, sizeof args);
1148 if (!xdr_guestfs_file_args (xdr_in, &args)) {
1149 reply_with_error ("%s: daemon failed to decode procedure arguments", "file");
1156 /* do_file has already called reply_with_error */
1159 struct guestfs_file_ret ret;
1160 ret.description = r;
1161 reply ((xdrproc_t) &xdr_guestfs_file_ret, (char *) &ret);
1164 xdr_free ((xdrproc_t) xdr_guestfs_file_args, (char *) &args);
1167 static void command_stub (XDR *xdr_in)
1170 struct guestfs_command_args args;
1173 memset (&args, 0, sizeof args);
1175 if (!xdr_guestfs_command_args (xdr_in, &args)) {
1176 reply_with_error ("%s: daemon failed to decode procedure arguments", "command");
1179 args.arguments.arguments_val = realloc (args.arguments.arguments_val, sizeof (char *) * (args.arguments.arguments_len+1));
1180 args.arguments.arguments_val[args.arguments.arguments_len] = NULL;
1181 arguments = args.arguments.arguments_val;
1183 r = do_command (arguments);
1185 /* do_command has already called reply_with_error */
1188 struct guestfs_command_ret ret;
1190 reply ((xdrproc_t) &xdr_guestfs_command_ret, (char *) &ret);
1193 xdr_free ((xdrproc_t) xdr_guestfs_command_args, (char *) &args);
1196 static void command_lines_stub (XDR *xdr_in)
1199 struct guestfs_command_lines_args args;
1202 memset (&args, 0, sizeof args);
1204 if (!xdr_guestfs_command_lines_args (xdr_in, &args)) {
1205 reply_with_error ("%s: daemon failed to decode procedure arguments", "command_lines");
1208 args.arguments.arguments_val = realloc (args.arguments.arguments_val, sizeof (char *) * (args.arguments.arguments_len+1));
1209 args.arguments.arguments_val[args.arguments.arguments_len] = NULL;
1210 arguments = args.arguments.arguments_val;
1212 r = do_command_lines (arguments);
1214 /* do_command_lines has already called reply_with_error */
1217 struct guestfs_command_lines_ret ret;
1218 ret.lines.lines_len = count_strings (r);
1219 ret.lines.lines_val = r;
1220 reply ((xdrproc_t) &xdr_guestfs_command_lines_ret, (char *) &ret);
1223 xdr_free ((xdrproc_t) xdr_guestfs_command_lines_args, (char *) &args);
1226 static void stat_stub (XDR *xdr_in)
1228 guestfs_int_stat *r;
1229 struct guestfs_stat_args args;
1232 memset (&args, 0, sizeof args);
1234 if (!xdr_guestfs_stat_args (xdr_in, &args)) {
1235 reply_with_error ("%s: daemon failed to decode procedure arguments", "stat");
1242 /* do_stat has already called reply_with_error */
1245 struct guestfs_stat_ret ret;
1247 reply ((xdrproc_t) xdr_guestfs_stat_ret, (char *) &ret);
1248 xdr_free ((xdrproc_t) xdr_guestfs_stat_ret, (char *) &ret);
1250 xdr_free ((xdrproc_t) xdr_guestfs_stat_args, (char *) &args);
1253 static void lstat_stub (XDR *xdr_in)
1255 guestfs_int_stat *r;
1256 struct guestfs_lstat_args args;
1259 memset (&args, 0, sizeof args);
1261 if (!xdr_guestfs_lstat_args (xdr_in, &args)) {
1262 reply_with_error ("%s: daemon failed to decode procedure arguments", "lstat");
1267 r = do_lstat (path);
1269 /* do_lstat has already called reply_with_error */
1272 struct guestfs_lstat_ret ret;
1274 reply ((xdrproc_t) xdr_guestfs_lstat_ret, (char *) &ret);
1275 xdr_free ((xdrproc_t) xdr_guestfs_lstat_ret, (char *) &ret);
1277 xdr_free ((xdrproc_t) xdr_guestfs_lstat_args, (char *) &args);
1280 static void statvfs_stub (XDR *xdr_in)
1282 guestfs_int_statvfs *r;
1283 struct guestfs_statvfs_args args;
1286 memset (&args, 0, sizeof args);
1288 if (!xdr_guestfs_statvfs_args (xdr_in, &args)) {
1289 reply_with_error ("%s: daemon failed to decode procedure arguments", "statvfs");
1294 r = do_statvfs (path);
1296 /* do_statvfs has already called reply_with_error */
1299 struct guestfs_statvfs_ret ret;
1301 reply ((xdrproc_t) xdr_guestfs_statvfs_ret, (char *) &ret);
1302 xdr_free ((xdrproc_t) xdr_guestfs_statvfs_ret, (char *) &ret);
1304 xdr_free ((xdrproc_t) xdr_guestfs_statvfs_args, (char *) &args);
1307 static void tune2fs_l_stub (XDR *xdr_in)
1310 struct guestfs_tune2fs_l_args args;
1313 memset (&args, 0, sizeof args);
1315 if (!xdr_guestfs_tune2fs_l_args (xdr_in, &args)) {
1316 reply_with_error ("%s: daemon failed to decode procedure arguments", "tune2fs_l");
1319 device = args.device;
1321 r = do_tune2fs_l (device);
1323 /* do_tune2fs_l has already called reply_with_error */
1326 struct guestfs_tune2fs_l_ret ret;
1327 ret.superblock.superblock_len = count_strings (r);
1328 ret.superblock.superblock_val = r;
1329 reply ((xdrproc_t) &xdr_guestfs_tune2fs_l_ret, (char *) &ret);
1332 xdr_free ((xdrproc_t) xdr_guestfs_tune2fs_l_args, (char *) &args);
1335 static void blockdev_setro_stub (XDR *xdr_in)
1338 struct guestfs_blockdev_setro_args args;
1341 memset (&args, 0, sizeof args);
1343 if (!xdr_guestfs_blockdev_setro_args (xdr_in, &args)) {
1344 reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_setro");
1347 device = args.device;
1349 r = do_blockdev_setro (device);
1351 /* do_blockdev_setro has already called reply_with_error */
1356 xdr_free ((xdrproc_t) xdr_guestfs_blockdev_setro_args, (char *) &args);
1359 static void blockdev_setrw_stub (XDR *xdr_in)
1362 struct guestfs_blockdev_setrw_args args;
1365 memset (&args, 0, sizeof args);
1367 if (!xdr_guestfs_blockdev_setrw_args (xdr_in, &args)) {
1368 reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_setrw");
1371 device = args.device;
1373 r = do_blockdev_setrw (device);
1375 /* do_blockdev_setrw has already called reply_with_error */
1380 xdr_free ((xdrproc_t) xdr_guestfs_blockdev_setrw_args, (char *) &args);
1383 static void blockdev_getro_stub (XDR *xdr_in)
1386 struct guestfs_blockdev_getro_args args;
1389 memset (&args, 0, sizeof args);
1391 if (!xdr_guestfs_blockdev_getro_args (xdr_in, &args)) {
1392 reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getro");
1395 device = args.device;
1397 r = do_blockdev_getro (device);
1399 /* do_blockdev_getro has already called reply_with_error */
1402 struct guestfs_blockdev_getro_ret ret;
1404 reply ((xdrproc_t) &xdr_guestfs_blockdev_getro_ret, (char *) &ret);
1406 xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getro_args, (char *) &args);
1409 static void blockdev_getss_stub (XDR *xdr_in)
1412 struct guestfs_blockdev_getss_args args;
1415 memset (&args, 0, sizeof args);
1417 if (!xdr_guestfs_blockdev_getss_args (xdr_in, &args)) {
1418 reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getss");
1421 device = args.device;
1423 r = do_blockdev_getss (device);
1425 /* do_blockdev_getss has already called reply_with_error */
1428 struct guestfs_blockdev_getss_ret ret;
1430 reply ((xdrproc_t) &xdr_guestfs_blockdev_getss_ret, (char *) &ret);
1432 xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getss_args, (char *) &args);
1435 static void blockdev_getbsz_stub (XDR *xdr_in)
1438 struct guestfs_blockdev_getbsz_args args;
1441 memset (&args, 0, sizeof args);
1443 if (!xdr_guestfs_blockdev_getbsz_args (xdr_in, &args)) {
1444 reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getbsz");
1447 device = args.device;
1449 r = do_blockdev_getbsz (device);
1451 /* do_blockdev_getbsz has already called reply_with_error */
1454 struct guestfs_blockdev_getbsz_ret ret;
1456 reply ((xdrproc_t) &xdr_guestfs_blockdev_getbsz_ret, (char *) &ret);
1458 xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getbsz_args, (char *) &args);
1461 static void blockdev_setbsz_stub (XDR *xdr_in)
1464 struct guestfs_blockdev_setbsz_args args;
1468 memset (&args, 0, sizeof args);
1470 if (!xdr_guestfs_blockdev_setbsz_args (xdr_in, &args)) {
1471 reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_setbsz");
1474 device = args.device;
1475 blocksize = args.blocksize;
1477 r = do_blockdev_setbsz (device, blocksize);
1479 /* do_blockdev_setbsz has already called reply_with_error */
1484 xdr_free ((xdrproc_t) xdr_guestfs_blockdev_setbsz_args, (char *) &args);
1487 static void blockdev_getsz_stub (XDR *xdr_in)
1490 struct guestfs_blockdev_getsz_args args;
1493 memset (&args, 0, sizeof args);
1495 if (!xdr_guestfs_blockdev_getsz_args (xdr_in, &args)) {
1496 reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getsz");
1499 device = args.device;
1501 r = do_blockdev_getsz (device);
1503 /* do_blockdev_getsz has already called reply_with_error */
1506 struct guestfs_blockdev_getsz_ret ret;
1507 ret.sizeinsectors = r;
1508 reply ((xdrproc_t) &xdr_guestfs_blockdev_getsz_ret, (char *) &ret);
1510 xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getsz_args, (char *) &args);
1513 static void blockdev_getsize64_stub (XDR *xdr_in)
1516 struct guestfs_blockdev_getsize64_args args;
1519 memset (&args, 0, sizeof args);
1521 if (!xdr_guestfs_blockdev_getsize64_args (xdr_in, &args)) {
1522 reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_getsize64");
1525 device = args.device;
1527 r = do_blockdev_getsize64 (device);
1529 /* do_blockdev_getsize64 has already called reply_with_error */
1532 struct guestfs_blockdev_getsize64_ret ret;
1533 ret.sizeinbytes = r;
1534 reply ((xdrproc_t) &xdr_guestfs_blockdev_getsize64_ret, (char *) &ret);
1536 xdr_free ((xdrproc_t) xdr_guestfs_blockdev_getsize64_args, (char *) &args);
1539 static void blockdev_flushbufs_stub (XDR *xdr_in)
1542 struct guestfs_blockdev_flushbufs_args args;
1545 memset (&args, 0, sizeof args);
1547 if (!xdr_guestfs_blockdev_flushbufs_args (xdr_in, &args)) {
1548 reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_flushbufs");
1551 device = args.device;
1553 r = do_blockdev_flushbufs (device);
1555 /* do_blockdev_flushbufs has already called reply_with_error */
1560 xdr_free ((xdrproc_t) xdr_guestfs_blockdev_flushbufs_args, (char *) &args);
1563 static void blockdev_rereadpt_stub (XDR *xdr_in)
1566 struct guestfs_blockdev_rereadpt_args args;
1569 memset (&args, 0, sizeof args);
1571 if (!xdr_guestfs_blockdev_rereadpt_args (xdr_in, &args)) {
1572 reply_with_error ("%s: daemon failed to decode procedure arguments", "blockdev_rereadpt");
1575 device = args.device;
1577 r = do_blockdev_rereadpt (device);
1579 /* do_blockdev_rereadpt has already called reply_with_error */
1584 xdr_free ((xdrproc_t) xdr_guestfs_blockdev_rereadpt_args, (char *) &args);
1587 static void upload_stub (XDR *xdr_in)
1590 struct guestfs_upload_args args;
1591 const char *remotefilename;
1593 memset (&args, 0, sizeof args);
1595 if (!xdr_guestfs_upload_args (xdr_in, &args)) {
1596 reply_with_error ("%s: daemon failed to decode procedure arguments", "upload");
1599 remotefilename = args.remotefilename;
1601 r = do_upload (remotefilename);
1603 /* do_upload has already called reply_with_error */
1608 xdr_free ((xdrproc_t) xdr_guestfs_upload_args, (char *) &args);
1611 static void download_stub (XDR *xdr_in)
1614 struct guestfs_download_args args;
1615 const char *remotefilename;
1617 memset (&args, 0, sizeof args);
1619 if (!xdr_guestfs_download_args (xdr_in, &args)) {
1620 reply_with_error ("%s: daemon failed to decode procedure arguments", "download");
1623 remotefilename = args.remotefilename;
1625 r = do_download (remotefilename);
1627 /* do_download has already called reply_with_error */
1630 /* do_download has already sent a reply */
1632 xdr_free ((xdrproc_t) xdr_guestfs_download_args, (char *) &args);
1635 static void checksum_stub (XDR *xdr_in)
1638 struct guestfs_checksum_args args;
1639 const char *csumtype;
1642 memset (&args, 0, sizeof args);
1644 if (!xdr_guestfs_checksum_args (xdr_in, &args)) {
1645 reply_with_error ("%s: daemon failed to decode procedure arguments", "checksum");
1648 csumtype = args.csumtype;
1651 r = do_checksum (csumtype, path);
1653 /* do_checksum has already called reply_with_error */
1656 struct guestfs_checksum_ret ret;
1658 reply ((xdrproc_t) &xdr_guestfs_checksum_ret, (char *) &ret);
1661 xdr_free ((xdrproc_t) xdr_guestfs_checksum_args, (char *) &args);
1664 void dispatch_incoming_message (XDR *xdr_in)
1667 case GUESTFS_PROC_MOUNT:
1668 mount_stub (xdr_in);
1670 case GUESTFS_PROC_SYNC:
1673 case GUESTFS_PROC_TOUCH:
1674 touch_stub (xdr_in);
1676 case GUESTFS_PROC_CAT:
1679 case GUESTFS_PROC_LL:
1682 case GUESTFS_PROC_LS:
1685 case GUESTFS_PROC_LIST_DEVICES:
1686 list_devices_stub (xdr_in);
1688 case GUESTFS_PROC_LIST_PARTITIONS:
1689 list_partitions_stub (xdr_in);
1691 case GUESTFS_PROC_PVS:
1694 case GUESTFS_PROC_VGS:
1697 case GUESTFS_PROC_LVS:
1700 case GUESTFS_PROC_PVS_FULL:
1701 pvs_full_stub (xdr_in);
1703 case GUESTFS_PROC_VGS_FULL:
1704 vgs_full_stub (xdr_in);
1706 case GUESTFS_PROC_LVS_FULL:
1707 lvs_full_stub (xdr_in);
1709 case GUESTFS_PROC_READ_LINES:
1710 read_lines_stub (xdr_in);
1712 case GUESTFS_PROC_AUG_INIT:
1713 aug_init_stub (xdr_in);
1715 case GUESTFS_PROC_AUG_CLOSE:
1716 aug_close_stub (xdr_in);
1718 case GUESTFS_PROC_AUG_DEFVAR:
1719 aug_defvar_stub (xdr_in);
1721 case GUESTFS_PROC_AUG_DEFNODE:
1722 aug_defnode_stub (xdr_in);
1724 case GUESTFS_PROC_AUG_GET:
1725 aug_get_stub (xdr_in);
1727 case GUESTFS_PROC_AUG_SET:
1728 aug_set_stub (xdr_in);
1730 case GUESTFS_PROC_AUG_INSERT:
1731 aug_insert_stub (xdr_in);
1733 case GUESTFS_PROC_AUG_RM:
1734 aug_rm_stub (xdr_in);
1736 case GUESTFS_PROC_AUG_MV:
1737 aug_mv_stub (xdr_in);
1739 case GUESTFS_PROC_AUG_MATCH:
1740 aug_match_stub (xdr_in);
1742 case GUESTFS_PROC_AUG_SAVE:
1743 aug_save_stub (xdr_in);
1745 case GUESTFS_PROC_AUG_LOAD:
1746 aug_load_stub (xdr_in);
1748 case GUESTFS_PROC_AUG_LS:
1749 aug_ls_stub (xdr_in);
1751 case GUESTFS_PROC_RM:
1754 case GUESTFS_PROC_RMDIR:
1755 rmdir_stub (xdr_in);
1757 case GUESTFS_PROC_RM_RF:
1758 rm_rf_stub (xdr_in);
1760 case GUESTFS_PROC_MKDIR:
1761 mkdir_stub (xdr_in);
1763 case GUESTFS_PROC_MKDIR_P:
1764 mkdir_p_stub (xdr_in);
1766 case GUESTFS_PROC_CHMOD:
1767 chmod_stub (xdr_in);
1769 case GUESTFS_PROC_CHOWN:
1770 chown_stub (xdr_in);
1772 case GUESTFS_PROC_EXISTS:
1773 exists_stub (xdr_in);
1775 case GUESTFS_PROC_IS_FILE:
1776 is_file_stub (xdr_in);
1778 case GUESTFS_PROC_IS_DIR:
1779 is_dir_stub (xdr_in);
1781 case GUESTFS_PROC_PVCREATE:
1782 pvcreate_stub (xdr_in);
1784 case GUESTFS_PROC_VGCREATE:
1785 vgcreate_stub (xdr_in);
1787 case GUESTFS_PROC_LVCREATE:
1788 lvcreate_stub (xdr_in);
1790 case GUESTFS_PROC_MKFS:
1793 case GUESTFS_PROC_SFDISK:
1794 sfdisk_stub (xdr_in);
1796 case GUESTFS_PROC_WRITE_FILE:
1797 write_file_stub (xdr_in);
1799 case GUESTFS_PROC_UMOUNT:
1800 umount_stub (xdr_in);
1802 case GUESTFS_PROC_MOUNTS:
1803 mounts_stub (xdr_in);
1805 case GUESTFS_PROC_UMOUNT_ALL:
1806 umount_all_stub (xdr_in);
1808 case GUESTFS_PROC_LVM_REMOVE_ALL:
1809 lvm_remove_all_stub (xdr_in);
1811 case GUESTFS_PROC_FILE:
1814 case GUESTFS_PROC_COMMAND:
1815 command_stub (xdr_in);
1817 case GUESTFS_PROC_COMMAND_LINES:
1818 command_lines_stub (xdr_in);
1820 case GUESTFS_PROC_STAT:
1823 case GUESTFS_PROC_LSTAT:
1824 lstat_stub (xdr_in);
1826 case GUESTFS_PROC_STATVFS:
1827 statvfs_stub (xdr_in);
1829 case GUESTFS_PROC_TUNE2FS_L:
1830 tune2fs_l_stub (xdr_in);
1832 case GUESTFS_PROC_BLOCKDEV_SETRO:
1833 blockdev_setro_stub (xdr_in);
1835 case GUESTFS_PROC_BLOCKDEV_SETRW:
1836 blockdev_setrw_stub (xdr_in);
1838 case GUESTFS_PROC_BLOCKDEV_GETRO:
1839 blockdev_getro_stub (xdr_in);
1841 case GUESTFS_PROC_BLOCKDEV_GETSS:
1842 blockdev_getss_stub (xdr_in);
1844 case GUESTFS_PROC_BLOCKDEV_GETBSZ:
1845 blockdev_getbsz_stub (xdr_in);
1847 case GUESTFS_PROC_BLOCKDEV_SETBSZ:
1848 blockdev_setbsz_stub (xdr_in);
1850 case GUESTFS_PROC_BLOCKDEV_GETSZ:
1851 blockdev_getsz_stub (xdr_in);
1853 case GUESTFS_PROC_BLOCKDEV_GETSIZE64:
1854 blockdev_getsize64_stub (xdr_in);
1856 case GUESTFS_PROC_BLOCKDEV_FLUSHBUFS:
1857 blockdev_flushbufs_stub (xdr_in);
1859 case GUESTFS_PROC_BLOCKDEV_REREADPT:
1860 blockdev_rereadpt_stub (xdr_in);
1862 case GUESTFS_PROC_UPLOAD:
1863 upload_stub (xdr_in);
1865 case GUESTFS_PROC_DOWNLOAD:
1866 download_stub (xdr_in);
1868 case GUESTFS_PROC_CHECKSUM:
1869 checksum_stub (xdr_in);
1872 reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr);
1876 static const char *lvm_pv_cols = "pv_name,pv_uuid,pv_fmt,pv_size,dev_size,pv_free,pv_used,pv_attr,pv_pe_count,pv_pe_alloc_count,pv_tags,pe_start,pv_mda_count,pv_mda_free";
1878 static int lvm_tokenize_pv (char *str, struct guestfs_lvm_int_pv *r)
1880 char *tok, *p, *next;
1884 fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
1887 if (!*str || isspace (*str)) {
1888 fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
1893 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_name");
1896 p = strchrnul (tok, ',');
1897 if (*p) next = p+1; else next = NULL;
1899 r->pv_name = strdup (tok);
1900 if (r->pv_name == NULL) {
1906 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_uuid");
1909 p = strchrnul (tok, ',');
1910 if (*p) next = p+1; else next = NULL;
1912 for (i = j = 0; i < 32; ++j) {
1913 if (tok[j] == '\0') {
1914 fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
1916 } else if (tok[j] != '-')
1917 r->pv_uuid[i++] = tok[j];
1921 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_fmt");
1924 p = strchrnul (tok, ',');
1925 if (*p) next = p+1; else next = NULL;
1927 r->pv_fmt = strdup (tok);
1928 if (r->pv_fmt == NULL) {
1934 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_size");
1937 p = strchrnul (tok, ',');
1938 if (*p) next = p+1; else next = NULL;
1940 if (sscanf (tok, "%"SCNu64, &r->pv_size) != 1) {
1941 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_size");
1946 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "dev_size");
1949 p = strchrnul (tok, ',');
1950 if (*p) next = p+1; else next = NULL;
1952 if (sscanf (tok, "%"SCNu64, &r->dev_size) != 1) {
1953 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "dev_size");
1958 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_free");
1961 p = strchrnul (tok, ',');
1962 if (*p) next = p+1; else next = NULL;
1964 if (sscanf (tok, "%"SCNu64, &r->pv_free) != 1) {
1965 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_free");
1970 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_used");
1973 p = strchrnul (tok, ',');
1974 if (*p) next = p+1; else next = NULL;
1976 if (sscanf (tok, "%"SCNu64, &r->pv_used) != 1) {
1977 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_used");
1982 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_attr");
1985 p = strchrnul (tok, ',');
1986 if (*p) next = p+1; else next = NULL;
1988 r->pv_attr = strdup (tok);
1989 if (r->pv_attr == NULL) {
1995 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_pe_count");
1998 p = strchrnul (tok, ',');
1999 if (*p) next = p+1; else next = NULL;
2001 if (sscanf (tok, "%"SCNi64, &r->pv_pe_count) != 1) {
2002 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_pe_count");
2007 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_pe_alloc_count");
2010 p = strchrnul (tok, ',');
2011 if (*p) next = p+1; else next = NULL;
2013 if (sscanf (tok, "%"SCNi64, &r->pv_pe_alloc_count) != 1) {
2014 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_pe_alloc_count");
2019 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_tags");
2022 p = strchrnul (tok, ',');
2023 if (*p) next = p+1; else next = NULL;
2025 r->pv_tags = strdup (tok);
2026 if (r->pv_tags == NULL) {
2032 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pe_start");
2035 p = strchrnul (tok, ',');
2036 if (*p) next = p+1; else next = NULL;
2038 if (sscanf (tok, "%"SCNu64, &r->pe_start) != 1) {
2039 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pe_start");
2044 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_mda_count");
2047 p = strchrnul (tok, ',');
2048 if (*p) next = p+1; else next = NULL;
2050 if (sscanf (tok, "%"SCNi64, &r->pv_mda_count) != 1) {
2051 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_mda_count");
2056 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_mda_free");
2059 p = strchrnul (tok, ',');
2060 if (*p) next = p+1; else next = NULL;
2062 if (sscanf (tok, "%"SCNu64, &r->pv_mda_free) != 1) {
2063 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_mda_free");
2068 fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
2074 guestfs_lvm_int_pv_list *
2075 parse_command_line_pvs (void)
2080 guestfs_lvm_int_pv_list *ret;
2083 ret = malloc (sizeof *ret);
2085 reply_with_perror ("malloc");
2089 ret->guestfs_lvm_int_pv_list_len = 0;
2090 ret->guestfs_lvm_int_pv_list_val = NULL;
2092 r = command (&out, &err,
2094 "-o", lvm_pv_cols, "--unbuffered", "--noheadings",
2095 "--nosuffix", "--separator", ",", "--units", "b", NULL);
2097 reply_with_error ("%s", err);
2106 /* Tokenize each line of the output. */
2110 pend = strchr (p, '\n'); /* Get the next line of output. */
2116 while (*p && isspace (*p)) /* Skip any leading whitespace. */
2119 if (!*p) { /* Empty line? Skip it. */
2124 /* Allocate some space to store this next entry. */
2125 newp = realloc (ret->guestfs_lvm_int_pv_list_val,
2126 sizeof (guestfs_lvm_int_pv) * (i+1));
2128 reply_with_perror ("realloc");
2129 free (ret->guestfs_lvm_int_pv_list_val);
2134 ret->guestfs_lvm_int_pv_list_val = newp;
2136 /* Tokenize the next entry. */
2137 r = lvm_tokenize_pv (p, &ret->guestfs_lvm_int_pv_list_val[i]);
2139 reply_with_error ("failed to parse output of 'pvs' command");
2140 free (ret->guestfs_lvm_int_pv_list_val);
2150 ret->guestfs_lvm_int_pv_list_len = i;
2155 static const char *lvm_vg_cols = "vg_name,vg_uuid,vg_fmt,vg_attr,vg_size,vg_free,vg_sysid,vg_extent_size,vg_extent_count,vg_free_count,max_lv,max_pv,pv_count,lv_count,snap_count,vg_seqno,vg_tags,vg_mda_count,vg_mda_free";
2157 static int lvm_tokenize_vg (char *str, struct guestfs_lvm_int_vg *r)
2159 char *tok, *p, *next;
2163 fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
2166 if (!*str || isspace (*str)) {
2167 fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
2172 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_name");
2175 p = strchrnul (tok, ',');
2176 if (*p) next = p+1; else next = NULL;
2178 r->vg_name = strdup (tok);
2179 if (r->vg_name == NULL) {
2185 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_uuid");
2188 p = strchrnul (tok, ',');
2189 if (*p) next = p+1; else next = NULL;
2191 for (i = j = 0; i < 32; ++j) {
2192 if (tok[j] == '\0') {
2193 fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
2195 } else if (tok[j] != '-')
2196 r->vg_uuid[i++] = tok[j];
2200 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_fmt");
2203 p = strchrnul (tok, ',');
2204 if (*p) next = p+1; else next = NULL;
2206 r->vg_fmt = strdup (tok);
2207 if (r->vg_fmt == NULL) {
2213 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_attr");
2216 p = strchrnul (tok, ',');
2217 if (*p) next = p+1; else next = NULL;
2219 r->vg_attr = strdup (tok);
2220 if (r->vg_attr == NULL) {
2226 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_size");
2229 p = strchrnul (tok, ',');
2230 if (*p) next = p+1; else next = NULL;
2232 if (sscanf (tok, "%"SCNu64, &r->vg_size) != 1) {
2233 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_size");
2238 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_free");
2241 p = strchrnul (tok, ',');
2242 if (*p) next = p+1; else next = NULL;
2244 if (sscanf (tok, "%"SCNu64, &r->vg_free) != 1) {
2245 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_free");
2250 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_sysid");
2253 p = strchrnul (tok, ',');
2254 if (*p) next = p+1; else next = NULL;
2256 r->vg_sysid = strdup (tok);
2257 if (r->vg_sysid == NULL) {
2263 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_extent_size");
2266 p = strchrnul (tok, ',');
2267 if (*p) next = p+1; else next = NULL;
2269 if (sscanf (tok, "%"SCNu64, &r->vg_extent_size) != 1) {
2270 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_extent_size");
2275 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_extent_count");
2278 p = strchrnul (tok, ',');
2279 if (*p) next = p+1; else next = NULL;
2281 if (sscanf (tok, "%"SCNi64, &r->vg_extent_count) != 1) {
2282 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_extent_count");
2287 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_free_count");
2290 p = strchrnul (tok, ',');
2291 if (*p) next = p+1; else next = NULL;
2293 if (sscanf (tok, "%"SCNi64, &r->vg_free_count) != 1) {
2294 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_free_count");
2299 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "max_lv");
2302 p = strchrnul (tok, ',');
2303 if (*p) next = p+1; else next = NULL;
2305 if (sscanf (tok, "%"SCNi64, &r->max_lv) != 1) {
2306 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "max_lv");
2311 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "max_pv");
2314 p = strchrnul (tok, ',');
2315 if (*p) next = p+1; else next = NULL;
2317 if (sscanf (tok, "%"SCNi64, &r->max_pv) != 1) {
2318 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "max_pv");
2323 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_count");
2326 p = strchrnul (tok, ',');
2327 if (*p) next = p+1; else next = NULL;
2329 if (sscanf (tok, "%"SCNi64, &r->pv_count) != 1) {
2330 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_count");
2335 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_count");
2338 p = strchrnul (tok, ',');
2339 if (*p) next = p+1; else next = NULL;
2341 if (sscanf (tok, "%"SCNi64, &r->lv_count) != 1) {
2342 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_count");
2347 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "snap_count");
2350 p = strchrnul (tok, ',');
2351 if (*p) next = p+1; else next = NULL;
2353 if (sscanf (tok, "%"SCNi64, &r->snap_count) != 1) {
2354 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "snap_count");
2359 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_seqno");
2362 p = strchrnul (tok, ',');
2363 if (*p) next = p+1; else next = NULL;
2365 if (sscanf (tok, "%"SCNi64, &r->vg_seqno) != 1) {
2366 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_seqno");
2371 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_tags");
2374 p = strchrnul (tok, ',');
2375 if (*p) next = p+1; else next = NULL;
2377 r->vg_tags = strdup (tok);
2378 if (r->vg_tags == NULL) {
2384 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_mda_count");
2387 p = strchrnul (tok, ',');
2388 if (*p) next = p+1; else next = NULL;
2390 if (sscanf (tok, "%"SCNi64, &r->vg_mda_count) != 1) {
2391 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_mda_count");
2396 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_mda_free");
2399 p = strchrnul (tok, ',');
2400 if (*p) next = p+1; else next = NULL;
2402 if (sscanf (tok, "%"SCNu64, &r->vg_mda_free) != 1) {
2403 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_mda_free");
2408 fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
2414 guestfs_lvm_int_vg_list *
2415 parse_command_line_vgs (void)
2420 guestfs_lvm_int_vg_list *ret;
2423 ret = malloc (sizeof *ret);
2425 reply_with_perror ("malloc");
2429 ret->guestfs_lvm_int_vg_list_len = 0;
2430 ret->guestfs_lvm_int_vg_list_val = NULL;
2432 r = command (&out, &err,
2434 "-o", lvm_vg_cols, "--unbuffered", "--noheadings",
2435 "--nosuffix", "--separator", ",", "--units", "b", NULL);
2437 reply_with_error ("%s", err);
2446 /* Tokenize each line of the output. */
2450 pend = strchr (p, '\n'); /* Get the next line of output. */
2456 while (*p && isspace (*p)) /* Skip any leading whitespace. */
2459 if (!*p) { /* Empty line? Skip it. */
2464 /* Allocate some space to store this next entry. */
2465 newp = realloc (ret->guestfs_lvm_int_vg_list_val,
2466 sizeof (guestfs_lvm_int_vg) * (i+1));
2468 reply_with_perror ("realloc");
2469 free (ret->guestfs_lvm_int_vg_list_val);
2474 ret->guestfs_lvm_int_vg_list_val = newp;
2476 /* Tokenize the next entry. */
2477 r = lvm_tokenize_vg (p, &ret->guestfs_lvm_int_vg_list_val[i]);
2479 reply_with_error ("failed to parse output of 'vgs' command");
2480 free (ret->guestfs_lvm_int_vg_list_val);
2490 ret->guestfs_lvm_int_vg_list_len = i;
2495 static const char *lvm_lv_cols = "lv_name,lv_uuid,lv_attr,lv_major,lv_minor,lv_kernel_major,lv_kernel_minor,lv_size,seg_count,origin,snap_percent,copy_percent,move_pv,lv_tags,mirror_log,modules";
2497 static int lvm_tokenize_lv (char *str, struct guestfs_lvm_int_lv *r)
2499 char *tok, *p, *next;
2503 fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
2506 if (!*str || isspace (*str)) {
2507 fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
2512 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_name");
2515 p = strchrnul (tok, ',');
2516 if (*p) next = p+1; else next = NULL;
2518 r->lv_name = strdup (tok);
2519 if (r->lv_name == NULL) {
2525 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_uuid");
2528 p = strchrnul (tok, ',');
2529 if (*p) next = p+1; else next = NULL;
2531 for (i = j = 0; i < 32; ++j) {
2532 if (tok[j] == '\0') {
2533 fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
2535 } else if (tok[j] != '-')
2536 r->lv_uuid[i++] = tok[j];
2540 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_attr");
2543 p = strchrnul (tok, ',');
2544 if (*p) next = p+1; else next = NULL;
2546 r->lv_attr = strdup (tok);
2547 if (r->lv_attr == NULL) {
2553 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_major");
2556 p = strchrnul (tok, ',');
2557 if (*p) next = p+1; else next = NULL;
2559 if (sscanf (tok, "%"SCNi64, &r->lv_major) != 1) {
2560 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_major");
2565 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_minor");
2568 p = strchrnul (tok, ',');
2569 if (*p) next = p+1; else next = NULL;
2571 if (sscanf (tok, "%"SCNi64, &r->lv_minor) != 1) {
2572 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_minor");
2577 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_kernel_major");
2580 p = strchrnul (tok, ',');
2581 if (*p) next = p+1; else next = NULL;
2583 if (sscanf (tok, "%"SCNi64, &r->lv_kernel_major) != 1) {
2584 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_kernel_major");
2589 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_kernel_minor");
2592 p = strchrnul (tok, ',');
2593 if (*p) next = p+1; else next = NULL;
2595 if (sscanf (tok, "%"SCNi64, &r->lv_kernel_minor) != 1) {
2596 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_kernel_minor");
2601 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_size");
2604 p = strchrnul (tok, ',');
2605 if (*p) next = p+1; else next = NULL;
2607 if (sscanf (tok, "%"SCNu64, &r->lv_size) != 1) {
2608 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "lv_size");
2613 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "seg_count");
2616 p = strchrnul (tok, ',');
2617 if (*p) next = p+1; else next = NULL;
2619 if (sscanf (tok, "%"SCNi64, &r->seg_count) != 1) {
2620 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "seg_count");
2625 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "origin");
2628 p = strchrnul (tok, ',');
2629 if (*p) next = p+1; else next = NULL;
2631 r->origin = strdup (tok);
2632 if (r->origin == NULL) {
2638 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "snap_percent");
2641 p = strchrnul (tok, ',');
2642 if (*p) next = p+1; else next = NULL;
2645 r->snap_percent = -1;
2646 else if (sscanf (tok, "%f", &r->snap_percent) != 1) {
2647 fprintf (stderr, "%s: failed to parse float '%s' from token %s\n", __func__, tok, "snap_percent");
2652 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "copy_percent");
2655 p = strchrnul (tok, ',');
2656 if (*p) next = p+1; else next = NULL;
2659 r->copy_percent = -1;
2660 else if (sscanf (tok, "%f", &r->copy_percent) != 1) {
2661 fprintf (stderr, "%s: failed to parse float '%s' from token %s\n", __func__, tok, "copy_percent");
2666 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "move_pv");
2669 p = strchrnul (tok, ',');
2670 if (*p) next = p+1; else next = NULL;
2672 r->move_pv = strdup (tok);
2673 if (r->move_pv == NULL) {
2679 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_tags");
2682 p = strchrnul (tok, ',');
2683 if (*p) next = p+1; else next = NULL;
2685 r->lv_tags = strdup (tok);
2686 if (r->lv_tags == NULL) {
2692 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "mirror_log");
2695 p = strchrnul (tok, ',');
2696 if (*p) next = p+1; else next = NULL;
2698 r->mirror_log = strdup (tok);
2699 if (r->mirror_log == NULL) {
2705 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "modules");
2708 p = strchrnul (tok, ',');
2709 if (*p) next = p+1; else next = NULL;
2711 r->modules = strdup (tok);
2712 if (r->modules == NULL) {
2718 fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
2724 guestfs_lvm_int_lv_list *
2725 parse_command_line_lvs (void)
2730 guestfs_lvm_int_lv_list *ret;
2733 ret = malloc (sizeof *ret);
2735 reply_with_perror ("malloc");
2739 ret->guestfs_lvm_int_lv_list_len = 0;
2740 ret->guestfs_lvm_int_lv_list_val = NULL;
2742 r = command (&out, &err,
2744 "-o", lvm_lv_cols, "--unbuffered", "--noheadings",
2745 "--nosuffix", "--separator", ",", "--units", "b", NULL);
2747 reply_with_error ("%s", err);
2756 /* Tokenize each line of the output. */
2760 pend = strchr (p, '\n'); /* Get the next line of output. */
2766 while (*p && isspace (*p)) /* Skip any leading whitespace. */
2769 if (!*p) { /* Empty line? Skip it. */
2774 /* Allocate some space to store this next entry. */
2775 newp = realloc (ret->guestfs_lvm_int_lv_list_val,
2776 sizeof (guestfs_lvm_int_lv) * (i+1));
2778 reply_with_perror ("realloc");
2779 free (ret->guestfs_lvm_int_lv_list_val);
2784 ret->guestfs_lvm_int_lv_list_val = newp;
2786 /* Tokenize the next entry. */
2787 r = lvm_tokenize_lv (p, &ret->guestfs_lvm_int_lv_list_val[i]);
2789 reply_with_error ("failed to parse output of 'lvs' command");
2790 free (ret->guestfs_lvm_int_lv_list_val);
2800 ret->guestfs_lvm_int_lv_list_len = i;