diff options
author | Christopher Ferris <cferris@google.com> | 2015-02-10 16:53:52 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-02-10 16:53:52 +0000 |
commit | 34e32466466ad3f46697798c9f9644d62390c9b5 (patch) | |
tree | 49b4687c4869dac161323b934900b99b462f36b0 /cmds/dumpstate | |
parent | dac8c96955488346697570db3769a029704f71ac (diff) | |
parent | 8511b3ae5eb42810f97f7c3e993d7f80d3393b83 (diff) | |
download | frameworks_native-34e32466466ad3f46697798c9f9644d62390c9b5.zip frameworks_native-34e32466466ad3f46697798c9f9644d62390c9b5.tar.gz frameworks_native-34e32466466ad3f46697798c9f9644d62390c9b5.tar.bz2 |
am 8511b3ae: Merge "Remove -z option."
* commit '8511b3ae5eb42810f97f7c3e993d7f80d3393b83':
Remove -z option.
Diffstat (limited to 'cmds/dumpstate')
-rw-r--r-- | cmds/dumpstate/dumpstate.c | 6 | ||||
-rw-r--r-- | cmds/dumpstate/dumpstate.h | 4 | ||||
-rw-r--r-- | cmds/dumpstate/utils.c | 47 |
3 files changed, 8 insertions, 49 deletions
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 705a1d1..5d236d7 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -388,7 +388,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" @@ -411,7 +410,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; @@ -451,7 +449,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"); @@ -546,10 +543,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(); diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h index 53bfff6..2be340b 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -43,8 +43,8 @@ void print_properties(); /* redirect output to a service control socket */ void redirect_to_socket(FILE *redirect, const char *service); -/* redirect output to a file, optionally gzipping; returns gzip pid */ -pid_t redirect_to_file(FILE *redirect, char *path, int gzip_level); +/* redirect output to a file */ +void redirect_to_file(FILE *redirect, char *path); /* dump Dalvik and native stack traces, return the trace file location (NULL if none) */ const char *dump_traces(); diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c index 6beb5ed..7ad9cf0 100644 --- a/cmds/dumpstate/utils.c +++ b/cmds/dumpstate/utils.c @@ -476,8 +476,8 @@ void redirect_to_socket(FILE *redirect, const char *service) { close(fd); } -/* redirect output to a file, optionally gzipping; returns gzip pid (or -1) */ -pid_t redirect_to_file(FILE *redirect, char *path, int gzip_level) { +/* redirect output to a file */ +void redirect_to_file(FILE *redirect, char *path) { char *chp = path; /* skip initial slash */ @@ -494,52 +494,15 @@ pid_t redirect_to_file(FILE *redirect, char *path, int gzip_level) { } } - int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + int fd = TEMP_FAILURE_RETRY(open(path, O_WRONLY | O_CREAT | O_TRUNC, + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)); if (fd < 0) { fprintf(stderr, "%s: %s\n", path, strerror(errno)); exit(1); } - pid_t gzip_pid = -1; - if (gzip_level > 0) { - int fds[2]; - if (pipe(fds)) { - fprintf(stderr, "pipe: %s\n", strerror(errno)); - exit(1); - } - - fflush(redirect); - fflush(stdout); - - gzip_pid = fork(); - if (gzip_pid < 0) { - fprintf(stderr, "fork: %s\n", strerror(errno)); - exit(1); - } - - if (gzip_pid == 0) { - dup2(fds[0], STDIN_FILENO); - dup2(fd, STDOUT_FILENO); - - close(fd); - close(fds[0]); - close(fds[1]); - - char level[10]; - snprintf(level, sizeof(level), "-%d", gzip_level); - execlp("gzip", "gzip", level, NULL); - fprintf(stderr, "exec(gzip): %s\n", strerror(errno)); - _exit(-1); - } - - close(fd); - close(fds[0]); - fd = fds[1]; - } - - dup2(fd, fileno(redirect)); + TEMP_FAILURE_RETRY(dup2(fd, fileno(redirect))); close(fd); - return gzip_pid; } static bool should_dump_native_traces(const char* path) { |