When not obtaining device from udev, we are doing deep devdir scan,
and at the same time we try to insert everything what /sys/dev/block
knows about. However in case lvm2 is configured to use nonstardard
devdir this way it will see (and scan) devices from a real system.
lvm2 test suite is using its own test devdir with its
own device nodes. To avoid touching real /dev devices, validate
the device node exist in give dir and do not insert such device
into a cache.
With obtain list from udev this patch has no effect
(the normal user path).
Version 2.02.151
=================================
+ When not obtaining devs from udev, check they exist before caching them.
Detect device mismatch also when compiling without udev support.
Version 2.02.150 - 9th April 2016
static struct device *_insert_sysfs_dev(dev_t devno, const char *devname)
{
+ static struct device _fake_dev = { .flags = DEV_USED_FOR_LV };
+ struct stat stat0;
char path[PATH_MAX];
char *path_copy;
struct device *dev;
return NULL;
}
+ if (lstat(path, &stat0) < 0) {
+ /* When device node does not exist return fake entry.
+ * This may happen when i.e. lvm2 device dir != /dev */
+ log_debug("%s: Not available device node", path);
+ return &_fake_dev;
+ }
+
if (!(dev = _dev_create(devno)))
return_NULL;