Branch data Line data Source code
1 : : /*
2 : : * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 : : * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
4 : : *
5 : : * This file is part of LVM2.
6 : : *
7 : : * This copyrighted material is made available to anyone wishing to use,
8 : : * modify, copy, or redistribute it subject to the terms and conditions
9 : : * of the GNU Lesser General Public License v.2.1.
10 : : *
11 : : * You should have received a copy of the GNU Lesser General Public License
12 : : * along with this program; if not, write to the Free Software Foundation,
13 : : * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 : : */
15 : :
16 : : #include "tools.h"
17 : :
18 : 0 : static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
19 : : struct volume_group *vg,
20 : : void *handle __attribute((unused)))
21 : : {
22 : : /* FIXME Do the active check here if activevolumegroups_ARG ? */
23 : 0 : vg_check_status(vg, EXPORTED_VG);
24 : :
25 [ # # ]: 0 : if (arg_count(cmd, colon_ARG)) {
26 : 0 : vgdisplay_colons(vg);
27 : 0 : return ECMD_PROCESSED;
28 : : }
29 : :
30 [ # # ]: 0 : if (arg_count(cmd, short_ARG)) {
31 : 0 : vgdisplay_short(vg);
32 : 0 : return ECMD_PROCESSED;
33 : : }
34 : :
35 : 0 : vgdisplay_full(vg); /* was vg_show */
36 : :
37 [ # # ]: 0 : if (arg_count(cmd, verbose_ARG)) {
38 : 0 : vgdisplay_extents(vg);
39 : :
40 : 0 : process_each_lv_in_vg(cmd, vg, NULL, NULL, NULL, NULL,
41 : : (process_single_lv_fn_t)lvdisplay_full);
42 : :
43 : 0 : log_print("--- Physical volumes ---");
44 : 0 : process_each_pv_in_vg(cmd, vg, NULL, NULL,
45 : : (process_single_pv_fn_t)pvdisplay_short);
46 : : }
47 : :
48 : 0 : check_current_backup(vg);
49 : :
50 : 0 : return ECMD_PROCESSED;
51 : : }
52 : :
53 : 0 : int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
54 : : {
55 [ # # ]: 0 : if (arg_count(cmd, columns_ARG)) {
56 [ # # # # # : 0 : if (arg_count(cmd, colon_ARG) ||
# ]
57 : 0 : arg_count(cmd, activevolumegroups_ARG) ||
58 : 0 : arg_count(cmd, short_ARG)) {
59 : 0 : log_error("Incompatible options selected");
60 : 0 : return EINVALID_CMD_LINE;
61 : : }
62 : 0 : return vgs(cmd, argc, argv);
63 [ # # # # # : 0 : } else if (arg_count(cmd, aligned_ARG) ||
# # # # #
# # ]
64 : 0 : arg_count(cmd, noheadings_ARG) ||
65 : 0 : arg_count(cmd, options_ARG) ||
66 : 0 : arg_count(cmd, separator_ARG) ||
67 : 0 : arg_count(cmd, sort_ARG) || arg_count(cmd, unbuffered_ARG)) {
68 : 0 : log_error("Incompatible options selected");
69 : 0 : return EINVALID_CMD_LINE;
70 : : }
71 : :
72 [ # # ][ # # ]: 0 : if (arg_count(cmd, colon_ARG) && arg_count(cmd, short_ARG)) {
73 : 0 : log_error("Option -c is not allowed with option -s");
74 : 0 : return EINVALID_CMD_LINE;
75 : : }
76 : :
77 [ # # ][ # # ]: 0 : if (argc && arg_count(cmd, activevolumegroups_ARG)) {
78 : 0 : log_error("Option -A is not allowed with volume group names");
79 : 0 : return EINVALID_CMD_LINE;
80 : : }
81 : :
82 : : /********* FIXME: Do without this - or else 2(+) passes!
83 : : Figure out longest volume group name
84 : : for (c = opt; opt < argc; opt++) {
85 : : len = strlen(argv[opt]);
86 : : if (len > max_len)
87 : : max_len = len;
88 : : }
89 : : **********/
90 : :
91 : 0 : return process_each_vg(cmd, argc, argv, 0, NULL,
92 : : vgdisplay_single);
93 : :
94 : : /******** FIXME Need to count number processed
95 : : Add this to process_each_vg if arg_count(cmd,activevolumegroups_ARG) ?
96 : :
97 : : if (opt == argc) {
98 : : log_print("no ");
99 : : if (arg_count(cmd,activevolumegroups_ARG))
100 : : printf("active ");
101 : : printf("volume groups found\n\n");
102 : : return LVM_E_NO_VG;
103 : : }
104 : : ************/
105 : : }
|