提交 b4a1b7b2 编写于 作者: A alanb

6864319: (fs) Eliminate static dependency on fdopendir (lnx)

Reviewed-by: martin
上级 ce6b0326
...@@ -85,19 +85,21 @@ static jfieldID entry_options; ...@@ -85,19 +85,21 @@ static jfieldID entry_options;
static jfieldID entry_dev; static jfieldID entry_dev;
/** /**
* System calls that may not be available at build time. * System calls that may not be available at run time.
*/ */
typedef int openat64_func(int, const char *, int, ...); typedef int openat64_func(int, const char *, int, ...);
typedef int fstatat64_func(int, const char *, struct stat64 *, int); typedef int fstatat64_func(int, const char *, struct stat64 *, int);
typedef int unlinkat_func(int, const char*, int); typedef int unlinkat_func(int, const char*, int);
typedef int renameat_func(int, const char*, int, const char*); typedef int renameat_func(int, const char*, int, const char*);
typedef int futimesat_func(int, const char *, const struct timeval *); typedef int futimesat_func(int, const char *, const struct timeval *);
typedef DIR* fdopendir_func(int);
static openat64_func* my_openat64_func = NULL; static openat64_func* my_openat64_func = NULL;
static fstatat64_func* my_fstatat64_func = NULL; static fstatat64_func* my_fstatat64_func = NULL;
static unlinkat_func* my_unlinkat_func = NULL; static unlinkat_func* my_unlinkat_func = NULL;
static renameat_func* my_renameat_func = NULL; static renameat_func* my_renameat_func = NULL;
static futimesat_func* my_futimesat_func = NULL; static futimesat_func* my_futimesat_func = NULL;
static fdopendir_func* my_fdopendir_func = NULL;
/** /**
* fstatat missing from glibc on Linux. Temporary workaround * fstatat missing from glibc on Linux. Temporary workaround
...@@ -183,7 +185,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) ...@@ -183,7 +185,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this)
entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B"); entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B");
entry_dev = (*env)->GetFieldID(env, clazz, "dev", "J"); entry_dev = (*env)->GetFieldID(env, clazz, "dev", "J");
/* system calls that might not be available at build time */ /* system calls that might not be available at run time */
#if defined(__solaris__) && defined(_LP64) #if defined(__solaris__) && defined(_LP64)
/* Solaris 64-bit does not have openat64/fstatat64 */ /* Solaris 64-bit does not have openat64/fstatat64 */
...@@ -196,6 +198,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) ...@@ -196,6 +198,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this)
my_unlinkat_func = (unlinkat_func*) dlsym(RTLD_DEFAULT, "unlinkat"); my_unlinkat_func = (unlinkat_func*) dlsym(RTLD_DEFAULT, "unlinkat");
my_renameat_func = (renameat_func*) dlsym(RTLD_DEFAULT, "renameat"); my_renameat_func = (renameat_func*) dlsym(RTLD_DEFAULT, "renameat");
my_futimesat_func = (futimesat_func*) dlsym(RTLD_DEFAULT, "futimesat"); my_futimesat_func = (futimesat_func*) dlsym(RTLD_DEFAULT, "futimesat");
my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir");
#if defined(FSTATAT64_SYSCALL_AVAILABLE) #if defined(FSTATAT64_SYSCALL_AVAILABLE)
/* fstatat64 missing from glibc */ /* fstatat64 missing from glibc */
...@@ -205,7 +208,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) ...@@ -205,7 +208,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this)
if (my_openat64_func != NULL && my_fstatat64_func != NULL && if (my_openat64_func != NULL && my_fstatat64_func != NULL &&
my_unlinkat_func != NULL && my_renameat_func != NULL && my_unlinkat_func != NULL && my_renameat_func != NULL &&
my_futimesat_func != NULL) my_futimesat_func != NULL && my_fdopendir_func != NULL)
{ {
flags |= sun_nio_fs_UnixNativeDispatcher_HAS_AT_SYSCALLS; flags |= sun_nio_fs_UnixNativeDispatcher_HAS_AT_SYSCALLS;
} }
...@@ -565,8 +568,13 @@ JNIEXPORT jlong JNICALL ...@@ -565,8 +568,13 @@ JNIEXPORT jlong JNICALL
Java_sun_nio_fs_UnixNativeDispatcher_fdopendir(JNIEnv* env, jclass this, int dfd) { Java_sun_nio_fs_UnixNativeDispatcher_fdopendir(JNIEnv* env, jclass this, int dfd) {
DIR* dir; DIR* dir;
if (my_fdopendir_func == NULL) {
JNU_ThrowInternalError(env, "should not reach here");
return (jlong)-1;
}
/* EINTR not listed as a possible error */ /* EINTR not listed as a possible error */
dir = fdopendir((int)dfd); dir = (*my_fdopendir_func)((int)dfd);
if (dir == NULL) { if (dir == NULL) {
throwUnixException(env, errno); throwUnixException(env, errno);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册