Lines 1-4
Link Here
|
1 |
--- mcelog.c.orig 2016-02-10 18:38:43 UTC |
1 |
--- mcelog.c.orig 2016-10-10 22:08:11 UTC |
2 |
+++ mcelog.c |
2 |
+++ mcelog.c |
3 |
@@ -20,9 +20,22 @@ |
3 |
@@ -20,9 +20,22 @@ |
4 |
#define _GNU_SOURCE 1 |
4 |
#define _GNU_SOURCE 1 |
Lines 23-29
Link Here
|
23 |
#include <stdlib.h> |
23 |
#include <stdlib.h> |
24 |
#include <stdio.h> |
24 |
#include <stdio.h> |
25 |
#include <string.h> |
25 |
#include <string.h> |
26 |
@@ -61,9 +74,25 @@ |
26 |
@@ -60,9 +73,25 @@ |
27 |
#include "bus.h" |
27 |
#include "bus.h" |
28 |
#include "unknown.h" |
28 |
#include "unknown.h" |
29 |
|
29 |
|
Lines 49-55
Link Here
|
49 |
|
49 |
|
50 |
int ignore_nodev; |
50 |
int ignore_nodev; |
51 |
int filter_bogus = 1; |
51 |
int filter_bogus = 1; |
52 |
@@ -74,7 +103,9 @@ int ascii_mode; |
52 |
@@ -73,7 +102,9 @@ int ascii_mode; |
53 |
int dump_raw_ascii; |
53 |
int dump_raw_ascii; |
54 |
int daemon_mode; |
54 |
int daemon_mode; |
55 |
static char *inputfile; |
55 |
static char *inputfile; |
Lines 59-65
Link Here
|
59 |
static int foreground; |
59 |
static int foreground; |
60 |
int filter_memory_errors; |
60 |
int filter_memory_errors; |
61 |
static struct config_cred runcred = { .uid = -1U, .gid = -1U }; |
61 |
static struct config_cred runcred = { .uid = -1U, .gid = -1U }; |
62 |
@@ -83,6 +114,10 @@ static char pidfile_default[] = PID_FILE |
62 |
@@ -82,6 +113,10 @@ static char pidfile_default[] = PID_FILE |
63 |
static char logfile_default[] = LOG_FILE; |
63 |
static char logfile_default[] = LOG_FILE; |
64 |
static char *pidfile = pidfile_default; |
64 |
static char *pidfile = pidfile_default; |
65 |
static char *logfile; |
65 |
static char *logfile; |
Lines 70-76
Link Here
|
70 |
static int debug_numerrors; |
70 |
static int debug_numerrors; |
71 |
int imc_log = -1; |
71 |
int imc_log = -1; |
72 |
static int check_only = 0; |
72 |
static int check_only = 0; |
73 |
@@ -482,6 +517,7 @@ static void dump_mce_raw_ascii(struct mc |
73 |
@@ -196,6 +231,7 @@ static void parse_cpuid(u32 cpuid, u32 * |
|
|
74 |
*model += c.c.ext_model << 4; |
75 |
} |
76 |
|
77 |
+#ifdef __Linux__ |
78 |
static u32 unparse_cpuid(unsigned family, unsigned model) |
79 |
{ |
80 |
union { |
81 |
@@ -213,6 +249,7 @@ static u32 unparse_cpuid(unsigned family |
82 |
c.c.ext_model = model >> 4; |
83 |
return c.v; |
84 |
} |
85 |
+#endif |
86 |
|
87 |
static char *cputype_name[] = { |
88 |
[CPU_GENERIC] = "generic CPU", |
89 |
@@ -325,6 +362,7 @@ static char *vendor[] = { |
90 |
[8] = "NSC" |
91 |
}; |
92 |
|
93 |
+#ifdef __Linux__ |
94 |
static unsigned cpuvendor_to_num(char *name) |
95 |
{ |
96 |
unsigned i; |
97 |
@@ -339,6 +377,7 @@ static unsigned cpuvendor_to_num(char *n |
98 |
return i; |
99 |
return 0; |
100 |
} |
101 |
+#endif |
102 |
|
103 |
static char *cpuvendor_name(u32 cpuvendor) |
104 |
{ |
105 |
@@ -483,6 +522,7 @@ static void dump_mce_raw_ascii(struct mc |
74 |
Wprintf("\n"); |
106 |
Wprintf("\n"); |
75 |
} |
107 |
} |
76 |
|
108 |
|
Lines 78-89
Link Here
|
78 |
int is_cpu_supported(void) |
110 |
int is_cpu_supported(void) |
79 |
{ |
111 |
{ |
80 |
enum { |
112 |
enum { |
81 |
@@ -552,13 +588,58 @@ int is_cpu_supported(void) |
113 |
@@ -553,14 +593,61 @@ int is_cpu_supported(void) |
82 |
|
114 |
|
83 |
return 1; |
115 |
return 1; |
84 |
} |
116 |
} |
85 |
+#endif |
117 |
+#endif |
86 |
|
118 |
+ |
87 |
+#ifdef __FreeBSD__ |
119 |
+#ifdef __FreeBSD__ |
88 |
+int is_cpu_supported(void) |
120 |
+int is_cpu_supported(void) |
89 |
+{ |
121 |
+{ |
Lines 123-131
Link Here
|
123 |
+ /* Add checks for other CPUs here */ |
155 |
+ /* Add checks for other CPUs here */ |
124 |
+ else |
156 |
+ else |
125 |
+ return 1; |
157 |
+ return 1; |
|
|
158 |
+ return 0; |
126 |
+} |
159 |
+} |
127 |
+#endif |
160 |
+#endif |
128 |
+ |
161 |
|
129 |
+#ifdef __Linux__ |
162 |
+#ifdef __Linux__ |
130 |
static char *skipspace(char *s) |
163 |
static char *skipspace(char *s) |
131 |
{ |
164 |
{ |
Lines 135-143
Link Here
|
135 |
} |
168 |
} |
136 |
+#endif |
169 |
+#endif |
137 |
|
170 |
|
|
|
171 |
+#ifdef __Linux__ |
138 |
static char *skip_syslog(char *s) |
172 |
static char *skip_syslog(char *s) |
139 |
{ |
173 |
{ |
140 |
@@ -667,6 +748,7 @@ static int match_patterns(char *s, char |
174 |
char *p; |
|
|
175 |
@@ -571,7 +658,9 @@ static char *skip_syslog(char *s) |
176 |
return p + sizeof("mcelog: ") - 1; |
177 |
return s; |
178 |
} |
179 |
+#endif |
180 |
|
181 |
+#ifdef __Linux__ |
182 |
static char *skipgunk(char *s) |
183 |
{ |
184 |
s = skip_syslog(s); |
185 |
@@ -596,12 +685,16 @@ static char *skipgunk(char *s) |
186 |
|
187 |
return skipspace(s); |
188 |
} |
189 |
+#endif |
190 |
|
191 |
+#ifdef __Linux__ |
192 |
static inline int urange(unsigned val, unsigned lo, unsigned hi) |
193 |
{ |
194 |
return val >= lo && val <= hi; |
195 |
} |
196 |
+#endif |
197 |
|
198 |
+#ifdef __Linux__ |
199 |
static int is_short(char *name) |
200 |
{ |
201 |
return strlen(name) == 3 && |
202 |
@@ -609,7 +702,9 @@ static int is_short(char *name) |
203 |
islower(name[1]) && |
204 |
islower(name[2]); |
205 |
} |
206 |
+#endif |
207 |
|
208 |
+#ifdef __Linux__ |
209 |
static unsigned skip_date(char *s) |
210 |
{ |
211 |
unsigned day, hour, min, year, sec; |
212 |
@@ -626,6 +721,7 @@ static unsigned skip_date(char *s) |
213 |
return 0; |
214 |
return next; |
215 |
} |
216 |
+#endif |
217 |
|
218 |
static void dump_mce_final(struct mce *m, char *symbol, int missing, int recordlen, |
219 |
int dseen) |
220 |
@@ -646,6 +742,7 @@ static void dump_mce_final(struct mce *m |
221 |
flushlog(); |
222 |
} |
223 |
|
224 |
+#ifdef __Linux__ |
225 |
static char *skip_patterns[] = { |
226 |
"MCA:*", |
227 |
"MCi_MISC register valid*", |
228 |
@@ -654,7 +751,9 @@ static char *skip_patterns[] = { |
229 |
"Kernel does not support page offline interface", |
230 |
NULL |
231 |
}; |
232 |
+#endif |
233 |
|
234 |
+#ifdef __Linux__ |
235 |
static int match_patterns(char *s, char **pat) |
236 |
{ |
237 |
for (; *pat; pat++) |
238 |
@@ -662,12 +761,14 @@ static int match_patterns(char *s, char |
239 |
return 0; |
240 |
return 1; |
241 |
} |
242 |
+#endif |
243 |
|
244 |
#define FIELD(f) \ |
245 |
if (recordlen < endof_field(struct mce, f)) \ |
141 |
recordlen = endof_field(struct mce, f) |
246 |
recordlen = endof_field(struct mce, f) |
142 |
|
247 |
|
143 |
/* Decode ASCII input for fatal messages */ |
248 |
/* Decode ASCII input for fatal messages */ |
Lines 145-151
Link Here
|
145 |
static void decodefatal(FILE *inf) |
250 |
static void decodefatal(FILE *inf) |
146 |
{ |
251 |
{ |
147 |
struct mce m; |
252 |
struct mce m; |
148 |
@@ -877,6 +959,227 @@ restart: |
253 |
@@ -878,6 +979,227 @@ restart: |
149 |
if (data) |
254 |
if (data) |
150 |
dump_mce_final(&m, symbol, missing, recordlen, disclaimer_seen); |
255 |
dump_mce_final(&m, symbol, missing, recordlen, disclaimer_seen); |
151 |
} |
256 |
} |
Lines 373-379
Link Here
|
373 |
|
478 |
|
374 |
static void remove_pidfile(void) |
479 |
static void remove_pidfile(void) |
375 |
{ |
480 |
{ |
376 |
@@ -941,6 +1244,10 @@ void usage(void) |
481 |
@@ -943,6 +1265,10 @@ void usage(void) |
377 |
" mcelog [options] --ascii < log\n" |
482 |
" mcelog [options] --ascii < log\n" |
378 |
" mcelog [options] --ascii --file log\n" |
483 |
" mcelog [options] --ascii --file log\n" |
379 |
"Decode machine check ASCII output from kernel logs\n" |
484 |
"Decode machine check ASCII output from kernel logs\n" |
Lines 384-390
Link Here
|
384 |
"\n" |
489 |
"\n" |
385 |
"Options:\n" |
490 |
"Options:\n" |
386 |
"--version Show the version of mcelog and exit\n" |
491 |
"--version Show the version of mcelog and exit\n" |
387 |
@@ -1147,6 +1454,14 @@ static int modifier(int opt) |
492 |
@@ -1147,6 +1473,14 @@ static int modifier(int opt) |
388 |
case O_IS_CPU_SUPPORTED: |
493 |
case O_IS_CPU_SUPPORTED: |
389 |
check_only = 1; |
494 |
check_only = 1; |
390 |
break; |
495 |
break; |
Lines 399-405
Link Here
|
399 |
case 0: |
504 |
case 0: |
400 |
break; |
505 |
break; |
401 |
default: |
506 |
default: |
402 |
@@ -1197,10 +1512,12 @@ static int combined_modifier(int opt) |
507 |
@@ -1195,10 +1529,12 @@ static int combined_modifier(int opt) |
403 |
|
508 |
|
404 |
static void general_setup(void) |
509 |
static void general_setup(void) |
405 |
{ |
510 |
{ |
Lines 412-418
Link Here
|
412 |
config_cred("global", "run-credentials", &runcred); |
517 |
config_cred("global", "run-credentials", &runcred); |
413 |
if (config_bool("global", "filter-memory-errors") == 1) |
518 |
if (config_bool("global", "filter-memory-errors") == 1) |
414 |
filter_memory_errors = 1; |
519 |
filter_memory_errors = 1; |
415 |
@@ -1223,6 +1540,7 @@ static void drop_cred(void) |
520 |
@@ -1221,6 +1557,7 @@ static void drop_cred(void) |
416 |
} |
521 |
} |
417 |
} |
522 |
} |
418 |
|
523 |
|
Lines 420-426
Link Here
|
420 |
static void process(int fd, unsigned recordlen, unsigned loglen, char *buf) |
525 |
static void process(int fd, unsigned recordlen, unsigned loglen, char *buf) |
421 |
{ |
526 |
{ |
422 |
int i; |
527 |
int i; |
423 |
@@ -1275,6 +1593,173 @@ static void process(int fd, unsigned rec |
528 |
@@ -1273,6 +1610,173 @@ static void process(int fd, unsigned rec |
424 |
if (finish) |
529 |
if (finish) |
425 |
exit(0); |
530 |
exit(0); |
426 |
} |
531 |
} |
Lines 594-600
Link Here
|
594 |
|
699 |
|
595 |
static void noargs(int ac, char **av) |
700 |
static void noargs(int ac, char **av) |
596 |
{ |
701 |
{ |
597 |
@@ -1333,12 +1818,14 @@ struct mcefd_data { |
702 |
@@ -1331,12 +1835,14 @@ struct mcefd_data { |
598 |
char *buf; |
703 |
char *buf; |
599 |
}; |
704 |
}; |
600 |
|
705 |
|
Lines 609-615
Link Here
|
609 |
|
714 |
|
610 |
static void handle_sigusr1(int sig) |
715 |
static void handle_sigusr1(int sig) |
611 |
{ |
716 |
{ |
612 |
@@ -1347,13 +1834,18 @@ static void handle_sigusr1(int sig) |
717 |
@@ -1345,13 +1851,18 @@ static void handle_sigusr1(int sig) |
613 |
|
718 |
|
614 |
int main(int ac, char **av) |
719 |
int main(int ac, char **av) |
615 |
{ |
720 |
{ |
Lines 630-636
Link Here
|
630 |
if (opt == '?') { |
735 |
if (opt == '?') { |
631 |
usage(); |
736 |
usage(); |
632 |
} else if (combined_modifier(opt) > 0) { |
737 |
} else if (combined_modifier(opt) > 0) { |
633 |
@@ -1375,11 +1867,13 @@ int main(int ac, char **av) |
738 |
@@ -1371,11 +1882,13 @@ int main(int ac, char **av) |
634 |
} |
739 |
} |
635 |
|
740 |
|
636 |
/* before doing anything else let's see if the CPUs are supported */ |
741 |
/* before doing anything else let's see if the CPUs are supported */ |
Lines 644-650
Link Here
|
644 |
if (check_only) |
749 |
if (check_only) |
645 |
exit(0); |
750 |
exit(0); |
646 |
|
751 |
|
647 |
@@ -1398,13 +1892,21 @@ int main(int ac, char **av) |
752 |
@@ -1394,13 +1907,21 @@ int main(int ac, char **av) |
648 |
} |
753 |
} |
649 |
|
754 |
|
650 |
modifier_finish(); |
755 |
modifier_finish(); |
Lines 666-672
Link Here
|
666 |
fd = open(logfn, O_RDONLY); |
771 |
fd = open(logfn, O_RDONLY); |
667 |
if (fd < 0) { |
772 |
if (fd < 0) { |
668 |
if (ignore_nodev) |
773 |
if (ignore_nodev) |
669 |
@@ -1419,27 +1921,44 @@ int main(int ac, char **av) |
774 |
@@ -1415,27 +1936,44 @@ int main(int ac, char **av) |
670 |
err("MCE_GET_LOG_LEN"); |
775 |
err("MCE_GET_LOG_LEN"); |
671 |
|
776 |
|
672 |
d.buf = xalloc(d.recordlen * d.loglen); |
777 |
d.buf = xalloc(d.recordlen * d.loglen); |