1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Skip devices that are too small to be PVs.

This commit is contained in:
Alasdair Kergon 2004-12-21 17:54:52 +00:00
parent db1cd37745
commit d46fd67fb6
3 changed files with 26 additions and 7 deletions

View File

@ -1,5 +1,6 @@
Version 2.00.32 -
====================================
Skip devices that are too small to be PVs.
Fix pvchange -x segfault with lvm2-format orphan.
Cope with empty msdos partition tables.
Add CONTRIBUTORS file.

View File

@ -238,12 +238,14 @@ int dev_get_size(const struct device *dev, uint64_t *size)
if (ioctl(fd, BLKGETSIZE64, size) < 0) {
log_sys_error("ioctl BLKGETSIZE64", name);
close(fd);
if (close(fd))
log_sys_error("close", name);
return 0;
}
*size >>= BLKSIZE_SHIFT; /* Convert to sectors */
close(fd);
if (close(fd))
log_sys_error("close", name);
log_very_verbose("%s: size is %" PRIu64 " sectors", name, *size);

View File

@ -18,6 +18,7 @@
#include "filter.h"
#include "lvm-string.h"
#include "config.h"
#include "metadata.h"
#include <dirent.h>
#include <unistd.h>
@ -75,7 +76,8 @@ static int _passes_lvm_type_device_filter(struct dev_filter *f,
struct device *dev)
{
const char *name = dev_name(dev);
int ret = 1;
int ret = 0;
uint64_t size;
/* Is this a recognised device type? */
if (!_max_partitions_by_major[MAJOR(dev->dev)]) {
@ -90,12 +92,26 @@ static int _passes_lvm_type_device_filter(struct dev_filter *f,
return 0;
}
if (is_partitioned_dev(dev)) {
log_debug("%s: Skipping: partition table signature found",
name);
ret = 0;
/* Check it's not too small */
if (!dev_get_size(dev, &size)) {
log_debug("%s: Skipping: dev_get_size failed", name);
goto out;
}
if (size < PV_MIN_SIZE) {
log_debug("%s: Skipping: Too small to hold a PV", name);
goto out;
}
if (is_partitioned_dev(dev)) {
log_debug("%s: Skipping: Partition table signature found",
name);
goto out;
}
ret = 1;
out:
dev_close(dev);
return ret;