lvm2/lvm2-2_03_12-dev_get_primary_dev-fix-invalid-path-check.patch
DistroBaker 78da9a698d Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/lvm2.git#d2cc5b0434310d77f9ef21e3da5220677753e81e
2021-02-22 16:05:37 +00:00

49 lines
1.7 KiB
Diff

From b3719266bd5e3a9e6737d6bda60e543121ddf343 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 9 Feb 2021 09:47:08 -0600
Subject: [PATCH] dev_get_primary_dev: fix invalid path check
Fix commit bee9f4efdd81 "filter-mpath: work with nvme devices"
which removed setting the path for readlink.
(cherry picked from commit f74f94c2ddb1d33d75d325c959344a566a621fd5)
Conflicts:
lib/device/dev-type.c
---
lib/device/dev-type.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 379afa8..1342e97 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -434,7 +434,7 @@ static int _has_sys_partition(struct device *dev)
int minor = (int) MINOR(dev->dev);
/* check if dev is a partition */
- if (dm_snprintf(path, sizeof(path), "%s/dev/block/%d:%d/partition",
+ if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/partition",
dm_sysfs_dir(), major, minor) < 0) {
log_error("dm_snprintf partition failed");
return 0;
@@ -660,8 +660,13 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
* - basename ../../block/md0/md0 = md0
* Parent's 'dev' sysfs attribute = /sys/block/md0/dev
*/
- if ((size = readlink(dirname(path), temp_path, sizeof(temp_path) - 1)) < 0) {
- log_sys_error("readlink", path);
+ if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d",
+ dm_sysfs_dir(), major, minor) < 0) {
+ log_warn("WARNING: %s: major:minor sysfs path is too long.", dev_name(dev));
+ return 0;
+ }
+ if ((size = readlink(path, temp_path, sizeof(temp_path) - 1)) < 0) {
+ log_warn("WARNING: Readlink of %s failed.", path);
goto out;
}
--
1.8.3.1