Index: runtime/bin/file_linux.cc |
diff --git a/runtime/bin/file_linux.cc b/runtime/bin/file_linux.cc |
index 0a437f14874fac8435f87fbc11404439ff5390cf..ff801adf8fe7efe5e4443ea0868e38bb69d8bea1 100644 |
--- a/runtime/bin/file_linux.cc |
+++ b/runtime/bin/file_linux.cc |
@@ -157,8 +157,13 @@ File* File::Open(const char* name, FileOpenMode mode) { |
} |
int flags = O_RDONLY; |
if ((mode & kWrite) != 0) { |
+ ASSERT((mode & kWriteOnly) == 0); |
flags = (O_RDWR | O_CREAT); |
} |
+ if ((mode & kWriteOnly) != 0) { |
+ ASSERT((mode & kWrite) == 0); |
+ flags = (O_WRONLY | O_CREAT); |
+ } |
if ((mode & kTruncate) != 0) { |
flags = flags | O_TRUNC; |
} |
@@ -167,7 +172,8 @@ File* File::Open(const char* name, FileOpenMode mode) { |
if (fd < 0) { |
return NULL; |
} |
- if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) { |
+ if ((((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) || |
+ (((mode & kWriteOnly) != 0) && ((mode & kTruncate) == 0))) { |
int64_t position = NO_RETRY_EXPECTED(lseek64(fd, 0, SEEK_END)); |
if (position < 0) { |
return NULL; |