OSDN Git Service

dumpstate: use O_APPEND for anr file.
authorJosh Gao <jmgao@google.com>
Sat, 14 Jan 2017 06:09:40 +0000 (22:09 -0800)
committerJosh Gao <jmgao@google.com>
Tue, 17 Jan 2017 21:55:20 +0000 (13:55 -0800)
Bug: http://b/30705528
Test: ran dumpstate, grepped dmesg for new selinux denials
Change-Id: I28814edcf37a7edbde79279feff0e7def64316f2

cmds/dumpstate/utils.cpp

index 139231c..4ac5b67 100644 (file)
@@ -1021,8 +1021,10 @@ const char *dump_traces() {
     }
 
     /* create a new, empty traces.txt file to receive stack dumps */
-    int fd = TEMP_FAILURE_RETRY(open(traces_path, O_CREAT | O_WRONLY | O_TRUNC | O_NOFOLLOW | O_CLOEXEC,
-                                     0666));  /* -rw-rw-rw- */
+    int fd = TEMP_FAILURE_RETRY(
+        open(traces_path,
+             O_CREAT | O_WRONLY | O_APPEND | O_TRUNC | O_NOFOLLOW | O_CLOEXEC,
+             0666)); /* -rw-rw-rw- */
     if (fd < 0) {
         MYLOGE("%s: %s\n", traces_path, strerror(errno));
         return NULL;