summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2021-10-18 19:04:44 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2021-10-18 19:17:26 +0200
commit9cf4eac250ef7abd5e0961da2371294da07ab4de (patch)
tree2d39adb804733832b13adf8706bb8437f491f6fe /lib
parentbae1083472d9c589d59f93a4e0a137cb94ba5ed0 (diff)
downloadlvm2-9cf4eac250ef7abd5e0961da2371294da07ab4de.tar.gz
dev-cache: skip different filesystems on dir scan
When scanning configured /dev dir, avoid entring directories with different filesystem. This minimizes risk we will block on i.e. entring directory with mount point.
Diffstat (limited to 'lib')
-rw-r--r--lib/device/dev-cache.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index d454b5b30..6d706eb1e 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -1101,6 +1101,7 @@ static void _insert_dirs(struct dm_list *dirs)
static int _insert(const char *path, const struct stat *info,
int rec, int check_with_udev_db)
{
+ static long _st_dev = -1;
struct stat tinfo;
if (!info) {
@@ -1111,12 +1112,20 @@ static int _insert(const char *path, const struct stat *info,
info = &tinfo;
}
+ if (_st_dev == -1)
+ _st_dev = info->st_dev; /* first dir device */
+
if (check_with_udev_db && !_device_in_udev_db(info->st_rdev)) {
log_very_verbose("%s: Not in udev db", path);
return 0;
}
if (S_ISDIR(info->st_mode)) { /* add a directory */
+ if (info->st_dev != _st_dev) {
+ log_debug_devs("%s: Different filesystem in directory", path);
+ return 1;
+ }
+
/* check it's not a symbolic link */
if (lstat(path, &tinfo) < 0) {
log_sys_very_verbose("lstat", path);