/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Changelog
*
* 05/02/2002 - First drop [HM]
*/
#include "tools.h"
int disks_found;
int parts_found;
int pv_disks_found;
int pv_parts_found;
int max_len;
static int _get_max_dev_name_len(struct dev_filter *filter)
{
int len = 0;
int maxlen = 0;
struct dev_iter *iter;
struct device *dev;
/* Do scan */
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
len = strlen(dev_name(dev));
if (len > maxlen)
maxlen = len;
}
dev_iter_destroy(iter);
return maxlen;
}
static void _count(struct device *dev, int *disks, int *parts)
{
int c = dev_name(dev)[strlen(dev_name(dev)) - 1];
/* Do scan */
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
/* Try if it is a PV first */
if ((label_read(dev, &label, UINT64_C(0)))) {
if (!dev_get_size(dev, &size)) {
log_error("Couldn't get size of \"%s\"",
dev_name(dev));
continue;
}
_print(cmd, dev, size, "LVM physical volume");
_count(dev, &pv_disks_found, &pv_parts_found);
continue;
}
/* If user just wants PVs we are done */
if (arg_count(cmd, lvmpartition_ARG))
continue;
/* What other device is it? */
if (!_check_device(cmd, dev))
continue;
}
dev_iter_destroy(iter);