aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorOliver O'Halloran <oohall@gmail.com>2021-06-25 11:49:20 +0530
committerVasant Hegde <hegdevasant@linux.vnet.ibm.com>2021-06-30 15:05:55 +0530
commitc3bd571748da7b83ed80bfbc59bd63395fe3e2b9 (patch)
treecdbb9f6b799077dc58fd88a25005cf2435c0d26c /external
parent0345237a3f9c88edd2dc1e433d6cc8dc0ee6a3fe (diff)
downloadskiboot-c3bd571748da7b83ed80bfbc59bd63395fe3e2b9.zip
skiboot-c3bd571748da7b83ed80bfbc59bd63395fe3e2b9.tar.gz
skiboot-c3bd571748da7b83ed80bfbc59bd63395fe3e2b9.tar.bz2
external/trace: Fall back to read()
Not all kernels support mmap() on an OPAL exported memory range. Fall back to allocating a buffer and using the normal file IO system calls to read the contents of the trace buffer in those cases. This does mean we can't use "follow" mode since we can't monitor the raw trace data effectively, but otherwise it works fine. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r--external/trace/dump_trace.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/external/trace/dump_trace.c b/external/trace/dump_trace.c
index aba684b..5a832c7 100644
--- a/external/trace/dump_trace.c
+++ b/external/trace/dump_trace.c
@@ -261,6 +261,7 @@ int main(int argc, char *argv[])
{
struct trace_reader *trs;
struct trace_info *ti;
+ bool no_mmap = false;
struct stat sb;
int fd, opt, i;
@@ -296,13 +297,26 @@ int main(int argc, char *argv[])
err(1, "Stating %s", argv[1]);
ti = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
- if (ti == MAP_FAILED)
- err(1, "Mmaping %s", argv[i]);
+ if (ti == MAP_FAILED) {
+ no_mmap = true;
+
+ ti = ezalloc(sb.st_size);
+ if (!ti)
+ err(1, "allocating memory for %s", argv[i]);
+
+ if (read(fd, ti, sb.st_size) == -1)
+ err(1, "reading from %s", argv[i]);
+ }
trs[i].tb = &ti->tb;
list_head_init(&trs[i].traces);
}
+ if (no_mmap) {
+ fprintf(stderr, "disabling follow mode: can't mmap() OPAL export files\n");
+ follow = 0;
+ }
+
do {
load_traces(trs, argc);
display_traces(trs, argc);