summaryrefslogtreecommitdiffstats
path: root/cmds/dumpstate
diff options
context:
space:
mode:
authorDan Egnor <egnor@google.com>2010-02-17 14:16:32 -0800
committerDan Egnor <egnor@google.com>2010-02-17 14:25:03 -0800
commit6a70d7d1e28bd0b98d03e7ecab3fd08ea5973e34 (patch)
treee76ae4ea5cea4d0559b115d51ca10e1fc308255a /cmds/dumpstate
parent1168baae849f03ad655bff74360b286b2f10b4a8 (diff)
downloadframeworks_base-6a70d7d1e28bd0b98d03e7ecab3fd08ea5973e34.zip
frameworks_base-6a70d7d1e28bd0b98d03e7ecab3fd08ea5973e34.tar.gz
frameworks_base-6a70d7d1e28bd0b98d03e7ecab3fd08ea5973e34.tar.bz2
Don't overwrite ANR traces.txt if it can't be renamed (usually
due to lack of permissions, usually due to an old adb running "dumpstate" directly rather than via bugreport).
Diffstat (limited to 'cmds/dumpstate')
-rw-r--r--cmds/dumpstate/utils.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmds/dumpstate/utils.c b/cmds/dumpstate/utils.c
index 39e14e4..6a79c6d 100644
--- a/cmds/dumpstate/utils.c
+++ b/cmds/dumpstate/utils.c
@@ -268,7 +268,10 @@ const char *dump_vm_traces() {
char anr_traces_path[PATH_MAX];
strlcpy(anr_traces_path, traces_path, sizeof(anr_traces_path));
strlcat(anr_traces_path, ".anr", sizeof(anr_traces_path));
- rename(traces_path, anr_traces_path);
+ if (rename(traces_path, anr_traces_path) && errno != ENOENT) {
+ fprintf(stderr, "rename(%s, %s): %s\n", traces_path, anr_traces_path, strerror(errno));
+ return NULL; // Can't rename old traces.txt -- no permission? -- leave it alone instead
+ }
/* create a new, empty traces.txt file to receive stack dumps */
int fd = open(traces_path, O_CREAT | O_WRONLY | O_TRUNC, 0666); /* -rw-rw-rw- */