atrace: use creat instead of truncate

Change-Id: Ie25c704f33c419c0c542249ae2841393862df0ab
This commit is contained in:
Jamie Gennis 2013-03-21 14:06:31 -07:00
parent aaebffd52f
commit 43122e7e67

View File

@ -176,13 +176,18 @@ static bool fileIsWritable(const char* filename) {
// Truncate a file. // Truncate a file.
static bool truncateFile(const char* path) static bool truncateFile(const char* path)
{ {
int err = truncate(path, 0); // This uses creat rather than truncate because some of the debug kernel
if (err != 0) { // 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, fprintf(stderr, "error truncating %s: %s (%d)\n", path,
strerror(errno), errno); strerror(errno), errno);
return false; return false;
} }
close(traceFD);
return true; return true;
} }