From 2db0f5f31c015b5a89b619f8c95a9bf95c09c75b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= Date: Wed, 15 Oct 2014 18:08:37 -0700 Subject: [PATCH] dumpstate: Add trusty version if driver is found Change-Id: I7780ea8e1d777c222a73408f70d8a6d49dee1d92 --- cmds/dumpstate/dumpstate.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 1fbcef6cf..526374e02 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include @@ -75,6 +76,28 @@ static void get_tombstone_fds(tombstone_data_t data[NUM_TOMBSTONES]) { } } +static void dump_dev_files(const char *title, const char *driverpath, const char *filename) +{ + DIR *d; + struct dirent *de; + char path[PATH_MAX]; + + d = opendir(driverpath); + if (d == NULL) { + return; + } + + while ((de = readdir(d))) { + if (de->d_type != DT_LNK) { + continue; + } + snprintf(path, sizeof(path), "%s/%s/%s", driverpath, de->d_name, filename); + dump_file(title, path); + } + + closedir(d); +} + /* dumps the current system state to stdout */ static void dumpstate() { time_t now = time(NULL); @@ -107,6 +130,7 @@ static void dumpstate() { printf("Command line: %s\n", strtok(cmdline_buf, "\n")); printf("\n"); + dump_dev_files("TRUSTY VERSION", "/sys/bus/platform/drivers/trusty", "trusty_version"); run_command("UPTIME", 10, "uptime", NULL); dump_file("MEMORY INFO", "/proc/meminfo"); run_command("CPU INFO", 10, "top", "-n", "1", "-d", "1", "-m", "30", "-t", NULL);