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 void dispatch_incoming_message (XDR *xdr_in)
1143 case GUESTFS_PROC_MOUNT:
1144 mount_stub (xdr_in);
1146 case GUESTFS_PROC_SYNC:
1149 case GUESTFS_PROC_TOUCH:
1150 touch_stub (xdr_in);
1152 case GUESTFS_PROC_CAT:
1155 case GUESTFS_PROC_LL:
1158 case GUESTFS_PROC_LS:
1161 case GUESTFS_PROC_LIST_DEVICES:
1162 list_devices_stub (xdr_in);
1164 case GUESTFS_PROC_LIST_PARTITIONS:
1165 list_partitions_stub (xdr_in);
1167 case GUESTFS_PROC_PVS:
1170 case GUESTFS_PROC_VGS:
1173 case GUESTFS_PROC_LVS:
1176 case GUESTFS_PROC_PVS_FULL:
1177 pvs_full_stub (xdr_in);
1179 case GUESTFS_PROC_VGS_FULL:
1180 vgs_full_stub (xdr_in);
1182 case GUESTFS_PROC_LVS_FULL:
1183 lvs_full_stub (xdr_in);
1185 case GUESTFS_PROC_READ_LINES:
1186 read_lines_stub (xdr_in);
1188 case GUESTFS_PROC_AUG_INIT:
1189 aug_init_stub (xdr_in);
1191 case GUESTFS_PROC_AUG_CLOSE:
1192 aug_close_stub (xdr_in);
1194 case GUESTFS_PROC_AUG_DEFVAR:
1195 aug_defvar_stub (xdr_in);
1197 case GUESTFS_PROC_AUG_DEFNODE:
1198 aug_defnode_stub (xdr_in);
1200 case GUESTFS_PROC_AUG_GET:
1201 aug_get_stub (xdr_in);
1203 case GUESTFS_PROC_AUG_SET:
1204 aug_set_stub (xdr_in);
1206 case GUESTFS_PROC_AUG_INSERT:
1207 aug_insert_stub (xdr_in);
1209 case GUESTFS_PROC_AUG_RM:
1210 aug_rm_stub (xdr_in);
1212 case GUESTFS_PROC_AUG_MV:
1213 aug_mv_stub (xdr_in);
1215 case GUESTFS_PROC_AUG_MATCH:
1216 aug_match_stub (xdr_in);
1218 case GUESTFS_PROC_AUG_SAVE:
1219 aug_save_stub (xdr_in);
1221 case GUESTFS_PROC_AUG_LOAD:
1222 aug_load_stub (xdr_in);
1224 case GUESTFS_PROC_AUG_LS:
1225 aug_ls_stub (xdr_in);
1227 case GUESTFS_PROC_RM:
1230 case GUESTFS_PROC_RMDIR:
1231 rmdir_stub (xdr_in);
1233 case GUESTFS_PROC_RM_RF:
1234 rm_rf_stub (xdr_in);
1236 case GUESTFS_PROC_MKDIR:
1237 mkdir_stub (xdr_in);
1239 case GUESTFS_PROC_MKDIR_P:
1240 mkdir_p_stub (xdr_in);
1242 case GUESTFS_PROC_CHMOD:
1243 chmod_stub (xdr_in);
1245 case GUESTFS_PROC_CHOWN:
1246 chown_stub (xdr_in);
1248 case GUESTFS_PROC_EXISTS:
1249 exists_stub (xdr_in);
1251 case GUESTFS_PROC_IS_FILE:
1252 is_file_stub (xdr_in);
1254 case GUESTFS_PROC_IS_DIR:
1255 is_dir_stub (xdr_in);
1257 case GUESTFS_PROC_PVCREATE:
1258 pvcreate_stub (xdr_in);
1260 case GUESTFS_PROC_VGCREATE:
1261 vgcreate_stub (xdr_in);
1263 case GUESTFS_PROC_LVCREATE:
1264 lvcreate_stub (xdr_in);
1266 case GUESTFS_PROC_MKFS:
1269 case GUESTFS_PROC_SFDISK:
1270 sfdisk_stub (xdr_in);
1272 case GUESTFS_PROC_WRITE_FILE:
1273 write_file_stub (xdr_in);
1275 case GUESTFS_PROC_UMOUNT:
1276 umount_stub (xdr_in);
1278 case GUESTFS_PROC_MOUNTS:
1279 mounts_stub (xdr_in);
1281 case GUESTFS_PROC_UMOUNT_ALL:
1282 umount_all_stub (xdr_in);
1284 case GUESTFS_PROC_LVM_REMOVE_ALL:
1285 lvm_remove_all_stub (xdr_in);
1288 reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr);
1292 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";
1294 static int lvm_tokenize_pv (char *str, struct guestfs_lvm_int_pv *r)
1296 char *tok, *p, *next;
1300 fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
1303 if (!*str || isspace (*str)) {
1304 fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
1309 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_name");
1312 p = strchrnul (tok, ',');
1313 if (*p) next = p+1; else next = NULL;
1315 r->pv_name = strdup (tok);
1316 if (r->pv_name == NULL) {
1322 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_uuid");
1325 p = strchrnul (tok, ',');
1326 if (*p) next = p+1; else next = NULL;
1328 for (i = j = 0; i < 32; ++j) {
1329 if (tok[j] == '\0') {
1330 fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
1332 } else if (tok[j] != '-')
1333 r->pv_uuid[i++] = tok[j];
1337 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_fmt");
1340 p = strchrnul (tok, ',');
1341 if (*p) next = p+1; else next = NULL;
1343 r->pv_fmt = strdup (tok);
1344 if (r->pv_fmt == NULL) {
1350 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_size");
1353 p = strchrnul (tok, ',');
1354 if (*p) next = p+1; else next = NULL;
1356 if (sscanf (tok, "%"SCNu64, &r->pv_size) != 1) {
1357 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_size");
1362 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "dev_size");
1365 p = strchrnul (tok, ',');
1366 if (*p) next = p+1; else next = NULL;
1368 if (sscanf (tok, "%"SCNu64, &r->dev_size) != 1) {
1369 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "dev_size");
1374 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_free");
1377 p = strchrnul (tok, ',');
1378 if (*p) next = p+1; else next = NULL;
1380 if (sscanf (tok, "%"SCNu64, &r->pv_free) != 1) {
1381 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_free");
1386 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_used");
1389 p = strchrnul (tok, ',');
1390 if (*p) next = p+1; else next = NULL;
1392 if (sscanf (tok, "%"SCNu64, &r->pv_used) != 1) {
1393 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_used");
1398 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_attr");
1401 p = strchrnul (tok, ',');
1402 if (*p) next = p+1; else next = NULL;
1404 r->pv_attr = strdup (tok);
1405 if (r->pv_attr == NULL) {
1411 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_pe_count");
1414 p = strchrnul (tok, ',');
1415 if (*p) next = p+1; else next = NULL;
1417 if (sscanf (tok, "%"SCNi64, &r->pv_pe_count) != 1) {
1418 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_pe_count");
1423 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_pe_alloc_count");
1426 p = strchrnul (tok, ',');
1427 if (*p) next = p+1; else next = NULL;
1429 if (sscanf (tok, "%"SCNi64, &r->pv_pe_alloc_count) != 1) {
1430 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_pe_alloc_count");
1435 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_tags");
1438 p = strchrnul (tok, ',');
1439 if (*p) next = p+1; else next = NULL;
1441 r->pv_tags = strdup (tok);
1442 if (r->pv_tags == NULL) {
1448 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pe_start");
1451 p = strchrnul (tok, ',');
1452 if (*p) next = p+1; else next = NULL;
1454 if (sscanf (tok, "%"SCNu64, &r->pe_start) != 1) {
1455 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pe_start");
1460 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_mda_count");
1463 p = strchrnul (tok, ',');
1464 if (*p) next = p+1; else next = NULL;
1466 if (sscanf (tok, "%"SCNi64, &r->pv_mda_count) != 1) {
1467 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_mda_count");
1472 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_mda_free");
1475 p = strchrnul (tok, ',');
1476 if (*p) next = p+1; else next = NULL;
1478 if (sscanf (tok, "%"SCNu64, &r->pv_mda_free) != 1) {
1479 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_mda_free");
1484 fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
1490 guestfs_lvm_int_pv_list *
1491 parse_command_line_pvs (void)
1496 guestfs_lvm_int_pv_list *ret;
1499 ret = malloc (sizeof *ret);
1501 reply_with_perror ("malloc");
1505 ret->guestfs_lvm_int_pv_list_len = 0;
1506 ret->guestfs_lvm_int_pv_list_val = NULL;
1508 r = command (&out, &err,
1510 "-o", lvm_pv_cols, "--unbuffered", "--noheadings",
1511 "--nosuffix", "--separator", ",", "--units", "b", NULL);
1513 reply_with_error ("%s", err);
1521 /* Tokenize each line of the output. */
1525 pend = strchr (p, '\n'); /* Get the next line of output. */
1531 while (*p && isspace (*p)) /* Skip any leading whitespace. */
1534 if (!*p) { /* Empty line? Skip it. */
1539 /* Allocate some space to store this next entry. */
1540 newp = realloc (ret->guestfs_lvm_int_pv_list_val,
1541 sizeof (guestfs_lvm_int_pv) * (i+1));
1543 reply_with_perror ("realloc");
1544 free (ret->guestfs_lvm_int_pv_list_val);
1549 ret->guestfs_lvm_int_pv_list_val = newp;
1551 /* Tokenize the next entry. */
1552 r = lvm_tokenize_pv (p, &ret->guestfs_lvm_int_pv_list_val[i]);
1554 reply_with_error ("failed to parse output of 'pvs' command");
1555 free (ret->guestfs_lvm_int_pv_list_val);
1565 ret->guestfs_lvm_int_pv_list_len = i;
1570 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";
1572 static int lvm_tokenize_vg (char *str, struct guestfs_lvm_int_vg *r)
1574 char *tok, *p, *next;
1578 fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
1581 if (!*str || isspace (*str)) {
1582 fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
1587 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_name");
1590 p = strchrnul (tok, ',');
1591 if (*p) next = p+1; else next = NULL;
1593 r->vg_name = strdup (tok);
1594 if (r->vg_name == NULL) {
1600 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_uuid");
1603 p = strchrnul (tok, ',');
1604 if (*p) next = p+1; else next = NULL;
1606 for (i = j = 0; i < 32; ++j) {
1607 if (tok[j] == '\0') {
1608 fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
1610 } else if (tok[j] != '-')
1611 r->vg_uuid[i++] = tok[j];
1615 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_fmt");
1618 p = strchrnul (tok, ',');
1619 if (*p) next = p+1; else next = NULL;
1621 r->vg_fmt = strdup (tok);
1622 if (r->vg_fmt == NULL) {
1628 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_attr");
1631 p = strchrnul (tok, ',');
1632 if (*p) next = p+1; else next = NULL;
1634 r->vg_attr = strdup (tok);
1635 if (r->vg_attr == NULL) {
1641 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_size");
1644 p = strchrnul (tok, ',');
1645 if (*p) next = p+1; else next = NULL;
1647 if (sscanf (tok, "%"SCNu64, &r->vg_size) != 1) {
1648 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_size");
1653 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_free");
1656 p = strchrnul (tok, ',');
1657 if (*p) next = p+1; else next = NULL;
1659 if (sscanf (tok, "%"SCNu64, &r->vg_free) != 1) {
1660 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_free");
1665 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_sysid");
1668 p = strchrnul (tok, ',');
1669 if (*p) next = p+1; else next = NULL;
1671 r->vg_sysid = strdup (tok);
1672 if (r->vg_sysid == NULL) {
1678 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_extent_size");
1681 p = strchrnul (tok, ',');
1682 if (*p) next = p+1; else next = NULL;
1684 if (sscanf (tok, "%"SCNu64, &r->vg_extent_size) != 1) {
1685 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_extent_size");
1690 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_extent_count");
1693 p = strchrnul (tok, ',');
1694 if (*p) next = p+1; else next = NULL;
1696 if (sscanf (tok, "%"SCNi64, &r->vg_extent_count) != 1) {
1697 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_extent_count");
1702 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_free_count");
1705 p = strchrnul (tok, ',');
1706 if (*p) next = p+1; else next = NULL;
1708 if (sscanf (tok, "%"SCNi64, &r->vg_free_count) != 1) {
1709 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_free_count");
1714 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "max_lv");
1717 p = strchrnul (tok, ',');
1718 if (*p) next = p+1; else next = NULL;
1720 if (sscanf (tok, "%"SCNi64, &r->max_lv) != 1) {
1721 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "max_lv");
1726 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "max_pv");
1729 p = strchrnul (tok, ',');
1730 if (*p) next = p+1; else next = NULL;
1732 if (sscanf (tok, "%"SCNi64, &r->max_pv) != 1) {
1733 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "max_pv");
1738 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_count");
1741 p = strchrnul (tok, ',');
1742 if (*p) next = p+1; else next = NULL;
1744 if (sscanf (tok, "%"SCNi64, &r->pv_count) != 1) {
1745 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_count");
1750 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_count");
1753 p = strchrnul (tok, ',');
1754 if (*p) next = p+1; else next = NULL;
1756 if (sscanf (tok, "%"SCNi64, &r->lv_count) != 1) {
1757 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_count");
1762 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "snap_count");
1765 p = strchrnul (tok, ',');
1766 if (*p) next = p+1; else next = NULL;
1768 if (sscanf (tok, "%"SCNi64, &r->snap_count) != 1) {
1769 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "snap_count");
1774 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_seqno");
1777 p = strchrnul (tok, ',');
1778 if (*p) next = p+1; else next = NULL;
1780 if (sscanf (tok, "%"SCNi64, &r->vg_seqno) != 1) {
1781 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_seqno");
1786 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_tags");
1789 p = strchrnul (tok, ',');
1790 if (*p) next = p+1; else next = NULL;
1792 r->vg_tags = strdup (tok);
1793 if (r->vg_tags == NULL) {
1799 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_mda_count");
1802 p = strchrnul (tok, ',');
1803 if (*p) next = p+1; else next = NULL;
1805 if (sscanf (tok, "%"SCNi64, &r->vg_mda_count) != 1) {
1806 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_mda_count");
1811 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_mda_free");
1814 p = strchrnul (tok, ',');
1815 if (*p) next = p+1; else next = NULL;
1817 if (sscanf (tok, "%"SCNu64, &r->vg_mda_free) != 1) {
1818 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_mda_free");
1823 fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
1829 guestfs_lvm_int_vg_list *
1830 parse_command_line_vgs (void)
1835 guestfs_lvm_int_vg_list *ret;
1838 ret = malloc (sizeof *ret);
1840 reply_with_perror ("malloc");
1844 ret->guestfs_lvm_int_vg_list_len = 0;
1845 ret->guestfs_lvm_int_vg_list_val = NULL;
1847 r = command (&out, &err,
1849 "-o", lvm_vg_cols, "--unbuffered", "--noheadings",
1850 "--nosuffix", "--separator", ",", "--units", "b", NULL);
1852 reply_with_error ("%s", err);
1860 /* Tokenize each line of the output. */
1864 pend = strchr (p, '\n'); /* Get the next line of output. */
1870 while (*p && isspace (*p)) /* Skip any leading whitespace. */
1873 if (!*p) { /* Empty line? Skip it. */
1878 /* Allocate some space to store this next entry. */
1879 newp = realloc (ret->guestfs_lvm_int_vg_list_val,
1880 sizeof (guestfs_lvm_int_vg) * (i+1));
1882 reply_with_perror ("realloc");
1883 free (ret->guestfs_lvm_int_vg_list_val);
1888 ret->guestfs_lvm_int_vg_list_val = newp;
1890 /* Tokenize the next entry. */
1891 r = lvm_tokenize_vg (p, &ret->guestfs_lvm_int_vg_list_val[i]);
1893 reply_with_error ("failed to parse output of 'vgs' command");
1894 free (ret->guestfs_lvm_int_vg_list_val);
1904 ret->guestfs_lvm_int_vg_list_len = i;
1909 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";
1911 static int lvm_tokenize_lv (char *str, struct guestfs_lvm_int_lv *r)
1913 char *tok, *p, *next;
1917 fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
1920 if (!*str || isspace (*str)) {
1921 fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
1926 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_name");
1929 p = strchrnul (tok, ',');
1930 if (*p) next = p+1; else next = NULL;
1932 r->lv_name = strdup (tok);
1933 if (r->lv_name == NULL) {
1939 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_uuid");
1942 p = strchrnul (tok, ',');
1943 if (*p) next = p+1; else next = NULL;
1945 for (i = j = 0; i < 32; ++j) {
1946 if (tok[j] == '\0') {
1947 fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
1949 } else if (tok[j] != '-')
1950 r->lv_uuid[i++] = tok[j];
1954 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_attr");
1957 p = strchrnul (tok, ',');
1958 if (*p) next = p+1; else next = NULL;
1960 r->lv_attr = strdup (tok);
1961 if (r->lv_attr == NULL) {
1967 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_major");
1970 p = strchrnul (tok, ',');
1971 if (*p) next = p+1; else next = NULL;
1973 if (sscanf (tok, "%"SCNi64, &r->lv_major) != 1) {
1974 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_major");
1979 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_minor");
1982 p = strchrnul (tok, ',');
1983 if (*p) next = p+1; else next = NULL;
1985 if (sscanf (tok, "%"SCNi64, &r->lv_minor) != 1) {
1986 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_minor");
1991 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_kernel_major");
1994 p = strchrnul (tok, ',');
1995 if (*p) next = p+1; else next = NULL;
1997 if (sscanf (tok, "%"SCNi64, &r->lv_kernel_major) != 1) {
1998 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_kernel_major");
2003 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_kernel_minor");
2006 p = strchrnul (tok, ',');
2007 if (*p) next = p+1; else next = NULL;
2009 if (sscanf (tok, "%"SCNi64, &r->lv_kernel_minor) != 1) {
2010 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_kernel_minor");
2015 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_size");
2018 p = strchrnul (tok, ',');
2019 if (*p) next = p+1; else next = NULL;
2021 if (sscanf (tok, "%"SCNu64, &r->lv_size) != 1) {
2022 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "lv_size");
2027 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "seg_count");
2030 p = strchrnul (tok, ',');
2031 if (*p) next = p+1; else next = NULL;
2033 if (sscanf (tok, "%"SCNi64, &r->seg_count) != 1) {
2034 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "seg_count");
2039 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "origin");
2042 p = strchrnul (tok, ',');
2043 if (*p) next = p+1; else next = NULL;
2045 r->origin = strdup (tok);
2046 if (r->origin == NULL) {
2052 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "snap_percent");
2055 p = strchrnul (tok, ',');
2056 if (*p) next = p+1; else next = NULL;
2059 r->snap_percent = -1;
2060 else if (sscanf (tok, "%f", &r->snap_percent) != 1) {
2061 fprintf (stderr, "%s: failed to parse float '%s' from token %s\n", __func__, tok, "snap_percent");
2066 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "copy_percent");
2069 p = strchrnul (tok, ',');
2070 if (*p) next = p+1; else next = NULL;
2073 r->copy_percent = -1;
2074 else if (sscanf (tok, "%f", &r->copy_percent) != 1) {
2075 fprintf (stderr, "%s: failed to parse float '%s' from token %s\n", __func__, tok, "copy_percent");
2080 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "move_pv");
2083 p = strchrnul (tok, ',');
2084 if (*p) next = p+1; else next = NULL;
2086 r->move_pv = strdup (tok);
2087 if (r->move_pv == NULL) {
2093 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_tags");
2096 p = strchrnul (tok, ',');
2097 if (*p) next = p+1; else next = NULL;
2099 r->lv_tags = strdup (tok);
2100 if (r->lv_tags == NULL) {
2106 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "mirror_log");
2109 p = strchrnul (tok, ',');
2110 if (*p) next = p+1; else next = NULL;
2112 r->mirror_log = strdup (tok);
2113 if (r->mirror_log == NULL) {
2119 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "modules");
2122 p = strchrnul (tok, ',');
2123 if (*p) next = p+1; else next = NULL;
2125 r->modules = strdup (tok);
2126 if (r->modules == NULL) {
2132 fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
2138 guestfs_lvm_int_lv_list *
2139 parse_command_line_lvs (void)
2144 guestfs_lvm_int_lv_list *ret;
2147 ret = malloc (sizeof *ret);
2149 reply_with_perror ("malloc");
2153 ret->guestfs_lvm_int_lv_list_len = 0;
2154 ret->guestfs_lvm_int_lv_list_val = NULL;
2156 r = command (&out, &err,
2158 "-o", lvm_lv_cols, "--unbuffered", "--noheadings",
2159 "--nosuffix", "--separator", ",", "--units", "b", NULL);
2161 reply_with_error ("%s", err);
2169 /* Tokenize each line of the output. */
2173 pend = strchr (p, '\n'); /* Get the next line of output. */
2179 while (*p && isspace (*p)) /* Skip any leading whitespace. */
2182 if (!*p) { /* Empty line? Skip it. */
2187 /* Allocate some space to store this next entry. */
2188 newp = realloc (ret->guestfs_lvm_int_lv_list_val,
2189 sizeof (guestfs_lvm_int_lv) * (i+1));
2191 reply_with_perror ("realloc");
2192 free (ret->guestfs_lvm_int_lv_list_val);
2197 ret->guestfs_lvm_int_lv_list_val = newp;
2199 /* Tokenize the next entry. */
2200 r = lvm_tokenize_lv (p, &ret->guestfs_lvm_int_lv_list_val[i]);
2202 reply_with_error ("failed to parse output of 'lvs' command");
2203 free (ret->guestfs_lvm_int_lv_list_val);
2213 ret->guestfs_lvm_int_lv_list_len = i;