]> git.ipfire.org Git - people/stevee/ipfire-3.x.git/blob - multipath-tools/patches/0015-RH-fix-output-buffer.patch
glibc: Disable multilib support on X86_64
[people/stevee/ipfire-3.x.git] / multipath-tools / patches / 0015-RH-fix-output-buffer.patch
1 ---
2 libmultipath/print.c | 31 +++++++++++++++++++++++++++----
3 1 file changed, 27 insertions(+), 4 deletions(-)
4
5 Index: multipath-tools-130222/libmultipath/print.c
6 ===================================================================
7 --- multipath-tools-130222.orig/libmultipath/print.c
8 +++ multipath-tools-130222/libmultipath/print.c
9 @@ -8,6 +8,8 @@
10 #include <sys/stat.h>
11 #include <dirent.h>
12 #include <unistd.h>
13 +#include <string.h>
14 +#include <errno.h>
15
16 #include "checkers.h"
17 #include "vector.h"
18 @@ -24,6 +26,7 @@
19 #include "switchgroup.h"
20 #include "devmapper.h"
21 #include "uevent.h"
22 +#include "debug.h"
23
24 #define MAX(x,y) (x > y) ? x : y
25 #define TAIL (line + len - 1 - c)
26 @@ -754,12 +757,32 @@ snprint_pathgroup (char * line, int len,
27 extern void
28 print_multipath_topology (struct multipath * mpp, int verbosity)
29 {
30 - char buff[MAX_LINE_LEN * MAX_LINES] = {};
31 + int resize;
32 + char *buff = NULL;
33 + char *old = NULL;
34 + int len, maxlen = MAX_LINE_LEN * MAX_LINES;
35
36 - memset(&buff[0], 0, MAX_LINE_LEN * MAX_LINES);
37 - snprint_multipath_topology(&buff[0], MAX_LINE_LEN * MAX_LINES,
38 - mpp, verbosity);
39 + buff = MALLOC(maxlen);
40 + do {
41 + if (!buff) {
42 + if (old)
43 + FREE(old);
44 + condlog(0, "couldn't allocate memory for list: %s\n",
45 + strerror(errno));
46 + return;
47 + }
48 +
49 + len = snprint_multipath_topology(buff, maxlen, mpp, verbosity);
50 + resize = (len == maxlen - 1);
51 +
52 + if (resize) {
53 + maxlen *= 2;
54 + old = buff;
55 + buff = REALLOC(buff, maxlen);
56 + }
57 + } while (resize);
58 printf("%s", buff);
59 + FREE(buff);
60 }
61
62 extern int