aboutsummaryrefslogtreecommitdiffstats
path: root/executor/executor_linux.h
diff options
context:
space:
mode:
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>2020-08-13 22:29:19 +0900
committerDmitry Vyukov <dvyukov@google.com>2020-08-13 15:56:42 +0200
commit598f4936eb24a3835f35dfbf7840f0c7065634a8 (patch)
tree6d9931222646872b13816db579f251f9d46e6a2b /executor/executor_linux.h
parent60d836d3726332d1a13cf2e62806471ccbdb5e50 (diff)
executor/linux: dump more information when failed to open kcov file
With commit 50e21c6be6188f42 ("executor/linux: dump mount information when failed to open kcov file"), we got an unexpected result. /sys/kernel/ does not exist despite /sys/ exists. /proc/mounts cannot be opened despite /proc/ exists. If sysfs is not mounted on /sys/ and proc is not mounted on /proc/ , maybe other filesystems (e.g. devtmpfs, cgroup) are not mounted as well. Let's dump "/", "/proc/" and "/sys/", and then mount /proc/ and dump /proc/mounts .
Diffstat (limited to 'executor/executor_linux.h')
-rw-r--r--executor/executor_linux.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/executor/executor_linux.h b/executor/executor_linux.h
index e8105f65f..fce380561 100644
--- a/executor/executor_linux.h
+++ b/executor/executor_linux.h
@@ -91,11 +91,28 @@ static intptr_t execute_syscall(const call_t* c, intptr_t a[kMaxArgs])
return res;
}
+static void dump_dir(const char* path)
+{
+ DIR* dir = opendir(path);
+ struct dirent* d = NULL;
+ if (!dir)
+ return;
+ fprintf(stderr, "Index of %s\n", path);
+ while ((d = readdir(dir)) != NULL)
+ fprintf(stderr, " %s\n", d->d_name);
+ closedir(dir);
+}
+
static void cover_open(cover_t* cov, bool extra)
{
int fd = open("/sys/kernel/debug/kcov", O_RDWR);
if (fd == -1) {
const int err = errno;
+ dump_dir("/");
+ dump_dir("/proc/");
+ dump_dir("/sys/");
+ if (mount("/proc/", "/proc/", "proc", 0, NULL))
+ fprintf(stderr, "Can't mount proc on /proc/\n");
if (chdir("/sys/"))
fprintf(stderr, "/sys/ does not exist.\n");
else if (chdir("/sys/kernel/"))