File sblim-gather-zECKD-fullpath.patch of Package sblim-gather.12177

From: Petr Tesarik <ptesarik@suse.com>
Date: 2017-03-24 12:05:31 +0100
Subject: Use full path to read ECKD sysfs attributes
References: bsc#1028716
Upstream: not yet

readSysfsAttr() apparently expects a full path. Confusion may be caused
by a difference in the parameter name in definition and declaration in
header file. The definition clearly states "devicePath":

ssize_t readSysfsAttr(const char *devicePath, const char *deviceAttr,
                     char *value, ssize_t len)

But the declaration in the header file says "deviceName":

ssize_t readSysfsAttr(const char *deviceName, const char *deviceAttr,
                      char *value, ssize_t len);

In any case, a relative path does not work.

Signed-off-by: Petr Tesarik <ptesarik@suse.com>
---
 plugin/metriczECKD.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: sblim-gather-2.2.8/plugin/metriczECKD.c
===================================================================
--- sblim-gather-2.2.8.orig/plugin/metriczECKD.c
+++ sblim-gather-2.2.8/plugin/metriczECKD.c
@@ -234,7 +234,7 @@ char* readSysFs(char* deviceName) {
 	
 int metricRetrECKD( int mid, 
 			   MetricReturner mret ) { 
-	char dirpath[256];
+	char dirpath[256], devpath[256];
 	int deviceCount = 0;
 
 	DIR *dirfd;
@@ -252,7 +252,12 @@ int metricRetrECKD( int mid,
 			   "%x.%x.%4x", &css, &lcss, &ccw) != 3)
 			continue;
 
-		values = readSysFs(dent->d_name);
+		if (snprintf(devpath, 255, "%s/%s", dirpath, dent->d_name) >= 255) {
+			DBGONLY(printf("device path too long : %s/%s", dirpath, dent->d_name));
+			devpath[255] = '\x0';
+		}
+
+		values = readSysFs(devpath);
 		DBGONLY(printf("device name = %s\n", dent->d_name);)
 
 		if (values!=NULL) {
openSUSE Build Service is sponsored by