diff --git a/CHANGELOG.md b/CHANGELOG.md index 69bdf41..caf9c49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Don't rely on /tmp or $TMPDIR in tests. - Fix misleading message in version check. +- Fix error message when opening missing trace directories ## [1.2.1] - 2022-07-25 diff --git a/src/emu/trace.c b/src/emu/trace.c index 113025c..74071d0 100644 --- a/src/emu/trace.c +++ b/src/emu/trace.c @@ -4,10 +4,12 @@ #define _XOPEN_SOURCE 500 #include "trace.h" +#include #include #include #include #include +#include #include "ovni.h" #include "path.h" #include "stream.h" @@ -125,6 +127,18 @@ trace_load(struct trace *trace, const char *tracedir) return -1; } + /* Try to open the directory to catch permission errors */ + DIR *dir = opendir(tracedir); + if (dir == NULL) { + err("cannot open \"%s\":", tracedir); + return -1; + } + + if (closedir(dir) != 0) { + err("closedir failed:"); + return -1; + } + /* Search recursively all streams in the trace directory */ if (nftw(tracedir, cb_nftw, 50, 0) != 0) { err("nftw failed");