Blame SOURCES/0015-RH-fix-output-buffer.patch

4728c8
---
4728c8
 libmultipath/print.c |   31 +++++++++++++++++++++++++++----
4728c8
 1 file changed, 27 insertions(+), 4 deletions(-)
4728c8
4728c8
Index: multipath-tools-130222/libmultipath/print.c
4728c8
===================================================================
4728c8
--- multipath-tools-130222.orig/libmultipath/print.c
4728c8
+++ multipath-tools-130222/libmultipath/print.c
4728c8
@@ -8,6 +8,8 @@
4728c8
 #include <sys/stat.h>
4728c8
 #include <dirent.h>
4728c8
 #include <unistd.h>
4728c8
+#include <string.h>
4728c8
+#include <errno.h>
4728c8
 
4728c8
 #include "checkers.h"
4728c8
 #include "vector.h"
4728c8
@@ -24,6 +26,7 @@
4728c8
 #include "switchgroup.h"
4728c8
 #include "devmapper.h"
4728c8
 #include "uevent.h"
4728c8
+#include "debug.h"
4728c8
 
4728c8
 #define MAX(x,y) (x > y) ? x : y
4728c8
 #define TAIL     (line + len - 1 - c)
4728c8
@@ -754,12 +757,32 @@ snprint_pathgroup (char * line, int len,
4728c8
 extern void
4728c8
 print_multipath_topology (struct multipath * mpp, int verbosity)
4728c8
 {
4728c8
-	char buff[MAX_LINE_LEN * MAX_LINES] = {};
4728c8
+	int resize;
4728c8
+	char *buff = NULL;
4728c8
+	char *old = NULL;
4728c8
+	int len, maxlen = MAX_LINE_LEN * MAX_LINES;
4728c8
 
4728c8
-	memset(&buff[0], 0, MAX_LINE_LEN * MAX_LINES);
4728c8
-	snprint_multipath_topology(&buff[0], MAX_LINE_LEN * MAX_LINES,
4728c8
-				   mpp, verbosity);
4728c8
+	buff = MALLOC(maxlen);
4728c8
+	do {
4728c8
+		if (!buff) {
4728c8
+			if (old)
4728c8
+				FREE(old);
4728c8
+			condlog(0, "couldn't allocate memory for list: %s\n",
4728c8
+				strerror(errno));
4728c8
+			return;
4728c8
+		}
4728c8
+
4728c8
+		len = snprint_multipath_topology(buff, maxlen, mpp, verbosity);
4728c8
+		resize = (len == maxlen - 1);
4728c8
+
4728c8
+		if (resize) {
4728c8
+			maxlen *= 2;
4728c8
+			old = buff;
4728c8
+			buff = REALLOC(buff, maxlen);
4728c8
+		}
4728c8
+	} while (resize);
4728c8
 	printf("%s", buff);
4728c8
+	FREE(buff);
4728c8
 }
4728c8
 
4728c8
 extern int