64 #include <string.h>
65
66 #define stat64 stat
67 #ifndef MACOSX
68 #define statvfs64 statvfs
69 #endif
70
71 #define open64 open
72 #define fstat64 fstat
73 #define lstat64 lstat
74 #define dirent64 dirent
75 #define readdir64_r readdir_r
76 #endif
77
78 #include "jni.h"
79 #include "jni_util.h"
80 #include "jlong.h"
81
82 #include "sun_nio_fs_UnixNativeDispatcher.h"
83
84 /**
85 * Size of password or group entry when not available via sysconf
86 */
87 #define ENT_BUF_SIZE 1024
88
89 #define RESTARTABLE(_cmd, _result) do { \
90 do { \
91 _result = _cmd; \
92 } while((_result == -1) && (errno == EINTR)); \
93 } while(0)
94
95 #define RESTARTABLE_RETURN_PTR(_cmd, _result) do { \
96 do { \
97 _result = _cmd; \
98 } while((_result == NULL) && (errno == EINTR)); \
99 } while(0)
100
101 static jfieldID attrs_st_mode;
102 static jfieldID attrs_st_ino;
103 static jfieldID attrs_st_dev;
247 entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B");
248 CHECK_NULL_RETURN(entry_fstype, 0);
249 entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B");
250 CHECK_NULL_RETURN(entry_options, 0);
251 entry_dev = (*env)->GetFieldID(env, clazz, "dev", "J");
252 CHECK_NULL_RETURN(entry_dev, 0);
253
254 /* system calls that might not be available at run time */
255
256 #if (defined(__solaris__) && defined(_LP64)) || defined(_ALLBSD_SOURCE)
257 /* Solaris 64-bit does not have openat64/fstatat64 */
258 my_openat64_func = (openat64_func*)dlsym(RTLD_DEFAULT, "openat");
259 my_fstatat64_func = (fstatat64_func*)dlsym(RTLD_DEFAULT, "fstatat");
260 #else
261 my_openat64_func = (openat64_func*) dlsym(RTLD_DEFAULT, "openat64");
262 my_fstatat64_func = (fstatat64_func*) dlsym(RTLD_DEFAULT, "fstatat64");
263 #endif
264 my_unlinkat_func = (unlinkat_func*) dlsym(RTLD_DEFAULT, "unlinkat");
265 my_renameat_func = (renameat_func*) dlsym(RTLD_DEFAULT, "renameat");
266 my_futimesat_func = (futimesat_func*) dlsym(RTLD_DEFAULT, "futimesat");
267 my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir");
268
269 #if defined(FSTATAT64_SYSCALL_AVAILABLE)
270 /* fstatat64 missing from glibc */
271 if (my_fstatat64_func == NULL)
272 my_fstatat64_func = (fstatat64_func*)&fstatat64_wrapper;
273 #endif
274
275 /* supports futimes or futimesat */
276
277 #ifdef _ALLBSD_SOURCE
278 capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMES;
279 #else
280 if (my_futimesat_func != NULL)
281 capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMES;
282 #endif
283
284 /* supports openat, etc. */
285
286 if (my_openat64_func != NULL && my_fstatat64_func != NULL &&
287 my_unlinkat_func != NULL && my_renameat_func != NULL &&
|
64 #include <string.h>
65
66 #define stat64 stat
67 #ifndef MACOSX
68 #define statvfs64 statvfs
69 #endif
70
71 #define open64 open
72 #define fstat64 fstat
73 #define lstat64 lstat
74 #define dirent64 dirent
75 #define readdir64_r readdir_r
76 #endif
77
78 #include "jni.h"
79 #include "jni_util.h"
80 #include "jlong.h"
81
82 #include "sun_nio_fs_UnixNativeDispatcher.h"
83
84 #if defined(_AIX)
85 #define DIR DIR64
86 #define opendir opendir64
87 #define closedir closedir64
88 #endif
89
90 /**
91 * Size of password or group entry when not available via sysconf
92 */
93 #define ENT_BUF_SIZE 1024
94
95 #define RESTARTABLE(_cmd, _result) do { \
96 do { \
97 _result = _cmd; \
98 } while((_result == -1) && (errno == EINTR)); \
99 } while(0)
100
101 #define RESTARTABLE_RETURN_PTR(_cmd, _result) do { \
102 do { \
103 _result = _cmd; \
104 } while((_result == NULL) && (errno == EINTR)); \
105 } while(0)
106
107 static jfieldID attrs_st_mode;
108 static jfieldID attrs_st_ino;
109 static jfieldID attrs_st_dev;
253 entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B");
254 CHECK_NULL_RETURN(entry_fstype, 0);
255 entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B");
256 CHECK_NULL_RETURN(entry_options, 0);
257 entry_dev = (*env)->GetFieldID(env, clazz, "dev", "J");
258 CHECK_NULL_RETURN(entry_dev, 0);
259
260 /* system calls that might not be available at run time */
261
262 #if (defined(__solaris__) && defined(_LP64)) || defined(_ALLBSD_SOURCE)
263 /* Solaris 64-bit does not have openat64/fstatat64 */
264 my_openat64_func = (openat64_func*)dlsym(RTLD_DEFAULT, "openat");
265 my_fstatat64_func = (fstatat64_func*)dlsym(RTLD_DEFAULT, "fstatat");
266 #else
267 my_openat64_func = (openat64_func*) dlsym(RTLD_DEFAULT, "openat64");
268 my_fstatat64_func = (fstatat64_func*) dlsym(RTLD_DEFAULT, "fstatat64");
269 #endif
270 my_unlinkat_func = (unlinkat_func*) dlsym(RTLD_DEFAULT, "unlinkat");
271 my_renameat_func = (renameat_func*) dlsym(RTLD_DEFAULT, "renameat");
272 my_futimesat_func = (futimesat_func*) dlsym(RTLD_DEFAULT, "futimesat");
273 #if defined(_AIX)
274 my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir64");
275 #else
276 my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir");
277 #endif
278
279 #if defined(FSTATAT64_SYSCALL_AVAILABLE)
280 /* fstatat64 missing from glibc */
281 if (my_fstatat64_func == NULL)
282 my_fstatat64_func = (fstatat64_func*)&fstatat64_wrapper;
283 #endif
284
285 /* supports futimes or futimesat */
286
287 #ifdef _ALLBSD_SOURCE
288 capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMES;
289 #else
290 if (my_futimesat_func != NULL)
291 capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMES;
292 #endif
293
294 /* supports openat, etc. */
295
296 if (my_openat64_func != NULL && my_fstatat64_func != NULL &&
297 my_unlinkat_func != NULL && my_renameat_func != NULL &&
|