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 ("mount: daemon failed to decode procedure arguments");
50 mountpoint = args.mountpoint;
52 r = do_mount (device, mountpoint);
54 /* do_mount has already called reply_with_error, so just return */
60 static void sync_stub (XDR *xdr_in)
66 /* do_sync has already called reply_with_error, so just return */
72 static void touch_stub (XDR *xdr_in)
75 struct guestfs_touch_args args;
78 memset (&args, 0, sizeof args);
80 if (!xdr_guestfs_touch_args (xdr_in, &args)) {
81 reply_with_error ("touch: daemon failed to decode procedure arguments");
88 /* do_touch has already called reply_with_error, so just return */
94 static void cat_stub (XDR *xdr_in)
97 struct guestfs_cat_args args;
100 memset (&args, 0, sizeof args);
102 if (!xdr_guestfs_cat_args (xdr_in, &args)) {
103 reply_with_error ("cat: daemon failed to decode procedure arguments");
110 /* do_cat has already called reply_with_error, so just return */
113 struct guestfs_cat_ret ret;
115 reply ((xdrproc_t) &xdr_guestfs_cat_ret, (char *) &ret);
119 static void ll_stub (XDR *xdr_in)
122 struct guestfs_ll_args args;
123 const char *directory;
125 memset (&args, 0, sizeof args);
127 if (!xdr_guestfs_ll_args (xdr_in, &args)) {
128 reply_with_error ("ll: daemon failed to decode procedure arguments");
131 directory = args.directory;
133 r = do_ll (directory);
135 /* do_ll has already called reply_with_error, so just return */
138 struct guestfs_ll_ret ret;
140 reply ((xdrproc_t) &xdr_guestfs_ll_ret, (char *) &ret);
144 static void ls_stub (XDR *xdr_in)
147 struct guestfs_ls_args args;
148 const char *directory;
150 memset (&args, 0, sizeof args);
152 if (!xdr_guestfs_ls_args (xdr_in, &args)) {
153 reply_with_error ("ls: daemon failed to decode procedure arguments");
156 directory = args.directory;
158 r = do_ls (directory);
160 /* do_ls has already called reply_with_error, so just return */
163 struct guestfs_ls_ret ret;
164 ret.listing.listing_len = count_strings (r);
165 ret.listing.listing_val = r;
166 reply ((xdrproc_t) &xdr_guestfs_ls_ret, (char *) &ret);
170 static void list_devices_stub (XDR *xdr_in)
174 r = do_list_devices ();
176 /* do_list_devices has already called reply_with_error, so just return */
179 struct guestfs_list_devices_ret ret;
180 ret.devices.devices_len = count_strings (r);
181 ret.devices.devices_val = r;
182 reply ((xdrproc_t) &xdr_guestfs_list_devices_ret, (char *) &ret);
186 static void list_partitions_stub (XDR *xdr_in)
190 r = do_list_partitions ();
192 /* do_list_partitions has already called reply_with_error, so just return */
195 struct guestfs_list_partitions_ret ret;
196 ret.partitions.partitions_len = count_strings (r);
197 ret.partitions.partitions_val = r;
198 reply ((xdrproc_t) &xdr_guestfs_list_partitions_ret, (char *) &ret);
202 static void pvs_full_stub (XDR *xdr_in)
204 guestfs_lvm_int_pv_list *r;
208 /* do_pvs_full has already called reply_with_error, so just return */
211 struct guestfs_pvs_full_ret ret;
213 reply ((xdrproc_t) &xdr_guestfs_pvs_full_ret, (char *) &ret);
214 xdr_free ((xdrproc_t) xdr_guestfs_pvs_full_ret, (char *) &ret);
217 static void vgs_full_stub (XDR *xdr_in)
219 guestfs_lvm_int_vg_list *r;
223 /* do_vgs_full has already called reply_with_error, so just return */
226 struct guestfs_vgs_full_ret ret;
228 reply ((xdrproc_t) &xdr_guestfs_vgs_full_ret, (char *) &ret);
229 xdr_free ((xdrproc_t) xdr_guestfs_vgs_full_ret, (char *) &ret);
232 static void lvs_full_stub (XDR *xdr_in)
234 guestfs_lvm_int_lv_list *r;
238 /* do_lvs_full has already called reply_with_error, so just return */
241 struct guestfs_lvs_full_ret ret;
243 reply ((xdrproc_t) &xdr_guestfs_lvs_full_ret, (char *) &ret);
244 xdr_free ((xdrproc_t) xdr_guestfs_lvs_full_ret, (char *) &ret);
247 void dispatch_incoming_message (XDR *xdr_in)
250 case GUESTFS_PROC_MOUNT:
253 case GUESTFS_PROC_SYNC:
256 case GUESTFS_PROC_TOUCH:
259 case GUESTFS_PROC_CAT:
262 case GUESTFS_PROC_LL:
265 case GUESTFS_PROC_LS:
268 case GUESTFS_PROC_LIST_DEVICES:
269 list_devices_stub (xdr_in);
271 case GUESTFS_PROC_LIST_PARTITIONS:
272 list_partitions_stub (xdr_in);
274 case GUESTFS_PROC_PVS_FULL:
275 pvs_full_stub (xdr_in);
277 case GUESTFS_PROC_VGS_FULL:
278 vgs_full_stub (xdr_in);
280 case GUESTFS_PROC_LVS_FULL:
281 lvs_full_stub (xdr_in);
284 reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr);
288 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";
290 static int lvm_tokenize_pv (char *str, struct guestfs_lvm_int_pv *r)
292 char *tok, *p, *next;
296 fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
299 if (!*str || isspace (*str)) {
300 fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
305 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_name");
308 p = strchrnul (tok, ',');
309 if (*p) next = p+1; else next = NULL;
311 r->pv_name = strdup (tok);
312 if (r->pv_name == NULL) {
318 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_uuid");
321 p = strchrnul (tok, ',');
322 if (*p) next = p+1; else next = NULL;
324 for (i = j = 0; i < 32; ++j) {
325 if (tok[j] == '\0') {
326 fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
328 } else if (tok[j] != '-')
329 r->pv_uuid[i++] = tok[j];
333 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_fmt");
336 p = strchrnul (tok, ',');
337 if (*p) next = p+1; else next = NULL;
339 r->pv_fmt = strdup (tok);
340 if (r->pv_fmt == NULL) {
346 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_size");
349 p = strchrnul (tok, ',');
350 if (*p) next = p+1; else next = NULL;
352 if (sscanf (tok, "%"SCNu64, &r->pv_size) != 1) {
353 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_size");
358 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "dev_size");
361 p = strchrnul (tok, ',');
362 if (*p) next = p+1; else next = NULL;
364 if (sscanf (tok, "%"SCNu64, &r->dev_size) != 1) {
365 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "dev_size");
370 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_free");
373 p = strchrnul (tok, ',');
374 if (*p) next = p+1; else next = NULL;
376 if (sscanf (tok, "%"SCNu64, &r->pv_free) != 1) {
377 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_free");
382 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_used");
385 p = strchrnul (tok, ',');
386 if (*p) next = p+1; else next = NULL;
388 if (sscanf (tok, "%"SCNu64, &r->pv_used) != 1) {
389 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_used");
394 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_attr");
397 p = strchrnul (tok, ',');
398 if (*p) next = p+1; else next = NULL;
400 r->pv_attr = strdup (tok);
401 if (r->pv_attr == NULL) {
407 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_pe_count");
410 p = strchrnul (tok, ',');
411 if (*p) next = p+1; else next = NULL;
413 if (sscanf (tok, "%"SCNi64, &r->pv_pe_count) != 1) {
414 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_pe_count");
419 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_pe_alloc_count");
422 p = strchrnul (tok, ',');
423 if (*p) next = p+1; else next = NULL;
425 if (sscanf (tok, "%"SCNi64, &r->pv_pe_alloc_count) != 1) {
426 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_pe_alloc_count");
431 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_tags");
434 p = strchrnul (tok, ',');
435 if (*p) next = p+1; else next = NULL;
437 r->pv_tags = strdup (tok);
438 if (r->pv_tags == NULL) {
444 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pe_start");
447 p = strchrnul (tok, ',');
448 if (*p) next = p+1; else next = NULL;
450 if (sscanf (tok, "%"SCNu64, &r->pe_start) != 1) {
451 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pe_start");
456 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_mda_count");
459 p = strchrnul (tok, ',');
460 if (*p) next = p+1; else next = NULL;
462 if (sscanf (tok, "%"SCNi64, &r->pv_mda_count) != 1) {
463 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_mda_count");
468 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_mda_free");
471 p = strchrnul (tok, ',');
472 if (*p) next = p+1; else next = NULL;
474 if (sscanf (tok, "%"SCNu64, &r->pv_mda_free) != 1) {
475 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "pv_mda_free");
480 fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
486 guestfs_lvm_int_pv_list *
487 parse_command_line_pvs (void)
492 guestfs_lvm_int_pv_list *ret;
495 ret = malloc (sizeof *ret);
497 reply_with_perror ("malloc");
501 ret->guestfs_lvm_int_pv_list_len = 0;
502 ret->guestfs_lvm_int_pv_list_val = NULL;
504 r = command (&out, &err,
506 "-o", lvm_pv_cols, "--unbuffered", "--noheadings",
507 "--nosuffix", "--separator", ",", "--units", "b", NULL);
509 reply_with_error ("%s", err);
517 /* Tokenize each line of the output. */
521 pend = strchr (p, '\n'); /* Get the next line of output. */
527 while (*p && isspace (*p)) /* Skip any leading whitespace. */
530 if (!*p) { /* Empty line? Skip it. */
535 /* Allocate some space to store this next entry. */
536 newp = realloc (ret->guestfs_lvm_int_pv_list_val,
537 sizeof (guestfs_lvm_int_pv) * (i+1));
539 reply_with_perror ("realloc");
540 free (ret->guestfs_lvm_int_pv_list_val);
545 ret->guestfs_lvm_int_pv_list_val = newp;
547 /* Tokenize the next entry. */
548 r = lvm_tokenize_pv (p, &ret->guestfs_lvm_int_pv_list_val[i]);
550 reply_with_error ("failed to parse output of 'pvs' command");
551 free (ret->guestfs_lvm_int_pv_list_val);
561 ret->guestfs_lvm_int_pv_list_len = i;
566 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";
568 static int lvm_tokenize_vg (char *str, struct guestfs_lvm_int_vg *r)
570 char *tok, *p, *next;
574 fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
577 if (!*str || isspace (*str)) {
578 fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
583 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_name");
586 p = strchrnul (tok, ',');
587 if (*p) next = p+1; else next = NULL;
589 r->vg_name = strdup (tok);
590 if (r->vg_name == NULL) {
596 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_uuid");
599 p = strchrnul (tok, ',');
600 if (*p) next = p+1; else next = NULL;
602 for (i = j = 0; i < 32; ++j) {
603 if (tok[j] == '\0') {
604 fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
606 } else if (tok[j] != '-')
607 r->vg_uuid[i++] = tok[j];
611 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_fmt");
614 p = strchrnul (tok, ',');
615 if (*p) next = p+1; else next = NULL;
617 r->vg_fmt = strdup (tok);
618 if (r->vg_fmt == NULL) {
624 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_attr");
627 p = strchrnul (tok, ',');
628 if (*p) next = p+1; else next = NULL;
630 r->vg_attr = strdup (tok);
631 if (r->vg_attr == NULL) {
637 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_size");
640 p = strchrnul (tok, ',');
641 if (*p) next = p+1; else next = NULL;
643 if (sscanf (tok, "%"SCNu64, &r->vg_size) != 1) {
644 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_size");
649 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_free");
652 p = strchrnul (tok, ',');
653 if (*p) next = p+1; else next = NULL;
655 if (sscanf (tok, "%"SCNu64, &r->vg_free) != 1) {
656 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_free");
661 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_sysid");
664 p = strchrnul (tok, ',');
665 if (*p) next = p+1; else next = NULL;
667 r->vg_sysid = strdup (tok);
668 if (r->vg_sysid == NULL) {
674 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_extent_size");
677 p = strchrnul (tok, ',');
678 if (*p) next = p+1; else next = NULL;
680 if (sscanf (tok, "%"SCNu64, &r->vg_extent_size) != 1) {
681 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_extent_size");
686 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_extent_count");
689 p = strchrnul (tok, ',');
690 if (*p) next = p+1; else next = NULL;
692 if (sscanf (tok, "%"SCNi64, &r->vg_extent_count) != 1) {
693 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_extent_count");
698 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_free_count");
701 p = strchrnul (tok, ',');
702 if (*p) next = p+1; else next = NULL;
704 if (sscanf (tok, "%"SCNi64, &r->vg_free_count) != 1) {
705 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_free_count");
710 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "max_lv");
713 p = strchrnul (tok, ',');
714 if (*p) next = p+1; else next = NULL;
716 if (sscanf (tok, "%"SCNi64, &r->max_lv) != 1) {
717 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "max_lv");
722 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "max_pv");
725 p = strchrnul (tok, ',');
726 if (*p) next = p+1; else next = NULL;
728 if (sscanf (tok, "%"SCNi64, &r->max_pv) != 1) {
729 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "max_pv");
734 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "pv_count");
737 p = strchrnul (tok, ',');
738 if (*p) next = p+1; else next = NULL;
740 if (sscanf (tok, "%"SCNi64, &r->pv_count) != 1) {
741 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "pv_count");
746 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_count");
749 p = strchrnul (tok, ',');
750 if (*p) next = p+1; else next = NULL;
752 if (sscanf (tok, "%"SCNi64, &r->lv_count) != 1) {
753 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_count");
758 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "snap_count");
761 p = strchrnul (tok, ',');
762 if (*p) next = p+1; else next = NULL;
764 if (sscanf (tok, "%"SCNi64, &r->snap_count) != 1) {
765 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "snap_count");
770 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_seqno");
773 p = strchrnul (tok, ',');
774 if (*p) next = p+1; else next = NULL;
776 if (sscanf (tok, "%"SCNi64, &r->vg_seqno) != 1) {
777 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_seqno");
782 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_tags");
785 p = strchrnul (tok, ',');
786 if (*p) next = p+1; else next = NULL;
788 r->vg_tags = strdup (tok);
789 if (r->vg_tags == NULL) {
795 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_mda_count");
798 p = strchrnul (tok, ',');
799 if (*p) next = p+1; else next = NULL;
801 if (sscanf (tok, "%"SCNi64, &r->vg_mda_count) != 1) {
802 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "vg_mda_count");
807 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "vg_mda_free");
810 p = strchrnul (tok, ',');
811 if (*p) next = p+1; else next = NULL;
813 if (sscanf (tok, "%"SCNu64, &r->vg_mda_free) != 1) {
814 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "vg_mda_free");
819 fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
825 guestfs_lvm_int_vg_list *
826 parse_command_line_vgs (void)
831 guestfs_lvm_int_vg_list *ret;
834 ret = malloc (sizeof *ret);
836 reply_with_perror ("malloc");
840 ret->guestfs_lvm_int_vg_list_len = 0;
841 ret->guestfs_lvm_int_vg_list_val = NULL;
843 r = command (&out, &err,
845 "-o", lvm_vg_cols, "--unbuffered", "--noheadings",
846 "--nosuffix", "--separator", ",", "--units", "b", NULL);
848 reply_with_error ("%s", err);
856 /* Tokenize each line of the output. */
860 pend = strchr (p, '\n'); /* Get the next line of output. */
866 while (*p && isspace (*p)) /* Skip any leading whitespace. */
869 if (!*p) { /* Empty line? Skip it. */
874 /* Allocate some space to store this next entry. */
875 newp = realloc (ret->guestfs_lvm_int_vg_list_val,
876 sizeof (guestfs_lvm_int_vg) * (i+1));
878 reply_with_perror ("realloc");
879 free (ret->guestfs_lvm_int_vg_list_val);
884 ret->guestfs_lvm_int_vg_list_val = newp;
886 /* Tokenize the next entry. */
887 r = lvm_tokenize_vg (p, &ret->guestfs_lvm_int_vg_list_val[i]);
889 reply_with_error ("failed to parse output of 'vgs' command");
890 free (ret->guestfs_lvm_int_vg_list_val);
900 ret->guestfs_lvm_int_vg_list_len = i;
905 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";
907 static int lvm_tokenize_lv (char *str, struct guestfs_lvm_int_lv *r)
909 char *tok, *p, *next;
913 fprintf (stderr, "%s: failed: passed a NULL string\n", __func__);
916 if (!*str || isspace (*str)) {
917 fprintf (stderr, "%s: failed: passed a empty string or one beginning with whitespace\n", __func__);
922 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_name");
925 p = strchrnul (tok, ',');
926 if (*p) next = p+1; else next = NULL;
928 r->lv_name = strdup (tok);
929 if (r->lv_name == NULL) {
935 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_uuid");
938 p = strchrnul (tok, ',');
939 if (*p) next = p+1; else next = NULL;
941 for (i = j = 0; i < 32; ++j) {
942 if (tok[j] == '\0') {
943 fprintf (stderr, "%s: failed to parse UUID from '%s'\n", __func__, tok);
945 } else if (tok[j] != '-')
946 r->lv_uuid[i++] = tok[j];
950 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_attr");
953 p = strchrnul (tok, ',');
954 if (*p) next = p+1; else next = NULL;
956 r->lv_attr = strdup (tok);
957 if (r->lv_attr == NULL) {
963 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_major");
966 p = strchrnul (tok, ',');
967 if (*p) next = p+1; else next = NULL;
969 if (sscanf (tok, "%"SCNi64, &r->lv_major) != 1) {
970 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_major");
975 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_minor");
978 p = strchrnul (tok, ',');
979 if (*p) next = p+1; else next = NULL;
981 if (sscanf (tok, "%"SCNi64, &r->lv_minor) != 1) {
982 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_minor");
987 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_kernel_major");
990 p = strchrnul (tok, ',');
991 if (*p) next = p+1; else next = NULL;
993 if (sscanf (tok, "%"SCNi64, &r->lv_kernel_major) != 1) {
994 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_kernel_major");
999 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_kernel_minor");
1002 p = strchrnul (tok, ',');
1003 if (*p) next = p+1; else next = NULL;
1005 if (sscanf (tok, "%"SCNi64, &r->lv_kernel_minor) != 1) {
1006 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "lv_kernel_minor");
1011 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_size");
1014 p = strchrnul (tok, ',');
1015 if (*p) next = p+1; else next = NULL;
1017 if (sscanf (tok, "%"SCNu64, &r->lv_size) != 1) {
1018 fprintf (stderr, "%s: failed to parse size '%s' from token %s\n", __func__, tok, "lv_size");
1023 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "seg_count");
1026 p = strchrnul (tok, ',');
1027 if (*p) next = p+1; else next = NULL;
1029 if (sscanf (tok, "%"SCNi64, &r->seg_count) != 1) {
1030 fprintf (stderr, "%s: failed to parse int '%s' from token %s\n", __func__, tok, "seg_count");
1035 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "origin");
1038 p = strchrnul (tok, ',');
1039 if (*p) next = p+1; else next = NULL;
1041 r->origin = strdup (tok);
1042 if (r->origin == NULL) {
1048 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "snap_percent");
1051 p = strchrnul (tok, ',');
1052 if (*p) next = p+1; else next = NULL;
1055 r->snap_percent = -1;
1056 else if (sscanf (tok, "%f", &r->snap_percent) != 1) {
1057 fprintf (stderr, "%s: failed to parse float '%s' from token %s\n", __func__, tok, "snap_percent");
1062 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "copy_percent");
1065 p = strchrnul (tok, ',');
1066 if (*p) next = p+1; else next = NULL;
1069 r->copy_percent = -1;
1070 else if (sscanf (tok, "%f", &r->copy_percent) != 1) {
1071 fprintf (stderr, "%s: failed to parse float '%s' from token %s\n", __func__, tok, "copy_percent");
1076 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "move_pv");
1079 p = strchrnul (tok, ',');
1080 if (*p) next = p+1; else next = NULL;
1082 r->move_pv = strdup (tok);
1083 if (r->move_pv == NULL) {
1089 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "lv_tags");
1092 p = strchrnul (tok, ',');
1093 if (*p) next = p+1; else next = NULL;
1095 r->lv_tags = strdup (tok);
1096 if (r->lv_tags == NULL) {
1102 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "mirror_log");
1105 p = strchrnul (tok, ',');
1106 if (*p) next = p+1; else next = NULL;
1108 r->mirror_log = strdup (tok);
1109 if (r->mirror_log == NULL) {
1115 fprintf (stderr, "%s: failed: string finished early, around token %s\n", __func__, "modules");
1118 p = strchrnul (tok, ',');
1119 if (*p) next = p+1; else next = NULL;
1121 r->modules = strdup (tok);
1122 if (r->modules == NULL) {
1128 fprintf (stderr, "%s: failed: extra tokens at end of string\n", __func__);
1134 guestfs_lvm_int_lv_list *
1135 parse_command_line_lvs (void)
1140 guestfs_lvm_int_lv_list *ret;
1143 ret = malloc (sizeof *ret);
1145 reply_with_perror ("malloc");
1149 ret->guestfs_lvm_int_lv_list_len = 0;
1150 ret->guestfs_lvm_int_lv_list_val = NULL;
1152 r = command (&out, &err,
1154 "-o", lvm_lv_cols, "--unbuffered", "--noheadings",
1155 "--nosuffix", "--separator", ",", "--units", "b", NULL);
1157 reply_with_error ("%s", err);
1165 /* Tokenize each line of the output. */
1169 pend = strchr (p, '\n'); /* Get the next line of output. */
1175 while (*p && isspace (*p)) /* Skip any leading whitespace. */
1178 if (!*p) { /* Empty line? Skip it. */
1183 /* Allocate some space to store this next entry. */
1184 newp = realloc (ret->guestfs_lvm_int_lv_list_val,
1185 sizeof (guestfs_lvm_int_lv) * (i+1));
1187 reply_with_perror ("realloc");
1188 free (ret->guestfs_lvm_int_lv_list_val);
1193 ret->guestfs_lvm_int_lv_list_val = newp;
1195 /* Tokenize the next entry. */
1196 r = lvm_tokenize_lv (p, &ret->guestfs_lvm_int_lv_list_val[i]);
1198 reply_with_error ("failed to parse output of 'lvs' command");
1199 free (ret->guestfs_lvm_int_lv_list_val);
1209 ret->guestfs_lvm_int_lv_list_len = i;