Index: runtime/bin/file_android.cc |
diff --git a/runtime/bin/file_android.cc b/runtime/bin/file_android.cc |
index 54ad86a73303543bb2f4bdc62cb5267c466fa9a9..75d40026cfea8c76bf926d9fb86da22457a0a4ba 100644 |
--- a/runtime/bin/file_android.cc |
+++ b/runtime/bin/file_android.cc |
@@ -10,6 +10,7 @@ |
#include <errno.h> // NOLINT |
#include <fcntl.h> // NOLINT |
#include <sys/stat.h> // NOLINT |
+#include <sys/types.h> // NOLINT |
#include <unistd.h> // NOLINT |
#include <libgen.h> // NOLINT |
@@ -73,21 +74,21 @@ int64_t File::Write(const void* buffer, int64_t num_bytes) { |
} |
-off_t File::Position() { |
+off64_t File::Position() { |
ASSERT(handle_->fd() >= 0); |
- return TEMP_FAILURE_RETRY(lseek(handle_->fd(), 0, SEEK_CUR)); |
+ return lseek64(handle_->fd(), 0, SEEK_CUR); |
} |
-bool File::SetPosition(int64_t position) { |
+bool File::SetPosition(off64_t position) { |
ASSERT(handle_->fd() >= 0); |
- return TEMP_FAILURE_RETRY(lseek(handle_->fd(), position, SEEK_SET) != -1); |
+ return lseek64(handle_->fd(), position, SEEK_SET) >= 0; |
} |
-bool File::Truncate(int64_t length) { |
+bool File::Truncate(off64_t length) { |
ASSERT(handle_->fd() >= 0); |
- return TEMP_FAILURE_RETRY(ftruncate(handle_->fd(), length) != -1); |
+ return TEMP_FAILURE_RETRY(ftruncate64(handle_->fd(), length) != -1); |
zra
2013/11/19 16:10:17
This change is causing a build failure on Android.
Anders Johnsen
2013/11/19 16:23:40
Done.
|
} |
@@ -97,10 +98,10 @@ bool File::Flush() { |
} |
-off_t File::Length() { |
+off64_t File::Length() { |
ASSERT(handle_->fd() >= 0); |
- struct stat st; |
- if (TEMP_FAILURE_RETRY(fstat(handle_->fd(), &st)) == 0) { |
+ struct stat64 st; |
+ if (TEMP_FAILURE_RETRY(fstat64(handle_->fd(), &st)) == 0) { |
return st.st_size; |
} |
return -1; |
@@ -109,8 +110,8 @@ off_t File::Length() { |
File* File::Open(const char* name, FileOpenMode mode) { |
// Report errors for non-regular files. |
- struct stat st; |
- if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
+ struct stat64 st; |
+ if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) { |
if (!S_ISREG(st.st_mode)) { |
errno = (S_ISDIR(st.st_mode)) ? EISDIR : ENOENT; |
return NULL; |
@@ -124,12 +125,12 @@ File* File::Open(const char* name, FileOpenMode mode) { |
flags = flags | O_TRUNC; |
} |
flags |= O_CLOEXEC; |
- int fd = TEMP_FAILURE_RETRY(open(name, flags, 0666)); |
+ int fd = TEMP_FAILURE_RETRY(open64(name, flags, 0666)); |
zra
2013/11/19 16:10:17
This change is causing a build failure on Android.
Anders Johnsen
2013/11/19 16:23:40
Done.
|
if (fd < 0) { |
return NULL; |
} |
if (((mode & kWrite) != 0) && ((mode & kTruncate) == 0)) { |
- int position = TEMP_FAILURE_RETRY(lseek(fd, 0, SEEK_END)); |
+ off64_t position = lseek64(fd, 0, SEEK_END); |
if (position < 0) { |
return NULL; |
} |
@@ -145,8 +146,8 @@ File* File::OpenStdio(int fd) { |
bool File::Exists(const char* name) { |
- struct stat st; |
- if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
+ struct stat64 st; |
+ if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) { |
return S_ISREG(st.st_mode); |
} else { |
return false; |
@@ -155,7 +156,8 @@ bool File::Exists(const char* name) { |
bool File::Create(const char* name) { |
- int fd = TEMP_FAILURE_RETRY(open(name, O_RDONLY | O_CREAT | O_CLOEXEC, 0666)); |
+ int fd = TEMP_FAILURE_RETRY( |
+ open64(name, O_RDONLY | O_CREAT | O_CLOEXEC, 0666)); |
zra
2013/11/19 16:10:17
This change is causing a build failure on Android.
Anders Johnsen
2013/11/19 16:23:40
Done.
|
if (fd < 0) { |
return false; |
} |
@@ -218,9 +220,9 @@ bool File::RenameLink(const char* old_path, const char* new_path) { |
} |
-off_t File::LengthFromPath(const char* name) { |
- struct stat st; |
- if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
+off64_t File::LengthFromPath(const char* name) { |
+ struct stat64 st; |
+ if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) { |
return st.st_size; |
} |
return -1; |
@@ -228,8 +230,8 @@ off_t File::LengthFromPath(const char* name) { |
void File::Stat(const char* name, int64_t* data) { |
- struct stat st; |
- if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
+ struct stat64 st; |
+ if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) { |
if (S_ISREG(st.st_mode)) { |
data[kType] = kIsFile; |
} else if (S_ISDIR(st.st_mode)) { |
@@ -251,8 +253,8 @@ void File::Stat(const char* name, int64_t* data) { |
time_t File::LastModified(const char* name) { |
- struct stat st; |
- if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) { |
+ struct stat64 st; |
+ if (TEMP_FAILURE_RETRY(stat64(name, &st)) == 0) { |
return st.st_mtime; |
} |
return -1; |
@@ -260,8 +262,8 @@ time_t File::LastModified(const char* name) { |
char* File::LinkTarget(const char* pathname) { |
- struct stat link_stats; |
- if (lstat(pathname, &link_stats) != 0) return NULL; |
+ struct stat64 link_stats; |
+ if (lstat64(pathname, &link_stats) != 0) return NULL; |
if (!S_ISLNK(link_stats.st_mode)) { |
errno = ENOENT; |
return NULL; |
@@ -314,8 +316,8 @@ const char* File::StringEscapedPathSeparator() { |
File::StdioHandleType File::GetStdioHandleType(int fd) { |
ASSERT(0 <= fd && fd <= 2); |
- struct stat buf; |
- int result = fstat(fd, &buf); |
+ struct stat64 buf; |
+ int result = fstat64(fd, &buf); |
if (result == -1) { |
const int kBufferSize = 1024; |
char error_message[kBufferSize]; |
@@ -331,12 +333,12 @@ File::StdioHandleType File::GetStdioHandleType(int fd) { |
File::Type File::GetType(const char* pathname, bool follow_links) { |
- struct stat entry_info; |
+ struct stat64 entry_info; |
int stat_success; |
if (follow_links) { |
- stat_success = TEMP_FAILURE_RETRY(stat(pathname, &entry_info)); |
+ stat_success = TEMP_FAILURE_RETRY(stat64(pathname, &entry_info)); |
} else { |
- stat_success = TEMP_FAILURE_RETRY(lstat(pathname, &entry_info)); |
+ stat_success = TEMP_FAILURE_RETRY(lstat64(pathname, &entry_info)); |
} |
if (stat_success == -1) return File::kDoesNotExist; |
if (S_ISDIR(entry_info.st_mode)) return File::kIsDirectory; |
@@ -347,10 +349,10 @@ File::Type File::GetType(const char* pathname, bool follow_links) { |
File::Identical File::AreIdentical(const char* file_1, const char* file_2) { |
- struct stat file_1_info; |
- struct stat file_2_info; |
- if (TEMP_FAILURE_RETRY(lstat(file_1, &file_1_info)) == -1 || |
- TEMP_FAILURE_RETRY(lstat(file_2, &file_2_info)) == -1) { |
+ struct stat64 file_1_info; |
+ struct stat64 file_2_info; |
+ if (TEMP_FAILURE_RETRY(lstat64(file_1, &file_1_info)) == -1 || |
+ TEMP_FAILURE_RETRY(lstat64(file_2, &file_2_info)) == -1) { |
return File::kError; |
} |
return (file_1_info.st_ino == file_2_info.st_ino && |