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 void dispatch_incoming_message (XDR *xdr_in)
1170 case GUESTFS_PROC_MOUNT:
1171 mount_stub (xdr_in);
1173 case GUESTFS_PROC_SYNC:
1176 case GUESTFS_PROC_TOUCH:
1177 touch_stub (xdr_in);
1179 case GUESTFS_PROC_CAT:
1182 case GUESTFS_PROC_LL:
1185 case GUESTFS_PROC_LS:
1188 case GUESTFS_PROC_LIST_DEVICES:
1189 list_devices_stub (xdr_in);
1191 case GUESTFS_PROC_LIST_PARTITIONS:
1192 list_partitions_stub (xdr_in);
1194 case GUESTFS_PROC_PVS:
1197 case GUESTFS_PROC_VGS:
1200 case GUESTFS_PROC_LVS:
1203 case GUESTFS_PROC_PVS_FULL:
1204 pvs_full_stub (xdr_in);
1206 case GUESTFS_PROC_VGS_FULL:
1207 vgs_full_stub (xdr_in);
1209 case GUESTFS_PROC_LVS_FULL:
1210 lvs_full_stub (xdr_in);
1212 case GUESTFS_PROC_READ_LINES:
1213 read_lines_stub (xdr_in);
1215 case GUESTFS_PROC_AUG_INIT:
1216 aug_init_stub (xdr_in);
1218 case GUESTFS_PROC_AUG_CLOSE:
1219 aug_close_stub (xdr_in);
1221 case GUESTFS_PROC_AUG_DEFVAR:
1222 aug_defvar_stub (xdr_in);
1224 case GUESTFS_PROC_AUG_DEFNODE:
1225 aug_defnode_stub (xdr_in);
1227 case GUESTFS_PROC_AUG_GET:
1228 aug_get_stub (xdr_in);
1230 case GUESTFS_PROC_AUG_SET:
1231 aug_set_stub (xdr_in);
1233 case GUESTFS_PROC_AUG_INSERT:
1234 aug_insert_stub (xdr_in);
1236 case GUESTFS_PROC_AUG_RM:
1237 aug_rm_stub (xdr_in);
1239 case GUESTFS_PROC_AUG_MV:
1240 aug_mv_stub (xdr_in);
1242 case GUESTFS_PROC_AUG_MATCH:
1243 aug_match_stub (xdr_in);
1245 case GUESTFS_PROC_AUG_SAVE:
1246 aug_save_stub (xdr_in);
1248 case GUESTFS_PROC_AUG_LOAD:
1249 aug_load_stub (xdr_in);
1251 case GUESTFS_PROC_AUG_LS:
1252 aug_ls_stub (xdr_in);
1254 case GUESTFS_PROC_RM:
1257 case GUESTFS_PROC_RMDIR:
1258 rmdir_stub (xdr_in);
1260 case GUESTFS_PROC_RM_RF:
1261 rm_rf_stub (xdr_in);
1263 case GUESTFS_PROC_MKDIR:
1264 mkdir_stub (xdr_in);
1266 case GUESTFS_PROC_MKDIR_P:
1267 mkdir_p_stub (xdr_in);
1269 case GUESTFS_PROC_CHMOD:
1270 chmod_stub (xdr_in);
1272 case GUESTFS_PROC_CHOWN:
1273 chown_stub (xdr_in);
1275 case GUESTFS_PROC_EXISTS:
1276 exists_stub (xdr_in);
1278 case GUESTFS_PROC_IS_FILE:
1279 is_file_stub (xdr_in);
1281 case GUESTFS_PROC_IS_DIR:
1282 is_dir_stub (xdr_in);
1284 case GUESTFS_PROC_PVCREATE:
1285 pvcreate_stub (xdr_in);
1287 case GUESTFS_PROC_VGCREATE:
1288 vgcreate_stub (xdr_in);
1290 case GUESTFS_PROC_LVCREATE:
1291 lvcreate_stub (xdr_in);
1293 case GUESTFS_PROC_MKFS:
1296 case GUESTFS_PROC_SFDISK:
1297 sfdisk_stub (xdr_in);
1299 case GUESTFS_PROC_WRITE_FILE:
1300 write_file_stub (xdr_in);
1302 case GUESTFS_PROC_UMOUNT:
1303 umount_stub (xdr_in);
1305 case GUESTFS_PROC_MOUNTS:
1306 mounts_stub (xdr_in);
1308 case GUESTFS_PROC_UMOUNT_ALL:
1309 umount_all_stub (xdr_in);
1311 case GUESTFS_PROC_LVM_REMOVE_ALL:
1312 lvm_remove_all_stub (xdr_in);
1314 case GUESTFS_PROC_FILE:
1318 reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr);
1322 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";
1324 static int lvm_tokenize_pv (char *str, struct guestfs_lvm_int_pv *r)
1326 char *tok, *p, *next;
1330 fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
1333 if (!*str || isspace (*str)) {
1334 fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
1339 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_name");
1342 p = strchrnul (tok, ',');
1343 if (*p) next = p+1; else next = NULL;
1345 r->pv_name = strdup (tok);
1346 if (r->pv_name == NULL) {
1352 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_uuid");
1355 p = strchrnul (tok, ',');
1356 if (*p) next = p+1; else next = NULL;
1358 for (i = j = 0; i < 32; ++j) {
1359 if (tok[j] == '\0') {
1360 fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
1362 } else if (tok[j] != '-')
1363 r->pv_uuid[i++] = tok[j];
1367 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_fmt");
1370 p = strchrnul (tok, ',');
1371 if (*p) next = p+1; else next = NULL;
1373 r->pv_fmt = strdup (tok);
1374 if (r->pv_fmt == NULL) {
1380 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_size");
1383 p = strchrnul (tok, ',');
1384 if (*p) next = p+1; else next = NULL;
1386 if (sscanf (tok, "%"SCNu64, &r->pv_size) != 1) {
1387 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_size");
1392 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "dev_size");
1395 p = strchrnul (tok, ',');
1396 if (*p) next = p+1; else next = NULL;
1398 if (sscanf (tok, "%"SCNu64, &r->dev_size) != 1) {
1399 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "dev_size");
1404 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_free");
1407 p = strchrnul (tok, ',');
1408 if (*p) next = p+1; else next = NULL;
1410 if (sscanf (tok, "%"SCNu64, &r->pv_free) != 1) {
1411 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_free");
1416 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_used");
1419 p = strchrnul (tok, ',');
1420 if (*p) next = p+1; else next = NULL;
1422 if (sscanf (tok, "%"SCNu64, &r->pv_used) != 1) {
1423 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_used");
1428 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_attr");
1431 p = strchrnul (tok, ',');
1432 if (*p) next = p+1; else next = NULL;
1434 r->pv_attr = strdup (tok);
1435 if (r->pv_attr == NULL) {
1441 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_pe_count");
1444 p = strchrnul (tok, ',');
1445 if (*p) next = p+1; else next = NULL;
1447 if (sscanf (tok, "%"SCNi64, &r->pv_pe_count) != 1) {
1448 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_pe_count");
1453 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_pe_alloc_count");
1456 p = strchrnul (tok, ',');
1457 if (*p) next = p+1; else next = NULL;
1459 if (sscanf (tok, "%"SCNi64, &r->pv_pe_alloc_count) != 1) {
1460 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_pe_alloc_count");
1465 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_tags");
1468 p = strchrnul (tok, ',');
1469 if (*p) next = p+1; else next = NULL;
1471 r->pv_tags = strdup (tok);
1472 if (r->pv_tags == NULL) {
1478 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pe_start");
1481 p = strchrnul (tok, ',');
1482 if (*p) next = p+1; else next = NULL;
1484 if (sscanf (tok, "%"SCNu64, &r->pe_start) != 1) {
1485 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pe_start");
1490 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_mda_count");
1493 p = strchrnul (tok, ',');
1494 if (*p) next = p+1; else next = NULL;
1496 if (sscanf (tok, "%"SCNi64, &r->pv_mda_count) != 1) {
1497 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_mda_count");
1502 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_mda_free");
1505 p = strchrnul (tok, ',');
1506 if (*p) next = p+1; else next = NULL;
1508 if (sscanf (tok, "%"SCNu64, &r->pv_mda_free) != 1) {
1509 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_mda_free");
1514 fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
1520 guestfs_lvm_int_pv_list *
1521 parse_command_line_pvs (void)
1526 guestfs_lvm_int_pv_list *ret;
1529 ret = malloc (sizeof *ret);
1531 reply_with_perror ("malloc");
1535 ret->guestfs_lvm_int_pv_list_len = 0;
1536 ret->guestfs_lvm_int_pv_list_val = NULL;
1538 r = command (&out, &err,
1540 "-o", lvm_pv_cols, "--unbuffered", "--noheadings",
1541 "--nosuffix", "--separator", ",", "--units", "b", NULL);
1543 reply_with_error ("%s", err);
1551 /* Tokenize each line of the output. */
1555 pend = strchr (p, '\n'); /* Get the next line of output. */
1561 while (*p && isspace (*p)) /* Skip any leading whitespace. */
1564 if (!*p) { /* Empty line? Skip it. */
1569 /* Allocate some space to store this next entry. */
1570 newp = realloc (ret->guestfs_lvm_int_pv_list_val,
1571 sizeof (guestfs_lvm_int_pv) * (i+1));
1573 reply_with_perror ("realloc");
1574 free (ret->guestfs_lvm_int_pv_list_val);
1579 ret->guestfs_lvm_int_pv_list_val = newp;
1581 /* Tokenize the next entry. */
1582 r = lvm_tokenize_pv (p, &ret->guestfs_lvm_int_pv_list_val[i]);
1584 reply_with_error ("failed to parse output of 'pvs' command");
1585 free (ret->guestfs_lvm_int_pv_list_val);
1595 ret->guestfs_lvm_int_pv_list_len = i;
1600 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";
1602 static int lvm_tokenize_vg (char *str, struct guestfs_lvm_int_vg *r)
1604 char *tok, *p, *next;
1608 fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
1611 if (!*str || isspace (*str)) {
1612 fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
1617 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_name");
1620 p = strchrnul (tok, ',');
1621 if (*p) next = p+1; else next = NULL;
1623 r->vg_name = strdup (tok);
1624 if (r->vg_name == NULL) {
1630 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_uuid");
1633 p = strchrnul (tok, ',');
1634 if (*p) next = p+1; else next = NULL;
1636 for (i = j = 0; i < 32; ++j) {
1637 if (tok[j] == '\0') {
1638 fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
1640 } else if (tok[j] != '-')
1641 r->vg_uuid[i++] = tok[j];
1645 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_fmt");
1648 p = strchrnul (tok, ',');
1649 if (*p) next = p+1; else next = NULL;
1651 r->vg_fmt = strdup (tok);
1652 if (r->vg_fmt == NULL) {
1658 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_attr");
1661 p = strchrnul (tok, ',');
1662 if (*p) next = p+1; else next = NULL;
1664 r->vg_attr = strdup (tok);
1665 if (r->vg_attr == NULL) {
1671 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_size");
1674 p = strchrnul (tok, ',');
1675 if (*p) next = p+1; else next = NULL;
1677 if (sscanf (tok, "%"SCNu64, &r->vg_size) != 1) {
1678 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_size");
1683 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_free");
1686 p = strchrnul (tok, ',');
1687 if (*p) next = p+1; else next = NULL;
1689 if (sscanf (tok, "%"SCNu64, &r->vg_free) != 1) {
1690 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_free");
1695 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_sysid");
1698 p = strchrnul (tok, ',');
1699 if (*p) next = p+1; else next = NULL;
1701 r->vg_sysid = strdup (tok);
1702 if (r->vg_sysid == NULL) {
1708 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_extent_size");
1711 p = strchrnul (tok, ',');
1712 if (*p) next = p+1; else next = NULL;
1714 if (sscanf (tok, "%"SCNu64, &r->vg_extent_size) != 1) {
1715 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_extent_size");
1720 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_extent_count");
1723 p = strchrnul (tok, ',');
1724 if (*p) next = p+1; else next = NULL;
1726 if (sscanf (tok, "%"SCNi64, &r->vg_extent_count) != 1) {
1727 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_extent_count");
1732 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_free_count");
1735 p = strchrnul (tok, ',');
1736 if (*p) next = p+1; else next = NULL;
1738 if (sscanf (tok, "%"SCNi64, &r->vg_free_count) != 1) {
1739 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_free_count");
1744 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "max_lv");
1747 p = strchrnul (tok, ',');
1748 if (*p) next = p+1; else next = NULL;
1750 if (sscanf (tok, "%"SCNi64, &r->max_lv) != 1) {
1751 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "max_lv");
1756 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "max_pv");
1759 p = strchrnul (tok, ',');
1760 if (*p) next = p+1; else next = NULL;
1762 if (sscanf (tok, "%"SCNi64, &r->max_pv) != 1) {
1763 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "max_pv");
1768 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_count");
1771 p = strchrnul (tok, ',');
1772 if (*p) next = p+1; else next = NULL;
1774 if (sscanf (tok, "%"SCNi64, &r->pv_count) != 1) {
1775 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_count");
1780 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_count");
1783 p = strchrnul (tok, ',');
1784 if (*p) next = p+1; else next = NULL;
1786 if (sscanf (tok, "%"SCNi64, &r->lv_count) != 1) {
1787 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_count");
1792 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "snap_count");
1795 p = strchrnul (tok, ',');
1796 if (*p) next = p+1; else next = NULL;
1798 if (sscanf (tok, "%"SCNi64, &r->snap_count) != 1) {
1799 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "snap_count");
1804 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_seqno");
1807 p = strchrnul (tok, ',');
1808 if (*p) next = p+1; else next = NULL;
1810 if (sscanf (tok, "%"SCNi64, &r->vg_seqno) != 1) {
1811 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_seqno");
1816 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_tags");
1819 p = strchrnul (tok, ',');
1820 if (*p) next = p+1; else next = NULL;
1822 r->vg_tags = strdup (tok);
1823 if (r->vg_tags == NULL) {
1829 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_mda_count");
1832 p = strchrnul (tok, ',');
1833 if (*p) next = p+1; else next = NULL;
1835 if (sscanf (tok, "%"SCNi64, &r->vg_mda_count) != 1) {
1836 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_mda_count");
1841 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_mda_free");
1844 p = strchrnul (tok, ',');
1845 if (*p) next = p+1; else next = NULL;
1847 if (sscanf (tok, "%"SCNu64, &r->vg_mda_free) != 1) {
1848 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_mda_free");
1853 fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
1859 guestfs_lvm_int_vg_list *
1860 parse_command_line_vgs (void)
1865 guestfs_lvm_int_vg_list *ret;
1868 ret = malloc (sizeof *ret);
1870 reply_with_perror ("malloc");
1874 ret->guestfs_lvm_int_vg_list_len = 0;
1875 ret->guestfs_lvm_int_vg_list_val = NULL;
1877 r = command (&out, &err,
1879 "-o", lvm_vg_cols, "--unbuffered", "--noheadings",
1880 "--nosuffix", "--separator", ",", "--units", "b", NULL);
1882 reply_with_error ("%s", err);
1890 /* Tokenize each line of the output. */
1894 pend = strchr (p, '\n'); /* Get the next line of output. */
1900 while (*p && isspace (*p)) /* Skip any leading whitespace. */
1903 if (!*p) { /* Empty line? Skip it. */
1908 /* Allocate some space to store this next entry. */
1909 newp = realloc (ret->guestfs_lvm_int_vg_list_val,
1910 sizeof (guestfs_lvm_int_vg) * (i+1));
1912 reply_with_perror ("realloc");
1913 free (ret->guestfs_lvm_int_vg_list_val);
1918 ret->guestfs_lvm_int_vg_list_val = newp;
1920 /* Tokenize the next entry. */
1921 r = lvm_tokenize_vg (p, &ret->guestfs_lvm_int_vg_list_val[i]);
1923 reply_with_error ("failed to parse output of 'vgs' command");
1924 free (ret->guestfs_lvm_int_vg_list_val);
1934 ret->guestfs_lvm_int_vg_list_len = i;
1939 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";
1941 static int lvm_tokenize_lv (char *str, struct guestfs_lvm_int_lv *r)
1943 char *tok, *p, *next;
1947 fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
1950 if (!*str || isspace (*str)) {
1951 fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
1956 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_name");
1959 p = strchrnul (tok, ',');
1960 if (*p) next = p+1; else next = NULL;
1962 r->lv_name = strdup (tok);
1963 if (r->lv_name == NULL) {
1969 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_uuid");
1972 p = strchrnul (tok, ',');
1973 if (*p) next = p+1; else next = NULL;
1975 for (i = j = 0; i < 32; ++j) {
1976 if (tok[j] == '\0') {
1977 fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
1979 } else if (tok[j] != '-')
1980 r->lv_uuid[i++] = tok[j];
1984 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_attr");
1987 p = strchrnul (tok, ',');
1988 if (*p) next = p+1; else next = NULL;
1990 r->lv_attr = strdup (tok);
1991 if (r->lv_attr == NULL) {
1997 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_major");
2000 p = strchrnul (tok, ',');
2001 if (*p) next = p+1; else next = NULL;
2003 if (sscanf (tok, "%"SCNi64, &r->lv_major) != 1) {
2004 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_major");
2009 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_minor");
2012 p = strchrnul (tok, ',');
2013 if (*p) next = p+1; else next = NULL;
2015 if (sscanf (tok, "%"SCNi64, &r->lv_minor) != 1) {
2016 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_minor");
2021 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_kernel_major");
2024 p = strchrnul (tok, ',');
2025 if (*p) next = p+1; else next = NULL;
2027 if (sscanf (tok, "%"SCNi64, &r->lv_kernel_major) != 1) {
2028 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_kernel_major");
2033 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_kernel_minor");
2036 p = strchrnul (tok, ',');
2037 if (*p) next = p+1; else next = NULL;
2039 if (sscanf (tok, "%"SCNi64, &r->lv_kernel_minor) != 1) {
2040 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_kernel_minor");
2045 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_size");
2048 p = strchrnul (tok, ',');
2049 if (*p) next = p+1; else next = NULL;
2051 if (sscanf (tok, "%"SCNu64, &r->lv_size) != 1) {
2052 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "lv_size");
2057 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "seg_count");
2060 p = strchrnul (tok, ',');
2061 if (*p) next = p+1; else next = NULL;
2063 if (sscanf (tok, "%"SCNi64, &r->seg_count) != 1) {
2064 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "seg_count");
2069 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "origin");
2072 p = strchrnul (tok, ',');
2073 if (*p) next = p+1; else next = NULL;
2075 r->origin = strdup (tok);
2076 if (r->origin == NULL) {
2082 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "snap_percent");
2085 p = strchrnul (tok, ',');
2086 if (*p) next = p+1; else next = NULL;
2089 r->snap_percent = -1;
2090 else if (sscanf (tok, "%f", &r->snap_percent) != 1) {
2091 fprintf (stderr, "%s: failed to parse float '%s' from token %s\n", __func__, tok, "snap_percent");
2096 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "copy_percent");
2099 p = strchrnul (tok, ',');
2100 if (*p) next = p+1; else next = NULL;
2103 r->copy_percent = -1;
2104 else if (sscanf (tok, "%f", &r->copy_percent) != 1) {
2105 fprintf (stderr, "%s: failed to parse float '%s' from token %s\n", __func__, tok, "copy_percent");
2110 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "move_pv");
2113 p = strchrnul (tok, ',');
2114 if (*p) next = p+1; else next = NULL;
2116 r->move_pv = strdup (tok);
2117 if (r->move_pv == NULL) {
2123 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_tags");
2126 p = strchrnul (tok, ',');
2127 if (*p) next = p+1; else next = NULL;
2129 r->lv_tags = strdup (tok);
2130 if (r->lv_tags == NULL) {
2136 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "mirror_log");
2139 p = strchrnul (tok, ',');
2140 if (*p) next = p+1; else next = NULL;
2142 r->mirror_log = strdup (tok);
2143 if (r->mirror_log == NULL) {
2149 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "modules");
2152 p = strchrnul (tok, ',');
2153 if (*p) next = p+1; else next = NULL;
2155 r->modules = strdup (tok);
2156 if (r->modules == NULL) {
2162 fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
2168 guestfs_lvm_int_lv_list *
2169 parse_command_line_lvs (void)
2174 guestfs_lvm_int_lv_list *ret;
2177 ret = malloc (sizeof *ret);
2179 reply_with_perror ("malloc");
2183 ret->guestfs_lvm_int_lv_list_len = 0;
2184 ret->guestfs_lvm_int_lv_list_val = NULL;
2186 r = command (&out, &err,
2188 "-o", lvm_lv_cols, "--unbuffered", "--noheadings",
2189 "--nosuffix", "--separator", ",", "--units", "b", NULL);
2191 reply_with_error ("%s", err);
2199 /* Tokenize each line of the output. */
2203 pend = strchr (p, '\n'); /* Get the next line of output. */
2209 while (*p && isspace (*p)) /* Skip any leading whitespace. */
2212 if (!*p) { /* Empty line? Skip it. */
2217 /* Allocate some space to store this next entry. */
2218 newp = realloc (ret->guestfs_lvm_int_lv_list_val,
2219 sizeof (guestfs_lvm_int_lv) * (i+1));
2221 reply_with_perror ("realloc");
2222 free (ret->guestfs_lvm_int_lv_list_val);
2227 ret->guestfs_lvm_int_lv_list_val = newp;
2229 /* Tokenize the next entry. */
2230 r = lvm_tokenize_lv (p, &ret->guestfs_lvm_int_lv_list_val[i]);
2232 reply_with_error ("failed to parse output of 'lvs' command");
2233 free (ret->guestfs_lvm_int_lv_list_val);
2243 ret->guestfs_lvm_int_lv_list_len = i;