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