diff options
Diffstat (limited to 'cmds/dumpstate/utils.c')
-rw-r--r-- | cmds/dumpstate/utils.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c index da00846..5b8ed49 100644 --- a/cmds/dumpstate/utils.c +++ b/cmds/dumpstate/utils.c @@ -31,16 +31,20 @@ #include <sys/klog.h> #include <time.h> #include <unistd.h> +#include <sys/prctl.h> #include <cutils/debugger.h> #include <cutils/properties.h> #include <cutils/sockets.h> #include <private/android_filesystem_config.h> +#include <selinux/android.h> + #include "dumpstate.h" /* list of native processes to include in the native dumps */ static const char* native_processes_to_dump[] = { + "/system/bin/drmserver", "/system/bin/mediaserver", "/system/bin/sdcard", "/system/bin/surfaceflinger", @@ -108,7 +112,8 @@ out_close: void do_dmesg() { printf("------ KERNEL LOG (dmesg) ------\n"); - int size = klogctl(10, NULL, 0); /* Get size of kernel buffer */ + /* Get size of kernel buffer */ + int size = klogctl(KLOG_SIZE_BUFFER, NULL, 0); if (size <= 0) { printf("Unexpected klogctl return value: %d\n\n", size); return; @@ -197,6 +202,9 @@ int run_command(const char *title, int timeout_seconds, const char *command, ... const char *args[1024] = {command}; size_t arg; + /* make sure the child dies when dumpstate dies */ + prctl(PR_SET_PDEATHSIG, SIGKILL); + va_list ap; va_start(ap, command); if (title) printf("------ %s (%s", title, command); @@ -396,6 +404,9 @@ const char *dump_traces() { if (!mkdir(anr_traces_dir, 0775)) { chown(anr_traces_dir, AID_SYSTEM, AID_SYSTEM); chmod(anr_traces_dir, 0775); + if (selinux_android_restorecon(anr_traces_dir) == -1) { + fprintf(stderr, "restorecon failed for %s: %s\n", anr_traces_dir, strerror(errno)); + } } else if (errno != EEXIST) { fprintf(stderr, "mkdir(%s): %s\n", anr_traces_dir, strerror(errno)); return NULL; |