mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Skip devices that are too small to be PVs.
This commit is contained in:
parent
db1cd37745
commit
d46fd67fb6
@ -1,5 +1,6 @@
|
|||||||
Version 2.00.32 -
|
Version 2.00.32 -
|
||||||
====================================
|
====================================
|
||||||
|
Skip devices that are too small to be PVs.
|
||||||
Fix pvchange -x segfault with lvm2-format orphan.
|
Fix pvchange -x segfault with lvm2-format orphan.
|
||||||
Cope with empty msdos partition tables.
|
Cope with empty msdos partition tables.
|
||||||
Add CONTRIBUTORS file.
|
Add CONTRIBUTORS file.
|
||||||
|
@ -238,12 +238,14 @@ int dev_get_size(const struct device *dev, uint64_t *size)
|
|||||||
|
|
||||||
if (ioctl(fd, BLKGETSIZE64, size) < 0) {
|
if (ioctl(fd, BLKGETSIZE64, size) < 0) {
|
||||||
log_sys_error("ioctl BLKGETSIZE64", name);
|
log_sys_error("ioctl BLKGETSIZE64", name);
|
||||||
close(fd);
|
if (close(fd))
|
||||||
|
log_sys_error("close", name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*size >>= BLKSIZE_SHIFT; /* Convert to sectors */
|
*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);
|
log_very_verbose("%s: size is %" PRIu64 " sectors", name, *size);
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "lvm-string.h"
|
#include "lvm-string.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "metadata.h"
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -75,7 +76,8 @@ static int _passes_lvm_type_device_filter(struct dev_filter *f,
|
|||||||
struct device *dev)
|
struct device *dev)
|
||||||
{
|
{
|
||||||
const char *name = dev_name(dev);
|
const char *name = dev_name(dev);
|
||||||
int ret = 1;
|
int ret = 0;
|
||||||
|
uint64_t size;
|
||||||
|
|
||||||
/* Is this a recognised device type? */
|
/* Is this a recognised device type? */
|
||||||
if (!_max_partitions_by_major[MAJOR(dev->dev)]) {
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_partitioned_dev(dev)) {
|
/* Check it's not too small */
|
||||||
log_debug("%s: Skipping: partition table signature found",
|
if (!dev_get_size(dev, &size)) {
|
||||||
name);
|
log_debug("%s: Skipping: dev_get_size failed", name);
|
||||||
ret = 0;
|
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);
|
dev_close(dev);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user