--- a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c Mon Jul 29 10:34:20 2019 -0400
+++ b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c Mon Jul 29 08:48:52 2019 -0700
@@ -143,6 +143,7 @@
typedef int unlinkat_func(int, const char*, int);
typedef int renameat_func(int, const char*, int, const char*);
typedef int futimesat_func(int, const char *, const struct timeval *);
+typedef int futimens_func(int, const struct timespec *);
typedef int lutimes_func(const char *, const struct timeval *);
typedef DIR* fdopendir_func(int);
@@ -151,6 +152,7 @@
static unlinkat_func* my_unlinkat_func = NULL;
static renameat_func* my_renameat_func = NULL;
static futimesat_func* my_futimesat_func = NULL;
+static futimens_func* my_futimens_func = NULL;
static lutimes_func* my_lutimes_func = NULL;
static fdopendir_func* my_fdopendir_func = NULL;
@@ -275,6 +277,7 @@
my_futimesat_func = (futimesat_func*) dlsym(RTLD_DEFAULT, "futimesat");
my_lutimes_func = (lutimes_func*) dlsym(RTLD_DEFAULT, "lutimes");
#endif
+ my_futimens_func = (futimens_func*) dlsym(RTLD_DEFAULT, "futimens");
#if defined(_AIX)
my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir64");
#else
@@ -287,7 +290,7 @@
my_fstatat64_func = (fstatat64_func*)&fstatat64_wrapper;
#endif
- /* supports futimes or futimesat and/or lutimes */
+ /* supports futimes or futimesat, futimens, and/or lutimes */
#ifdef _ALLBSD_SOURCE
capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMES;
@@ -298,6 +301,8 @@
if (my_lutimes_func != NULL)
capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_LUTIMES;
#endif
+ if (my_futimens_func != NULL)
+ capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMENS;
/* supports openat, etc. */
@@ -694,6 +699,29 @@
}
JNIEXPORT void JNICALL
+Java_sun_nio_fs_UnixNativeDispatcher_futimens(JNIEnv* env, jclass this, jint filedes,
+ jlong accessTime, jlong modificationTime)
+{
+ struct timespec times[2];
+ int err = 0;
+
+ times[0].tv_sec = accessTime / 1000000000;
+ times[0].tv_nsec = accessTime % 1000000000;
+
+ times[1].tv_sec = modificationTime / 1000000000;
+ times[1].tv_nsec = modificationTime % 1000000000;
+
+ if (my_futimens_func == NULL) {
+ JNU_ThrowInternalError(env, "my_futimens_func is NULL");
+ return;
+ }
+ RESTARTABLE((*my_futimens_func)(filedes, ×[0]), err);
+ if (err == -1) {
+ throwUnixException(env, errno);
+ }
+}
+
+JNIEXPORT void JNICALL
Java_sun_nio_fs_UnixNativeDispatcher_lutimes0(JNIEnv* env, jclass this,
jlong pathAddress, jlong accessTime, jlong modificationTime)
{