]> sourceware.org Git - lvm2.git/blame - tools/pvdisplay.c
dev-type: detect mixed dos partition with gpt's PMBR
[lvm2.git] / tools / pvdisplay.c
CommitLineData
269930c0 1/*
6606c3ae 2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
be684599 3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
269930c0 4 *
6606c3ae 5 * This file is part of LVM2.
269930c0 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.
269930c0 10 *
be684599 11 * You should have received a copy of the GNU Lesser General Public License
6606c3ae 12 * along with this program; if not, write to the Free Software Foundation,
fcbef05a 13 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
269930c0
AK
14 */
15
16#include "tools.h"
17
72b2cb61 18static int _pvdisplay_single(struct cmd_context *cmd,
223c62e7 19 struct volume_group *vg,
51d96a17
PR
20 struct physical_volume *pv,
21 struct processing_handle *handle __attribute__((unused)))
269930c0 22{
f1a000a4 23 const char *pv_name = pv_dev_name(pv);
e663b4e8 24 int ret = ECMD_PROCESSED;
6fda126d 25 uint64_t size;
e663b4e8 26
9c1dbeb3 27 if (is_orphan(pv))
ff77bb1a 28 size = pv_size(pv);
c7f0b573 29 else
bd67a315 30 size = (uint64_t)(pv_pe_count(pv) - pv_pe_alloc_count(pv)) *
ff77bb1a 31 pv_pe_size(pv);
269930c0 32
7e671e5d 33 if (arg_is_set(cmd, short_ARG)) {
4c64ed4c 34 log_print("Device \"%s\" has a capacity of %s", pv_name,
72b2cb61 35 display_size(cmd, size));
e663b4e8 36 goto out;
269930c0
AK
37 }
38
ff77bb1a 39 if (pv_status(pv) & EXPORTED_VG)
52525bde
ZK
40 log_print_unless_silent("Physical volume \"%s\" of volume group \"%s\" "
41 "is exported", pv_name, pv_vg_name(pv));
269930c0 42
9c1dbeb3 43 if (is_orphan(pv))
52525bde
ZK
44 log_print_unless_silent("\"%s\" is a new physical volume of \"%s\"",
45 pv_name, display_size(cmd, size));
269930c0 46
7e671e5d 47 if (arg_is_set(cmd, colon_ARG)) {
cd77c5a7 48 pvdisplay_colons(pv);
e663b4e8 49 goto out;
269930c0
AK
50 }
51
51d96a17 52 pvdisplay_full(cmd, pv, NULL);
269930c0 53
7e671e5d 54 if (arg_is_set(cmd, maps_ARG))
4baa42be 55 pvdisplay_segments(pv);
e663b4e8
AK
56
57out:
e663b4e8 58 return ret;
5a52dca9
AK
59}
60
61int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
62{
f1a000a4
DT
63 int ret;
64
7e671e5d
AK
65 if (arg_is_set(cmd, columns_ARG)) {
66 if (arg_is_set(cmd, colon_ARG) || arg_is_set(cmd, maps_ARG) ||
67 arg_is_set(cmd, short_ARG)) {
4c64ed4c
AK
68 log_error("Incompatible options selected");
69 return EINVALID_CMD_LINE;
70 }
71 return pvs(cmd, argc, argv);
cc82dc7b
ZK
72 }
73
7e671e5d
AK
74 if (arg_is_set(cmd, aligned_ARG) ||
75 arg_is_set(cmd, all_ARG) ||
76 arg_is_set(cmd, binary_ARG) ||
77 arg_is_set(cmd, noheadings_ARG) ||
78 arg_is_set(cmd, options_ARG) ||
79 arg_is_set(cmd, separator_ARG) ||
80 arg_is_set(cmd, sort_ARG) ||
81 arg_is_set(cmd, unbuffered_ARG)) {
4c64ed4c
AK
82 log_error("Incompatible options selected");
83 return EINVALID_CMD_LINE;
84 }
5a52dca9 85
7e671e5d 86 if (arg_is_set(cmd, colon_ARG) && arg_is_set(cmd, maps_ARG)) {
844afa32
ZK
87 log_error("Option -c not allowed with option -m");
88 return EINVALID_CMD_LINE;
89 }
90
7e671e5d 91 if (arg_is_set(cmd, colon_ARG) && arg_is_set(cmd, short_ARG)) {
844afa32 92 log_error("Option -c is not allowed with option -s");
5a52dca9
AK
93 return EINVALID_CMD_LINE;
94 }
95
6620dc94
DT
96 /*
97 * Without -a, command only looks at PVs and can use hints,
98 * with -a, the command looks at all (non-hinted) devices.
99 */
100 if (arg_is_set(cmd, all_ARG))
101 cmd->use_hints = 0;
102
71671778
DT
103 ret = process_each_pv(cmd, argc, argv, NULL,
104 arg_is_set(cmd, all_ARG), 0,
105 NULL, _pvdisplay_single);
f1a000a4 106
f1a000a4 107 return ret;
269930c0 108}
This page took 0.238473 seconds and 6 git commands to generate.