2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
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.
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
18 static int _pvdisplay_single(struct cmd_context *cmd,
19 struct volume_group *vg,
20 struct physical_volume *pv, void *handle)
23 int ret = ECMD_PROCESSED;
25 struct volume_group *old_vg = vg;
27 const char *pv_name = pv_dev_name(pv);
28 const char *vg_name = NULL;
30 if (!is_orphan(pv) && !vg) {
31 vg_name = pv_vg_name(pv);
32 vg = vg_read(cmd, vg_name, (char *)&pv->vgid, 0);
33 if (vg_read_error(vg)) {
34 log_error("Skipping volume group %s", vg_name);
36 /* FIXME If CLUSTERED should return ECMD_PROCESSED here */
41 * Replace possibly incomplete PV structure with new one
42 * allocated in vg_read_internal() path.
44 if (!(pvl = find_pv_in_vg(vg, pv_name))) {
45 log_error("Unable to find \"%s\" in volume group \"%s\"",
57 size = (pv_pe_count(pv) - pv_pe_alloc_count(pv)) *
60 if (arg_count(cmd, short_ARG)) {
61 log_print("Device \"%s\" has a capacity of %s", pv_name,
62 display_size(cmd, size));
66 if (pv_status(pv) & EXPORTED_VG)
67 log_print("Physical volume \"%s\" of volume group \"%s\" "
68 "is exported", pv_name, pv_vg_name(pv));
71 log_print("\"%s\" is a new physical volume of \"%s\"",
72 pv_name, display_size(cmd, size));
74 if (arg_count(cmd, colon_ARG)) {
79 pvdisplay_full(cmd, pv, handle);
81 if (arg_count(cmd, maps_ARG))
82 pvdisplay_segments(pv);
86 unlock_vg(cmd, vg_name);
93 int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
95 if (arg_count(cmd, columns_ARG)) {
96 if (arg_count(cmd, colon_ARG) || arg_count(cmd, maps_ARG) ||
97 arg_count(cmd, short_ARG)) {
98 log_error("Incompatible options selected");
99 return EINVALID_CMD_LINE;
101 return pvs(cmd, argc, argv);
102 } else if (arg_count(cmd, aligned_ARG) ||
103 arg_count(cmd, all_ARG) ||
104 arg_count(cmd, noheadings_ARG) ||
105 arg_count(cmd, options_ARG) ||
106 arg_count(cmd, separator_ARG) ||
107 arg_count(cmd, sort_ARG) || arg_count(cmd, unbuffered_ARG)) {
108 log_error("Incompatible options selected");
109 return EINVALID_CMD_LINE;
112 if (arg_count(cmd, colon_ARG) && arg_count(cmd, maps_ARG)) {
113 log_error("Option -v not allowed with option -c");
114 return EINVALID_CMD_LINE;
117 return process_each_pv(cmd, argc, argv, NULL, 0, 0, NULL,