Blame SOURCES/lib-zfcp-hbaapi-2.1-find-sg-without-sysfs-deprecated.patch

6ef316
---
6ef316
 lib-zfcp-hbaapi-2.1/vlib_sysfs.c |   23 ++++++++++++++++++++---
6ef316
 1 file changed, 20 insertions(+), 3 deletions(-)
6ef316
6ef316
--- a/lib-zfcp-hbaapi-2.1/vlib_sysfs.c
6ef316
+++ b/lib-zfcp-hbaapi-2.1/vlib_sysfs.c
6ef316
@@ -310,14 +310,15 @@ HBA_STATUS sysfs_createAndReadConfigAdap
6ef316
 int sysfs_getUnitsFromPort(struct vlib_port *port)
6ef316
 {
6ef316
 	char path[PATH_MAX];
6ef316
-	char unitPath[PATH_MAX];
6ef316
+	char unitPath[PATH_MAX], unitPath2[PATH_MAX];
6ef316
 	char attr[ATTR_MAX];
6ef316
-	char *sg;
6ef316
+	char *sg, *sg2;
6ef316
 	struct vlib_unit unit;
6ef316
 	struct vlib_adapter *adapter;
6ef316
-	sfhelper_dir *dir, *sg_dir;
6ef316
+	sfhelper_dir *dir, *sg_dir, *sg_dir2;
6ef316
 	char *dirent;
6ef316
 	int ret;
6ef316
+	uint32_t sgindex;
6ef316
 
6ef316
 	adapter = getAdapterByHostNo(port->host);
6ef316
 	if (!adapter)
6ef316
@@ -369,6 +370,22 @@ int sysfs_getUnitsFromPort(struct vlib_p
6ef316
 			if (ret == 1)
6ef316
 				/* successful match */
6ef316
 				break;
6ef316
+			/* search match without CONFIG_SYSFS_DEPRECATED[_V2] */
6ef316
+			if (strncmp(sg, "scsi_generic", 13 /* full */) != 0)
6ef316
+				continue;
6ef316
+			snprintf(unitPath2, PATH_MAX, "%s/%s", unitPath, sg);
6ef316
+			sg_dir2 = sfhelper_opendir(unitPath2);
6ef316
+			if (sg_dir2 == NULL)
6ef316
+				continue;
6ef316
+			while (sg2 = sfhelper_getNextDirEnt(sg_dir2)) {
6ef316
+				if (sscanf(sg2, "sg%u", &sgindex) != 1)
6ef316
+					continue;
6ef316
+				snprintf(unit.sg_dev, sizeof(unit.sg_dev),
6ef316
+					 "%s", sg2);
6ef316
+				/* successful match */
6ef316
+				break;
6ef316
+			}
6ef316
+			sfhelper_closedir(sg_dir2);
6ef316
 		}
6ef316
 		sfhelper_closedir(sg_dir);
6ef316
 		addUnitToRepos(port, &unit);