diff options
Diffstat (limited to 'cmds/dumpstate/dumpstate.c')
-rw-r--r-- | cmds/dumpstate/dumpstate.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index dc1ada0..a33dcf3 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -64,7 +64,8 @@ static void get_tombstone_fds(tombstone_data_t data[NUM_TOMBSTONES]) { time_t thirty_minutes_ago = time(NULL) - 60*30; for (size_t i = 0; i < NUM_TOMBSTONES; i++) { snprintf(data[i].name, sizeof(data[i].name), "%s%02zu", TOMBSTONE_FILE_PREFIX, i); - int fd = open(data[i].name, O_RDONLY | O_CLOEXEC | O_NOFOLLOW); + int fd = TEMP_FAILURE_RETRY(open(data[i].name, + O_RDONLY | O_CLOEXEC | O_NOFOLLOW | O_NONBLOCK)); struct stat st; if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode) && (time_t) st.st_mtime >= thirty_minutes_ago) { @@ -184,7 +185,8 @@ static void dumpstate() { if (!anr_traces_path[0]) { printf("*** NO VM TRACES FILE DEFINED (dalvik.vm.stack-trace-file)\n\n"); } else { - int fd = open(anr_traces_path, O_RDONLY | O_CLOEXEC | O_NOFOLLOW); + int fd = TEMP_FAILURE_RETRY(open(anr_traces_path, + O_RDONLY | O_CLOEXEC | O_NOFOLLOW | O_NONBLOCK)); if (fd < 0) { printf("*** NO ANR VM TRACES FILE (%s): %s\n\n", anr_traces_path, strerror(errno)); } else { @@ -236,13 +238,15 @@ static void dumpstate() { dump_file("LAST KMSG", "/proc/last_kmsg"); } - dump_file("LAST PANIC CONSOLE", "/data/dontpanic/apanic_console"); - dump_file("LAST PANIC THREADS", "/data/dontpanic/apanic_threads"); + /* kernels must set CONFIG_PSTORE_PMSG, slice up pstore with device tree */ + run_command("LAST LOGCAT", 10, "logcat", "-L", "-v", "threadtime", + "-b", "all", "-d", "*:v", NULL); for_each_userid(do_dump_settings, NULL); /* The following have a tendency to get wedged when wifi drivers/fw goes belly-up. */ - run_command("NETWORK INTERFACES", 10, SU_PATH, "root", "netcfg", NULL); + + run_command("NETWORK INTERFACES", 10, "ip", "link", NULL); run_command("IPv4 ADDRESSES", 10, "ip", "-4", "addr", "show", NULL); run_command("IPv6 ADDRESSES", 10, "ip", "-6", "addr", "show", NULL); @@ -387,7 +391,6 @@ static void usage() { fprintf(stderr, "usage: dumpstate [-b soundfile] [-e soundfile] [-o file [-d] [-p] [-z]] [-s] [-q]\n" " -o: write to file (instead of stdout)\n" " -d: append date to filename (requires -o)\n" - " -z: gzip output (requires -o)\n" " -p: capture screenshot to filename.png (requires -o)\n" " -s: write output to control socket (for init)\n" " -b: play sound file instead of vibrate, at beginning of job\n" @@ -410,7 +413,6 @@ static void vibrate(FILE* vibrator, int ms) { int main(int argc, char *argv[]) { struct sigaction sigact; int do_add_date = 0; - int do_compress = 0; int do_vibrate = 1; char* use_outfile = 0; int use_socket = 0; @@ -435,7 +437,7 @@ int main(int argc, char *argv[]) { /* set as high priority, and protect from OOM killer */ setpriority(PRIO_PROCESS, 0, -20); - FILE *oom_adj = fopen("/proc/self/oom_adj", "w"); + FILE *oom_adj = fopen("/proc/self/oom_adj", "we"); if (oom_adj) { fputs("-17", oom_adj); fclose(oom_adj); @@ -450,7 +452,6 @@ int main(int argc, char *argv[]) { case 's': use_socket = 1; break; case 'v': break; // compatibility no-op case 'q': do_vibrate = 0; break; - case 'z': do_compress = 6; break; case 'p': do_fb = 1; break; case 'B': do_broadcast = 1; break; case '?': printf("\n"); @@ -469,15 +470,14 @@ int main(int argc, char *argv[]) { /* open the vibrator before dropping root */ FILE *vibrator = 0; if (do_vibrate) { - vibrator = fopen("/sys/class/timed_output/vibrator/enable", "w"); + vibrator = fopen("/sys/class/timed_output/vibrator/enable", "we"); if (vibrator) { - fcntl(fileno(vibrator), F_SETFD, FD_CLOEXEC); vibrate(vibrator, 150); } } /* read /proc/cmdline before dropping root */ - FILE *cmdline = fopen("/proc/cmdline", "r"); + FILE *cmdline = fopen("/proc/cmdline", "re"); if (cmdline != NULL) { fgets(cmdline_buf, sizeof(cmdline_buf), cmdline); fclose(cmdline); @@ -545,10 +545,9 @@ int main(int argc, char *argv[]) { strlcat(screenshot_path, ".png", sizeof(screenshot_path)); } strlcat(path, ".txt", sizeof(path)); - if (do_compress) strlcat(path, ".gz", sizeof(path)); strlcpy(tmp_path, path, sizeof(tmp_path)); strlcat(tmp_path, ".tmp", sizeof(tmp_path)); - gzip_pid = redirect_to_file(stdout, tmp_path, do_compress); + redirect_to_file(stdout, tmp_path); } dumpstate(); |