diff options
author | Felipe Leme <felipeal@google.com> | 2016-10-21 11:38:26 -0700 |
---|---|---|
committer | Felipe Leme <felipeal@google.com> | 2016-10-21 11:46:40 -0700 |
commit | 03974984bf23a24ec81fa87764e567590da14608 (patch) | |
tree | 5a4de5a7c625d3b7a4361a150c01115ab0af3135 | |
parent | 1d3df546d5ee4dcc9e7cae6f8b8b790f741539af (diff) | |
download | native-03974984bf23a24ec81fa87764e567590da14608.tar.gz |
DO NOT MERGE. Added a is_zipping() function.
BUG: 32219165
Fixes: 32335112
Change-Id: I2bc630f9c840ccd3a2e0474ed16a766e8a405ad8
-rw-r--r-- | cmds/dumpstate/dumpstate.cpp | 24 | ||||
-rw-r--r-- | cmds/dumpstate/dumpstate.h | 3 |
2 files changed, 17 insertions, 10 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 0ff693375c..f5e67d0dff 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -152,7 +152,7 @@ void do_mountinfo(int pid, const char *name) { } void add_mountinfo() { - if (!zip_writer) return; + if (!is_zipping()) return; const char *title = "MOUNT INFO"; mount_points.clear(); DurationReporter duration_reporter(title, NULL); @@ -183,8 +183,8 @@ static void dump_dev_files(const char *title, const char *driverpath, const char } static void dump_systrace() { - if (!zip_writer) { - MYLOGD("Not dumping systrace because zip_writer is not set\n"); + if (!is_zipping()) { + MYLOGD("Not dumping systrace because dumpstate is not zipping\n"); return; } std::string systrace_path = bugreport_dir + "/systrace-" + suffix + ".txt"; @@ -240,7 +240,7 @@ static void dump_raft() { return; } - if (!zip_writer) { + if (!is_zipping()) { // Write compressed and encoded raft logs to stdout if not zip_writer. run_command("RAFT LOGS", 600, "logcompressor", "-r", RAFT_DIR, NULL); return; @@ -578,8 +578,8 @@ static const std::set<std::string> PROBLEMATIC_FILE_EXTENSIONS = { }; bool add_zip_entry_from_fd(const std::string& entry_name, int fd) { - if (!zip_writer) { - MYLOGD("Not adding zip entry %s from fd because zip_writer is not set\n", + if (!is_zipping()) { + MYLOGD("Not adding entry %s from fd because dumpstate is not zipping\n", entry_name.c_str()); return false; } @@ -648,8 +648,8 @@ static int _add_file_from_fd(const char *title, const char *path, int fd) { // TODO: move to util.cpp void add_dir(const char *dir, bool recursive) { - if (!zip_writer) { - MYLOGD("Not adding dir %s because zip_writer is not set\n", dir); + if (!is_zipping()) { + MYLOGD("Not adding dir %s because dumpstate is not zipping\n", dir); return; } MYLOGD("Adding dir %s (recursive: %d)\n", dir, recursive); @@ -657,10 +657,14 @@ void add_dir(const char *dir, bool recursive) { dump_files(NULL, dir, recursive ? skip_none : is_dir, _add_file_from_fd); } +bool is_zipping() { + return zip_writer != nullptr; +} + /* adds a text entry entry to the existing zip file. */ static bool add_text_zip_entry(const std::string& entry_name, const std::string& content) { - if (!zip_writer) { - MYLOGD("Not adding text zip entry %s because zip_writer is not set\n", entry_name.c_str()); + if (!is_zipping()) { + MYLOGD("Not adding text entry %s because dumpstate is not zipping\n", entry_name.c_str()); return false; } MYLOGD("Adding zip text entry %s\n", entry_name.c_str()); diff --git a/cmds/dumpstate/dumpstate.h b/cmds/dumpstate/dumpstate.h index 5e083cc002..514af59c17 100644 --- a/cmds/dumpstate/dumpstate.h +++ b/cmds/dumpstate/dumpstate.h @@ -87,6 +87,9 @@ extern std::string bugreport_dir; /* root dir for all files copied as-is into the bugreport. */ extern const std::string ZIP_ROOT_DIR; +/* Checkes whether dumpstate is generating a zipped bugreport. */ +bool is_zipping(); + /* adds a new entry to the existing zip file. */ bool add_zip_entry(const std::string& entry_name, const std::string& entry_path); |