# HG changeset patch # User Nick Gasson # Date 1543222310 -28800 # Mon Nov 26 16:51:50 2018 +0800 # Node ID c9c6be25e9257939b9823d1764a98d80620e9de4 # Parent 7a16ce664d851d30bebb7c655323604893a0e466 8214077: test java/io/File/SetLastModified.java fails on ARM32 Summary: replace uses of stat with stat64 in java.base Reviewed-by: duke Contributed-by: nick.gasson@arm.com Jira: ENTLLT-1484 Change-Id: I7eb190fdc1f60db7cc13327eb2e9fe233063ffd1 diff --git a/src/java.base/linux/native/libjava/ProcessHandleImpl_linux.c b/src/java.base/linux/native/libjava/ProcessHandleImpl_linux.c --- a/src/java.base/linux/native/libjava/ProcessHandleImpl_linux.c +++ b/src/java.base/linux/native/libjava/ProcessHandleImpl_linux.c @@ -138,13 +138,13 @@ void os_getCmdlineAndUserInfo(JNIEnv *en char *args = NULL; jstring cmdexe = NULL; char fn[32]; - struct stat stat_buf; + struct stat64 stat_buf; /* * Stat /proc/ to get the user id */ snprintf(fn, sizeof fn, "/proc/%d", pid); - if (stat(fn, &stat_buf) == 0) { + if (stat64(fn, &stat_buf) == 0) { unix_getUserInfo(env, jinfo, stat_buf.st_uid); JNU_CHECK_EXCEPTION(env); } diff --git a/src/java.base/unix/native/libjava/TimeZone_md.c b/src/java.base/unix/native/libjava/TimeZone_md.c --- a/src/java.base/unix/native/libjava/TimeZone_md.c +++ b/src/java.base/unix/native/libjava/TimeZone_md.c @@ -56,6 +56,14 @@ #define fileclose fclose #endif +#if defined(_ALLBSD_SOURCE) + #ifndef MACOSX + #define stat64 stat + #define lstat64 lstat + #define fstat64 fstat + #endif +#endif + #if defined(__linux__) || defined(_ALLBSD_SOURCE) static const char *ETC_TIMEZONE_FILE = "/etc/timezone"; static const char *ZONEINFO_DIR = "/usr/share/zoneinfo"; @@ -115,7 +123,7 @@ static char * findZoneinfoFile(char *buf, size_t size, const char *dir) { DIR *dirp = NULL; - struct stat statbuf; + struct stat64 statbuf; struct dirent *dp = NULL; char *pathname = NULL; int fd = -1; @@ -156,7 +164,7 @@ findZoneinfoFile(char *buf, size_t size, if (pathname == NULL) { break; } - RESTARTABLE(stat(pathname, &statbuf), res); + RESTARTABLE(stat64(pathname, &statbuf), res); if (res == -1) { break; } @@ -219,7 +227,7 @@ findZoneinfoFile(char *buf, size_t size, static char * getPlatformTimeZoneID() { - struct stat statbuf; + struct stat64 statbuf; char *tz = NULL; FILE *fp; int fd; @@ -256,7 +264,7 @@ getPlatformTimeZoneID() /* * Next, try /etc/localtime to find the zone ID. */ - RESTARTABLE(lstat(DEFAULT_ZONEINFO_FILE, &statbuf), res); + RESTARTABLE(lstat64(DEFAULT_ZONEINFO_FILE, &statbuf), res); if (res == -1) { return NULL; } @@ -296,7 +304,7 @@ getPlatformTimeZoneID() return NULL; } - RESTARTABLE(fstat(fd, &statbuf), res); + RESTARTABLE(fstat64(fd, &statbuf), res); if (res == -1) { (void) close(fd); return NULL; @@ -557,7 +565,7 @@ cleanupScf(scf_handle_t *h, static char * getSolarisDefaultZoneID() { char *tz = NULL; - struct stat statbuf; + struct stat64 statbuf; size_t size; char *buf; int fd; @@ -597,7 +605,7 @@ getSolarisDefaultZoneID() { } cleanupScf(h, snap, inst, pg, prop, val, tz); - RESTARTABLE(stat(DEFAULT_ZONEINFO_FILE, &statbuf), res); + RESTARTABLE(stat64(DEFAULT_ZONEINFO_FILE, &statbuf), res); if (res == -1) { return NULL; } diff --git a/src/java.base/unix/native/libjava/UnixFileSystem_md.c b/src/java.base/unix/native/libjava/UnixFileSystem_md.c --- a/src/java.base/unix/native/libjava/UnixFileSystem_md.c +++ b/src/java.base/unix/native/libjava/UnixFileSystem_md.c @@ -69,6 +69,7 @@ #if defined(_ALLBSD_SOURCE) #ifndef MACOSX #define statvfs64 statvfs + #define stat64 stat #endif #endif @@ -121,8 +122,8 @@ Java_java_io_UnixFileSystem_canonicalize static jboolean statMode(const char *path, int *mode) { - struct stat sb; - if (stat(path, &sb) == 0) { + struct stat64 sb; + if (stat64(path, &sb) == 0) { *mode = sb.st_mode; return JNI_TRUE; } @@ -229,8 +230,8 @@ Java_java_io_UnixFileSystem_getLastModif jlong rv = 0; WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { - struct stat sb; - if (stat(path, &sb) == 0) { + struct stat64 sb; + if (stat64(path, &sb) == 0) { #if defined(_AIX) rv = (jlong)sb.st_mtime * 1000; rv += (jlong)sb.st_mtime_n / 1000000; @@ -254,8 +255,8 @@ Java_java_io_UnixFileSystem_getLength(JN jlong rv = 0; WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { - struct stat sb; - if (stat(path, &sb) == 0) { + struct stat64 sb; + if (stat64(path, &sb) == 0) { rv = sb.st_size; } } END_PLATFORM_STRING(env, path); @@ -408,9 +409,9 @@ Java_java_io_UnixFileSystem_setLastModif jboolean rv = JNI_FALSE; WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { - struct stat sb; + struct stat64 sb; - if (stat(path, &sb) == 0) { + if (stat64(path, &sb) == 0) { struct timeval tv[2]; /* Preserve access time */