aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2015-05-07 17:56:30 +0000
committerGravatar Han-Wen Nienhuys <hanwen@google.com>2015-05-08 16:59:11 +0000
commit73ad1482a1d99b9acd14f4545ff11671d87ec4e1 (patch)
tree0bba60358bfac8cc090c51400aed9cc609d9eabf /src/main
parentc4e2126935a4275e17ed002fd6f54d471ddddd84 (diff)
Switch to stat64/lstat64
Better fix for #174. -- MOS_MIGRATED_REVID=93045666
Diffstat (limited to 'src/main')
-rw-r--r--src/main/native/unix_jni.cc20
-rw-r--r--src/main/native/unix_jni.h6
-rw-r--r--src/main/native/unix_jni_darwin.cc10
-rw-r--r--src/main/native/unix_jni_linux.cc8
4 files changed, 22 insertions, 22 deletions
diff --git a/src/main/native/unix_jni.cc b/src/main/native/unix_jni.cc
index d5a47a97b1..aaf3115b0b 100644
--- a/src/main/native/unix_jni.cc
+++ b/src/main/native/unix_jni.cc
@@ -293,7 +293,7 @@ Java_com_google_devtools_build_lib_unix_FilesystemUtils_symlink(JNIEnv *env,
}
static jobject NewFileStatus(JNIEnv *env,
- const struct stat &stat_ref) {
+ const struct stat64 &stat_ref) {
static jclass file_status_class = NULL;
if (file_status_class == NULL) { // note: harmless race condition
jclass local = env->FindClass("com/google/devtools/build/lib/unix/FileStatus");
@@ -318,7 +318,7 @@ static jobject NewFileStatus(JNIEnv *env,
static jobject NewErrnoFileStatus(JNIEnv *env,
int saved_errno,
- const struct stat &stat_ref) {
+ const struct stat64 &stat_ref) {
static jclass errno_file_status_class = NULL;
if (errno_file_status_class == NULL) { // note: harmless race condition
jclass local = env->FindClass("com/google/devtools/build/lib/unix/ErrnoFileStatus");
@@ -347,7 +347,7 @@ static jobject NewErrnoFileStatus(JNIEnv *env,
StatSeconds(stat_ref, STAT_ATIME), StatNanoSeconds(stat_ref, STAT_ATIME),
StatSeconds(stat_ref, STAT_MTIME), StatNanoSeconds(stat_ref, STAT_MTIME),
StatSeconds(stat_ref, STAT_CTIME), StatNanoSeconds(stat_ref, STAT_CTIME),
- stat_ref.st_size, static_cast<int>(stat_ref.st_dev),
+ static_cast<jlong>(stat_ref.st_size), static_cast<int>(stat_ref.st_dev),
static_cast<jlong>(stat_ref.st_ino));
}
@@ -374,9 +374,9 @@ Java_com_google_devtools_build_lib_unix_ErrnoFileStatus_00024ErrnoConstants_init
static jobject StatCommon(JNIEnv *env,
jstring path,
- int (*stat_function)(const char *, struct stat *),
+ int (*stat_function)(const char *, struct stat64 *),
bool should_throw) {
- struct stat statbuf;
+ struct stat64 statbuf;
const char *path_chars = GetStringLatin1Chars(env, path);
int r;
int saved_errno = 0;
@@ -414,7 +414,7 @@ extern "C" JNIEXPORT jobject JNICALL
Java_com_google_devtools_build_lib_unix_FilesystemUtils_stat(JNIEnv *env,
jclass clazz,
jstring path) {
- return ::StatCommon(env, path, ::stat, true);
+ return ::StatCommon(env, path, ::stat64, true);
}
/*
@@ -427,7 +427,7 @@ extern "C" JNIEXPORT jobject JNICALL
Java_com_google_devtools_build_lib_unix_FilesystemUtils_lstat(JNIEnv *env,
jclass clazz,
jstring path) {
- return ::StatCommon(env, path, ::lstat, true);
+ return ::StatCommon(env, path, ::lstat64, true);
}
/*
@@ -439,7 +439,7 @@ extern "C" JNIEXPORT jobject JNICALL
Java_com_google_devtools_build_lib_unix_FilesystemUtils_errnoStat(JNIEnv *env,
jclass clazz,
jstring path) {
- return ::StatCommon(env, path, ::stat, false);
+ return ::StatCommon(env, path, ::stat64, false);
}
/*
@@ -451,7 +451,7 @@ extern "C" JNIEXPORT jobject JNICALL
Java_com_google_devtools_build_lib_unix_FilesystemUtils_errnoLstat(JNIEnv *env,
jclass clazz,
jstring path) {
- return ::StatCommon(env, path, ::lstat, false);
+ return ::StatCommon(env, path, ::lstat64, false);
}
/*
@@ -554,7 +554,7 @@ static char GetDirentType(struct dirent *entry,
}
FALLTHROUGH_INTENDED;
case DT_UNKNOWN:
- struct stat statbuf;
+ struct stat64 statbuf;
if (portable_fstatat(dirfd, entry->d_name, &statbuf, 0) == 0) {
if (S_ISREG(statbuf.st_mode)) return 'f';
if (S_ISDIR(statbuf.st_mode)) return 'd';
diff --git a/src/main/native/unix_jni.h b/src/main/native/unix_jni.h
index 4078119fcf..cc47853ab0 100644
--- a/src/main/native/unix_jni.h
+++ b/src/main/native/unix_jni.h
@@ -47,7 +47,7 @@ extern void PostFileException(JNIEnv *env, int error_number,
extern std::string ErrorMessage(int error_number);
// Runs fstatat(2), if available, or sets errno to ENOSYS if not.
-int portable_fstatat(int dirfd, char *name, struct stat *statbuf, int flags);
+int portable_fstatat(int dirfd, char *name, struct stat64 *statbuf, int flags);
// Encoding for different timestamps in a struct stat{}.
enum StatTimes {
@@ -57,10 +57,10 @@ enum StatTimes {
};
// Returns seconds from a stat buffer.
-int StatSeconds(const struct stat &statbuf, StatTimes t);
+int StatSeconds(const struct stat64 &statbuf, StatTimes t);
// Returns nanoseconds from a stat buffer.
-int StatNanoSeconds(const struct stat &statbuf, StatTimes t);
+int StatNanoSeconds(const struct stat64 &statbuf, StatTimes t);
// Runs getxattr(2), if available. If not, sets errno to ENOSYS.
ssize_t portable_getxattr(const char *path, const char *name, void *value,
diff --git a/src/main/native/unix_jni_darwin.cc b/src/main/native/unix_jni_darwin.cc
index 7e3c8e8f6a..b5269f4534 100644
--- a/src/main/native/unix_jni_darwin.cc
+++ b/src/main/native/unix_jni_darwin.cc
@@ -39,7 +39,7 @@ string ErrorMessage(int error_number) {
}
-int portable_fstatat(int dirfd, char *name, struct stat *statbuf, int flags) {
+int portable_fstatat(int dirfd, char *name, struct stat64 *statbuf, int flags) {
char dirPath[PATH_MAX2]; // Have enough room for relative path
// No fstatat under darwin, simulate it
@@ -50,7 +50,7 @@ int portable_fstatat(int dirfd, char *name, struct stat *statbuf, int flags) {
}
if (strlen(name) == 0 || name[0] == '/') {
// Absolute path, simply stat
- return stat(name, statbuf);
+ return stat64(name, statbuf);
}
// Relative path, construct an absolute path
if (fcntl(dirfd, F_GETPATH, dirPath) == -1) {
@@ -68,12 +68,12 @@ int portable_fstatat(int dirfd, char *name, struct stat *statbuf, int flags) {
if (newpath == NULL) {
return -1;
}
- int r = stat(newpath, statbuf);
+ int r = stat64(newpath, statbuf);
free(newpath);
return r;
}
-int StatSeconds(const struct stat &statbuf, StatTimes t) {
+int StatSeconds(const struct stat64 &statbuf, StatTimes t) {
switch (t) {
case STAT_ATIME:
return statbuf.st_atime;
@@ -86,7 +86,7 @@ int StatSeconds(const struct stat &statbuf, StatTimes t) {
}
}
-int StatNanoSeconds(const struct stat &statbuf, StatTimes t) {
+int StatNanoSeconds(const struct stat64 &statbuf, StatTimes t) {
switch (t) {
case STAT_ATIME:
return statbuf.st_atimespec.tv_nsec;
diff --git a/src/main/native/unix_jni_linux.cc b/src/main/native/unix_jni_linux.cc
index 8acc09fe27..439fe0277d 100644
--- a/src/main/native/unix_jni_linux.cc
+++ b/src/main/native/unix_jni_linux.cc
@@ -31,11 +31,11 @@ std::string ErrorMessage(int error_number) {
return std::string(strerror_r(error_number, buf, sizeof buf));
}
-int portable_fstatat(int dirfd, char *name, struct stat *statbuf, int flags) {
- return fstatat(dirfd, name, statbuf, flags);
+int portable_fstatat(int dirfd, char *name, struct stat64 *statbuf, int flags) {
+ return fstatat64(dirfd, name, statbuf, flags);
}
-int StatSeconds(const struct stat &statbuf, StatTimes t) {
+int StatSeconds(const struct stat64 &statbuf, StatTimes t) {
switch (t) {
case STAT_ATIME:
return statbuf.st_atim.tv_sec;
@@ -49,7 +49,7 @@ int StatSeconds(const struct stat &statbuf, StatTimes t) {
return 0;
}
-int StatNanoSeconds(const struct stat &statbuf, StatTimes t) {
+int StatNanoSeconds(const struct stat64 &statbuf, StatTimes t) {
switch (t) {
case STAT_ATIME:
return statbuf.st_atim.tv_nsec;