Check the existence of raft dir.
b/28430346
Change-Id: I6ceb54f60c766d7b73ae93daa81f57b5a229e291
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index 1cd06e7..8e2e484 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -227,6 +227,13 @@
MYLOGD("raft_log_path is empty\n");
return;
}
+
+ struct stat s;
+ if (stat(RAFT_DIR, &s) != 0 || !S_ISDIR(s.st_mode)) {
+ MYLOGD("%s does not exist or is not a directory\n", RAFT_DIR);
+ return;
+ }
+
if (!zip_writer) {
// Write compressed and encoded raft logs to stdout if not zip_writer.
run_command("RAFT LOGS", 600, "logcompressor", "-r", RAFT_DIR, NULL);