mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_03_12-dev_get_primary_dev-fix-invalid-path-check.patch

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