diff options
author | Jamie Gennis <jgennis@google.com> | 2013-03-21 14:06:31 -0700 |
---|---|---|
committer | Jamie Gennis <jgennis@google.com> | 2013-03-21 14:06:57 -0700 |
commit | 43122e7e672eb170334a4467dd41cf4bd545bae5 (patch) | |
tree | ee9729539016ea10a8a90436f5e50548b9481c3a /cmds/atrace | |
parent | aaebffd52f1bfa3d239bba0d60b699c01c6d791c (diff) | |
download | frameworks_native-43122e7e672eb170334a4467dd41cf4bd545bae5.zip frameworks_native-43122e7e672eb170334a4467dd41cf4bd545bae5.tar.gz frameworks_native-43122e7e672eb170334a4467dd41cf4bd545bae5.tar.bz2 |
atrace: use creat instead of truncate
Change-Id: Ie25c704f33c419c0c542249ae2841393862df0ab
Diffstat (limited to 'cmds/atrace')
-rw-r--r-- | cmds/atrace/atrace.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp index 29838e4..d85a1d7 100644 --- a/cmds/atrace/atrace.cpp +++ b/cmds/atrace/atrace.cpp @@ -176,13 +176,18 @@ static bool fileIsWritable(const char* filename) { // Truncate a file. static bool truncateFile(const char* path) { - int err = truncate(path, 0); - if (err != 0) { + // This uses creat rather than truncate because some of the debug kernel + // device nodes (e.g. k_ftraceFilterPath) currently aren't changed by + // calls to truncate, but they are cleared by calls to creat. + int traceFD = creat(path, 0); + if (traceFD == -1) { fprintf(stderr, "error truncating %s: %s (%d)\n", path, - strerror(errno), errno); + strerror(errno), errno); return false; } + close(traceFD); + return true; } |