author | bpb |
Mon, 29 Jul 2019 08:48:52 -0700 | |
changeset 57568 | 460ac76019f4 |
parent 54692 | 22866513a80e |
child 58397 | 2d40e6a7ce8e |
permissions | -rw-r--r-- |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1 |
/* |
54692
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
2 |
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
4 |
* |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
10 |
* |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
15 |
* accompanied this code). |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
16 |
* |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
20 |
* |
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
24 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
25 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
26 |
#include <stdio.h> |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
27 |
#include <stdlib.h> |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
28 |
#include <limits.h> |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
29 |
#include <fcntl.h> |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
30 |
#include <dirent.h> |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
31 |
#include <unistd.h> |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
32 |
#include <errno.h> |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
33 |
#include <dlfcn.h> |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
34 |
#include <sys/types.h> |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
35 |
#include <sys/stat.h> |
31145
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
36 |
#ifdef MACOSX |
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
37 |
#include <sys/param.h> |
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
38 |
#include <sys/mount.h> |
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
39 |
#else |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
40 |
#include <sys/statvfs.h> |
31145
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
41 |
#endif |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
42 |
#include <sys/time.h> |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
43 |
|
40182
1e16a8fd76ba
8160997: Solaris: deprecated <pwd.h> and <gid.h> interfaces should be replaced
dcubed
parents:
37346
diff
changeset
|
44 |
/* For POSIX-compliant getpwuid_r, getgrgid_r on Solaris */ |
1e16a8fd76ba
8160997: Solaris: deprecated <pwd.h> and <gid.h> interfaces should be replaced
dcubed
parents:
37346
diff
changeset
|
45 |
#if defined(__solaris__) |
1e16a8fd76ba
8160997: Solaris: deprecated <pwd.h> and <gid.h> interfaces should be replaced
dcubed
parents:
37346
diff
changeset
|
46 |
#define _POSIX_PTHREAD_SEMANTICS |
1e16a8fd76ba
8160997: Solaris: deprecated <pwd.h> and <gid.h> interfaces should be replaced
dcubed
parents:
37346
diff
changeset
|
47 |
#endif |
1e16a8fd76ba
8160997: Solaris: deprecated <pwd.h> and <gid.h> interfaces should be replaced
dcubed
parents:
37346
diff
changeset
|
48 |
#include <pwd.h> |
1e16a8fd76ba
8160997: Solaris: deprecated <pwd.h> and <gid.h> interfaces should be replaced
dcubed
parents:
37346
diff
changeset
|
49 |
#include <grp.h> |
1e16a8fd76ba
8160997: Solaris: deprecated <pwd.h> and <gid.h> interfaces should be replaced
dcubed
parents:
37346
diff
changeset
|
50 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
51 |
#ifdef __solaris__ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
52 |
#include <strings.h> |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
53 |
#endif |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
54 |
|
40800
bd4117559e3f
8165643: SecureDirectoryStream doesn't work on linux non-x86
martin
parents:
40182
diff
changeset
|
55 |
#ifdef __linux__ |
bd4117559e3f
8165643: SecureDirectoryStream doesn't work on linux non-x86
martin
parents:
40182
diff
changeset
|
56 |
#include <sys/syscall.h> |
bd4117559e3f
8165643: SecureDirectoryStream doesn't work on linux non-x86
martin
parents:
40182
diff
changeset
|
57 |
#endif |
bd4117559e3f
8165643: SecureDirectoryStream doesn't work on linux non-x86
martin
parents:
40182
diff
changeset
|
58 |
|
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
59 |
#if defined(__linux__) || defined(_AIX) |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
60 |
#include <string.h> |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
61 |
#endif |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
62 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
63 |
#ifdef _ALLBSD_SOURCE |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
64 |
#include <string.h> |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
65 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
66 |
#define stat64 stat |
31145
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
67 |
#ifndef MACOSX |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
68 |
#define statvfs64 statvfs |
31145
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
69 |
#endif |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
70 |
|
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
71 |
#define open64 open |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
72 |
#define fstat64 fstat |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
73 |
#define lstat64 lstat |
51102
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
74 |
#define readdir64 readdir |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
75 |
#endif |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
76 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
77 |
#include "jni.h" |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
78 |
#include "jni_util.h" |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
79 |
#include "jlong.h" |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
80 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
81 |
#include "sun_nio_fs_UnixNativeDispatcher.h" |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
82 |
|
42944 | 83 |
#if defined(_AIX) |
84 |
#define DIR DIR64 |
|
51597
4c78f4fd8370
8207744: Clean up inconsistent use of opendir/closedir versus opendir64/closedir64
bpb
parents:
51309
diff
changeset
|
85 |
#define dirent dirent64 |
42944 | 86 |
#define opendir opendir64 |
51597
4c78f4fd8370
8207744: Clean up inconsistent use of opendir/closedir versus opendir64/closedir64
bpb
parents:
51309
diff
changeset
|
87 |
#define readdir readdir64 |
42944 | 88 |
#define closedir closedir64 |
89 |
#endif |
|
90 |
||
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
91 |
/** |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
92 |
* Size of password or group entry when not available via sysconf |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
93 |
*/ |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
94 |
#define ENT_BUF_SIZE 1024 |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
95 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
96 |
#define RESTARTABLE(_cmd, _result) do { \ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
97 |
do { \ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
98 |
_result = _cmd; \ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
99 |
} while((_result == -1) && (errno == EINTR)); \ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
100 |
} while(0) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
101 |
|
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
102 |
#define RESTARTABLE_RETURN_PTR(_cmd, _result) do { \ |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
103 |
do { \ |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
104 |
_result = _cmd; \ |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
105 |
} while((_result == NULL) && (errno == EINTR)); \ |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
106 |
} while(0) |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
107 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
108 |
static jfieldID attrs_st_mode; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
109 |
static jfieldID attrs_st_ino; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
110 |
static jfieldID attrs_st_dev; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
111 |
static jfieldID attrs_st_rdev; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
112 |
static jfieldID attrs_st_nlink; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
113 |
static jfieldID attrs_st_uid; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
114 |
static jfieldID attrs_st_gid; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
115 |
static jfieldID attrs_st_size; |
15275
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
116 |
static jfieldID attrs_st_atime_sec; |
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
117 |
static jfieldID attrs_st_atime_nsec; |
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
118 |
static jfieldID attrs_st_mtime_sec; |
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
119 |
static jfieldID attrs_st_mtime_nsec; |
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
120 |
static jfieldID attrs_st_ctime_sec; |
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
121 |
static jfieldID attrs_st_ctime_nsec; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
122 |
|
17154
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
123 |
#ifdef _DARWIN_FEATURE_64_BIT_INODE |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
124 |
static jfieldID attrs_st_birthtime_sec; |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
125 |
#endif |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
126 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
127 |
static jfieldID attrs_f_frsize; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
128 |
static jfieldID attrs_f_blocks; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
129 |
static jfieldID attrs_f_bfree; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
130 |
static jfieldID attrs_f_bavail; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
131 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
132 |
static jfieldID entry_name; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
133 |
static jfieldID entry_dir; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
134 |
static jfieldID entry_fstype; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
135 |
static jfieldID entry_options; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
136 |
static jfieldID entry_dev; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
137 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
138 |
/** |
3328
c7e12ed68f87
6864319: (fs) Eliminate static dependency on fdopendir (lnx)
alanb
parents:
3065
diff
changeset
|
139 |
* System calls that may not be available at run time. |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
140 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
141 |
typedef int openat64_func(int, const char *, int, ...); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
142 |
typedef int fstatat64_func(int, const char *, struct stat64 *, int); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
143 |
typedef int unlinkat_func(int, const char*, int); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
144 |
typedef int renameat_func(int, const char*, int, const char*); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
145 |
typedef int futimesat_func(int, const char *, const struct timeval *); |
57568
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
146 |
typedef int futimens_func(int, const struct timespec *); |
54692
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
147 |
typedef int lutimes_func(const char *, const struct timeval *); |
3328
c7e12ed68f87
6864319: (fs) Eliminate static dependency on fdopendir (lnx)
alanb
parents:
3065
diff
changeset
|
148 |
typedef DIR* fdopendir_func(int); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
149 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
150 |
static openat64_func* my_openat64_func = NULL; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
151 |
static fstatat64_func* my_fstatat64_func = NULL; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
152 |
static unlinkat_func* my_unlinkat_func = NULL; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
153 |
static renameat_func* my_renameat_func = NULL; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
154 |
static futimesat_func* my_futimesat_func = NULL; |
57568
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
155 |
static futimens_func* my_futimens_func = NULL; |
54692
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
156 |
static lutimes_func* my_lutimes_func = NULL; |
3328
c7e12ed68f87
6864319: (fs) Eliminate static dependency on fdopendir (lnx)
alanb
parents:
3065
diff
changeset
|
157 |
static fdopendir_func* my_fdopendir_func = NULL; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
158 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
159 |
/** |
52641
09a3f379b927
8214078: (fs) SecureDirectoryStream not supported on arm32
alanb
parents:
51597
diff
changeset
|
160 |
* fstatat missing from glibc on Linux. |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
161 |
*/ |
52641
09a3f379b927
8214078: (fs) SecureDirectoryStream not supported on arm32
alanb
parents:
51597
diff
changeset
|
162 |
#if defined(__linux__) && (defined(__i386) || defined(__arm__)) |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
163 |
#define FSTATAT64_SYSCALL_AVAILABLE |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
164 |
static int fstatat64_wrapper(int dfd, const char *path, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
165 |
struct stat64 *statbuf, int flag) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
166 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
167 |
#ifndef __NR_fstatat64 |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
168 |
#define __NR_fstatat64 300 |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
169 |
#endif |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
170 |
return syscall(__NR_fstatat64, dfd, path, statbuf, flag); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
171 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
172 |
#endif |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
173 |
|
40800
bd4117559e3f
8165643: SecureDirectoryStream doesn't work on linux non-x86
martin
parents:
40182
diff
changeset
|
174 |
#if defined(__linux__) && defined(_LP64) && defined(__NR_newfstatat) |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
175 |
#define FSTATAT64_SYSCALL_AVAILABLE |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
176 |
static int fstatat64_wrapper(int dfd, const char *path, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
177 |
struct stat64 *statbuf, int flag) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
178 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
179 |
return syscall(__NR_newfstatat, dfd, path, statbuf, flag); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
180 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
181 |
#endif |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
182 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
183 |
/** |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
184 |
* Call this to throw an internal UnixException when a system/library |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
185 |
* call fails |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
186 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
187 |
static void throwUnixException(JNIEnv* env, int errnum) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
188 |
jobject x = JNU_NewObjectByName(env, "sun/nio/fs/UnixException", |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
189 |
"(I)V", errnum); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
190 |
if (x != NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
191 |
(*env)->Throw(env, x); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
192 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
193 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
194 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
195 |
/** |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
196 |
* Initialization |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
197 |
*/ |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
198 |
JNIEXPORT jint JNICALL |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
199 |
Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
200 |
{ |
17154
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
201 |
jint capabilities = 0; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
202 |
jclass clazz; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
203 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
204 |
clazz = (*env)->FindClass(env, "sun/nio/fs/UnixFileAttributes"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
205 |
CHECK_NULL_RETURN(clazz, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
206 |
attrs_st_mode = (*env)->GetFieldID(env, clazz, "st_mode", "I"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
207 |
CHECK_NULL_RETURN(attrs_st_mode, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
208 |
attrs_st_ino = (*env)->GetFieldID(env, clazz, "st_ino", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
209 |
CHECK_NULL_RETURN(attrs_st_ino, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
210 |
attrs_st_dev = (*env)->GetFieldID(env, clazz, "st_dev", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
211 |
CHECK_NULL_RETURN(attrs_st_dev, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
212 |
attrs_st_rdev = (*env)->GetFieldID(env, clazz, "st_rdev", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
213 |
CHECK_NULL_RETURN(attrs_st_rdev, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
214 |
attrs_st_nlink = (*env)->GetFieldID(env, clazz, "st_nlink", "I"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
215 |
CHECK_NULL_RETURN(attrs_st_nlink, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
216 |
attrs_st_uid = (*env)->GetFieldID(env, clazz, "st_uid", "I"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
217 |
CHECK_NULL_RETURN(attrs_st_uid, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
218 |
attrs_st_gid = (*env)->GetFieldID(env, clazz, "st_gid", "I"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
219 |
CHECK_NULL_RETURN(attrs_st_gid, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
220 |
attrs_st_size = (*env)->GetFieldID(env, clazz, "st_size", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
221 |
CHECK_NULL_RETURN(attrs_st_size, 0); |
15275
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
222 |
attrs_st_atime_sec = (*env)->GetFieldID(env, clazz, "st_atime_sec", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
223 |
CHECK_NULL_RETURN(attrs_st_atime_sec, 0); |
15275
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
224 |
attrs_st_atime_nsec = (*env)->GetFieldID(env, clazz, "st_atime_nsec", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
225 |
CHECK_NULL_RETURN(attrs_st_atime_nsec, 0); |
15275
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
226 |
attrs_st_mtime_sec = (*env)->GetFieldID(env, clazz, "st_mtime_sec", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
227 |
CHECK_NULL_RETURN(attrs_st_mtime_sec, 0); |
15275
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
228 |
attrs_st_mtime_nsec = (*env)->GetFieldID(env, clazz, "st_mtime_nsec", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
229 |
CHECK_NULL_RETURN(attrs_st_mtime_nsec, 0); |
15275
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
230 |
attrs_st_ctime_sec = (*env)->GetFieldID(env, clazz, "st_ctime_sec", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
231 |
CHECK_NULL_RETURN(attrs_st_ctime_sec, 0); |
15275
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
232 |
attrs_st_ctime_nsec = (*env)->GetFieldID(env, clazz, "st_ctime_nsec", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
233 |
CHECK_NULL_RETURN(attrs_st_ctime_nsec, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
234 |
|
17154
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
235 |
#ifdef _DARWIN_FEATURE_64_BIT_INODE |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
236 |
attrs_st_birthtime_sec = (*env)->GetFieldID(env, clazz, "st_birthtime_sec", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
237 |
CHECK_NULL_RETURN(attrs_st_birthtime_sec, 0); |
17154
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
238 |
#endif |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
239 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
240 |
clazz = (*env)->FindClass(env, "sun/nio/fs/UnixFileStoreAttributes"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
241 |
CHECK_NULL_RETURN(clazz, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
242 |
attrs_f_frsize = (*env)->GetFieldID(env, clazz, "f_frsize", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
243 |
CHECK_NULL_RETURN(attrs_f_frsize, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
244 |
attrs_f_blocks = (*env)->GetFieldID(env, clazz, "f_blocks", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
245 |
CHECK_NULL_RETURN(attrs_f_blocks, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
246 |
attrs_f_bfree = (*env)->GetFieldID(env, clazz, "f_bfree", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
247 |
CHECK_NULL_RETURN(attrs_f_bfree, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
248 |
attrs_f_bavail = (*env)->GetFieldID(env, clazz, "f_bavail", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
249 |
CHECK_NULL_RETURN(attrs_f_bavail, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
250 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
251 |
clazz = (*env)->FindClass(env, "sun/nio/fs/UnixMountEntry"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
252 |
CHECK_NULL_RETURN(clazz, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
253 |
entry_name = (*env)->GetFieldID(env, clazz, "name", "[B"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
254 |
CHECK_NULL_RETURN(entry_name, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
255 |
entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
256 |
CHECK_NULL_RETURN(entry_dir, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
257 |
entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
258 |
CHECK_NULL_RETURN(entry_fstype, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
259 |
entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
260 |
CHECK_NULL_RETURN(entry_options, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
261 |
entry_dev = (*env)->GetFieldID(env, clazz, "dev", "J"); |
22631
ac85b05a53f4
8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons
alanb
parents:
22597
diff
changeset
|
262 |
CHECK_NULL_RETURN(entry_dev, 0); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
263 |
|
3328
c7e12ed68f87
6864319: (fs) Eliminate static dependency on fdopendir (lnx)
alanb
parents:
3065
diff
changeset
|
264 |
/* system calls that might not be available at run time */ |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
265 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
266 |
#if (defined(__solaris__) && defined(_LP64)) || defined(_ALLBSD_SOURCE) |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
267 |
/* Solaris 64-bit does not have openat64/fstatat64 */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
268 |
my_openat64_func = (openat64_func*)dlsym(RTLD_DEFAULT, "openat"); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
269 |
my_fstatat64_func = (fstatat64_func*)dlsym(RTLD_DEFAULT, "fstatat"); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
270 |
#else |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
271 |
my_openat64_func = (openat64_func*) dlsym(RTLD_DEFAULT, "openat64"); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
272 |
my_fstatat64_func = (fstatat64_func*) dlsym(RTLD_DEFAULT, "fstatat64"); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
273 |
#endif |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
274 |
my_unlinkat_func = (unlinkat_func*) dlsym(RTLD_DEFAULT, "unlinkat"); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
275 |
my_renameat_func = (renameat_func*) dlsym(RTLD_DEFAULT, "renameat"); |
54692
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
276 |
#ifndef _ALLBSD_SOURCE |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
277 |
my_futimesat_func = (futimesat_func*) dlsym(RTLD_DEFAULT, "futimesat"); |
54692
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
278 |
my_lutimes_func = (lutimes_func*) dlsym(RTLD_DEFAULT, "lutimes"); |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
279 |
#endif |
57568
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
280 |
my_futimens_func = (futimens_func*) dlsym(RTLD_DEFAULT, "futimens"); |
42944 | 281 |
#if defined(_AIX) |
282 |
my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir64"); |
|
283 |
#else |
|
3328
c7e12ed68f87
6864319: (fs) Eliminate static dependency on fdopendir (lnx)
alanb
parents:
3065
diff
changeset
|
284 |
my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir"); |
42944 | 285 |
#endif |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
286 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
287 |
#if defined(FSTATAT64_SYSCALL_AVAILABLE) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
288 |
/* fstatat64 missing from glibc */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
289 |
if (my_fstatat64_func == NULL) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
290 |
my_fstatat64_func = (fstatat64_func*)&fstatat64_wrapper; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
291 |
#endif |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
292 |
|
57568
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
293 |
/* supports futimes or futimesat, futimens, and/or lutimes */ |
17154
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
294 |
|
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
295 |
#ifdef _ALLBSD_SOURCE |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
296 |
capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMES; |
54692
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
297 |
capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_LUTIMES; |
17154
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
298 |
#else |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
299 |
if (my_futimesat_func != NULL) |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
300 |
capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMES; |
54692
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
301 |
if (my_lutimes_func != NULL) |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
302 |
capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_LUTIMES; |
17154
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
303 |
#endif |
57568
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
304 |
if (my_futimens_func != NULL) |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
305 |
capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMENS; |
17154
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
306 |
|
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
307 |
/* supports openat, etc. */ |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
308 |
|
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
309 |
if (my_openat64_func != NULL && my_fstatat64_func != NULL && |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
310 |
my_unlinkat_func != NULL && my_renameat_func != NULL && |
3328
c7e12ed68f87
6864319: (fs) Eliminate static dependency on fdopendir (lnx)
alanb
parents:
3065
diff
changeset
|
311 |
my_futimesat_func != NULL && my_fdopendir_func != NULL) |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
312 |
{ |
17154
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
313 |
capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_OPENAT; |
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
314 |
} |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
315 |
|
17154
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
316 |
/* supports file birthtime */ |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
317 |
|
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
318 |
#ifdef _DARWIN_FEATURE_64_BIT_INODE |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
319 |
capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_BIRTHTIME; |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
320 |
#endif |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
321 |
|
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
322 |
return capabilities; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
323 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
324 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
325 |
JNIEXPORT jbyteArray JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
326 |
Java_sun_nio_fs_UnixNativeDispatcher_getcwd(JNIEnv* env, jclass this) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
327 |
jbyteArray result = NULL; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
328 |
char buf[PATH_MAX+1]; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
329 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
330 |
/* EINTR not listed as a possible error */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
331 |
char* cwd = getcwd(buf, sizeof(buf)); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
332 |
if (cwd == NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
333 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
334 |
} else { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
335 |
jsize len = (jsize)strlen(buf); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
336 |
result = (*env)->NewByteArray(env, len); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
337 |
if (result != NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
338 |
(*env)->SetByteArrayRegion(env, result, 0, len, (jbyte*)buf); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
339 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
340 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
341 |
return result; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
342 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
343 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
344 |
JNIEXPORT jbyteArray |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
345 |
Java_sun_nio_fs_UnixNativeDispatcher_strerror(JNIEnv* env, jclass this, jint error) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
346 |
{ |
32846
5383225ebd0d
8133249: Occasional SIGSEGV: non thread-safe use of strerr in getLastErrorString
robm
parents:
31145
diff
changeset
|
347 |
char tmpbuf[1024]; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
348 |
jsize len; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
349 |
jbyteArray bytes; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
350 |
|
32846
5383225ebd0d
8133249: Occasional SIGSEGV: non thread-safe use of strerr in getLastErrorString
robm
parents:
31145
diff
changeset
|
351 |
getErrorString((int)errno, tmpbuf, sizeof(tmpbuf)); |
5383225ebd0d
8133249: Occasional SIGSEGV: non thread-safe use of strerr in getLastErrorString
robm
parents:
31145
diff
changeset
|
352 |
len = strlen(tmpbuf); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
353 |
bytes = (*env)->NewByteArray(env, len); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
354 |
if (bytes != NULL) { |
32846
5383225ebd0d
8133249: Occasional SIGSEGV: non thread-safe use of strerr in getLastErrorString
robm
parents:
31145
diff
changeset
|
355 |
(*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)tmpbuf); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
356 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
357 |
return bytes; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
358 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
359 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
360 |
JNIEXPORT jint |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
361 |
Java_sun_nio_fs_UnixNativeDispatcher_dup(JNIEnv* env, jclass this, jint fd) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
362 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
363 |
int res = -1; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
364 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
365 |
RESTARTABLE(dup((int)fd), res); |
26209
f7860e8501d8
8055421: (fs) bad error handling in java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
igerasim
parents:
25859
diff
changeset
|
366 |
if (res == -1) { |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
367 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
368 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
369 |
return (jint)res; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
370 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
371 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
372 |
JNIEXPORT jlong JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
373 |
Java_sun_nio_fs_UnixNativeDispatcher_fopen0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
374 |
jlong pathAddress, jlong modeAddress) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
375 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
376 |
FILE* fp = NULL; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
377 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
378 |
const char* mode = (const char*)jlong_to_ptr(modeAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
379 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
380 |
do { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
381 |
fp = fopen(path, mode); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
382 |
} while (fp == NULL && errno == EINTR); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
383 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
384 |
if (fp == NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
385 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
386 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
387 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
388 |
return ptr_to_jlong(fp); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
389 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
390 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
391 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
392 |
Java_sun_nio_fs_UnixNativeDispatcher_fclose(JNIEnv* env, jclass this, jlong stream) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
393 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
394 |
FILE* fp = jlong_to_ptr(stream); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
395 |
|
26209
f7860e8501d8
8055421: (fs) bad error handling in java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
igerasim
parents:
25859
diff
changeset
|
396 |
/* NOTE: fclose() wrapper is only used with read-only streams. |
f7860e8501d8
8055421: (fs) bad error handling in java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
igerasim
parents:
25859
diff
changeset
|
397 |
* If it ever is used with write streams, it might be better to add |
f7860e8501d8
8055421: (fs) bad error handling in java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
igerasim
parents:
25859
diff
changeset
|
398 |
* RESTARTABLE(fflush(fp)) before closing, to make sure the stream |
f7860e8501d8
8055421: (fs) bad error handling in java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
igerasim
parents:
25859
diff
changeset
|
399 |
* is completely written even if fclose() failed. |
f7860e8501d8
8055421: (fs) bad error handling in java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
igerasim
parents:
25859
diff
changeset
|
400 |
*/ |
f7860e8501d8
8055421: (fs) bad error handling in java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
igerasim
parents:
25859
diff
changeset
|
401 |
if (fclose(fp) == EOF && errno != EINTR) { |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
402 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
403 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
404 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
405 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
406 |
JNIEXPORT jint JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
407 |
Java_sun_nio_fs_UnixNativeDispatcher_open0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
408 |
jlong pathAddress, jint oflags, jint mode) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
409 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
410 |
jint fd; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
411 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
412 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
413 |
RESTARTABLE(open64(path, (int)oflags, (mode_t)mode), fd); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
414 |
if (fd == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
415 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
416 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
417 |
return fd; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
418 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
419 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
420 |
JNIEXPORT jint JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
421 |
Java_sun_nio_fs_UnixNativeDispatcher_openat0(JNIEnv* env, jclass this, jint dfd, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
422 |
jlong pathAddress, jint oflags, jint mode) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
423 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
424 |
jint fd; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
425 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
426 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
427 |
if (my_openat64_func == NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
428 |
JNU_ThrowInternalError(env, "should not reach here"); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
429 |
return -1; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
430 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
431 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
432 |
RESTARTABLE((*my_openat64_func)(dfd, path, (int)oflags, (mode_t)mode), fd); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
433 |
if (fd == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
434 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
435 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
436 |
return fd; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
437 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
438 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
439 |
JNIEXPORT void JNICALL |
34537
ca5ca0e04c96
8139133: Changing the modification time on a unix domain socket file fails
bpb
parents:
32846
diff
changeset
|
440 |
Java_sun_nio_fs_UnixNativeDispatcher_close0(JNIEnv* env, jclass this, jint fd) { |
51102
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
441 |
int res; |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
442 |
|
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
443 |
#if defined(_AIX) |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
444 |
/* AIX allows close to be restarted after EINTR */ |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
445 |
RESTARTABLE(close((int)fd), res); |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
446 |
#else |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
447 |
res = close((int)fd); |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
448 |
#endif |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
449 |
if (res == -1 && errno != EINTR) { |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
450 |
throwUnixException(env, errno); |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
451 |
} |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
452 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
453 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
454 |
JNIEXPORT jint JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
455 |
Java_sun_nio_fs_UnixNativeDispatcher_read(JNIEnv* env, jclass this, jint fd, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
456 |
jlong address, jint nbytes) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
457 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
458 |
ssize_t n; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
459 |
void* bufp = jlong_to_ptr(address); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
460 |
RESTARTABLE(read((int)fd, bufp, (size_t)nbytes), n); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
461 |
if (n == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
462 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
463 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
464 |
return (jint)n; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
465 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
466 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
467 |
JNIEXPORT jint JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
468 |
Java_sun_nio_fs_UnixNativeDispatcher_write(JNIEnv* env, jclass this, jint fd, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
469 |
jlong address, jint nbytes) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
470 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
471 |
ssize_t n; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
472 |
void* bufp = jlong_to_ptr(address); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
473 |
RESTARTABLE(write((int)fd, bufp, (size_t)nbytes), n); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
474 |
if (n == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
475 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
476 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
477 |
return (jint)n; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
478 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
479 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
480 |
/** |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
481 |
* Copy stat64 members into sun.nio.fs.UnixFileAttributes |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
482 |
*/ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
483 |
static void prepAttributes(JNIEnv* env, struct stat64* buf, jobject attrs) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
484 |
(*env)->SetIntField(env, attrs, attrs_st_mode, (jint)buf->st_mode); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
485 |
(*env)->SetLongField(env, attrs, attrs_st_ino, (jlong)buf->st_ino); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
486 |
(*env)->SetLongField(env, attrs, attrs_st_dev, (jlong)buf->st_dev); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
487 |
(*env)->SetLongField(env, attrs, attrs_st_rdev, (jlong)buf->st_rdev); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
488 |
(*env)->SetIntField(env, attrs, attrs_st_nlink, (jint)buf->st_nlink); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
489 |
(*env)->SetIntField(env, attrs, attrs_st_uid, (jint)buf->st_uid); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
490 |
(*env)->SetIntField(env, attrs, attrs_st_gid, (jint)buf->st_gid); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
491 |
(*env)->SetLongField(env, attrs, attrs_st_size, (jlong)buf->st_size); |
15275
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
492 |
(*env)->SetLongField(env, attrs, attrs_st_atime_sec, (jlong)buf->st_atime); |
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
493 |
(*env)->SetLongField(env, attrs, attrs_st_mtime_sec, (jlong)buf->st_mtime); |
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
494 |
(*env)->SetLongField(env, attrs, attrs_st_ctime_sec, (jlong)buf->st_ctime); |
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
495 |
|
17154
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
496 |
#ifdef _DARWIN_FEATURE_64_BIT_INODE |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
497 |
(*env)->SetLongField(env, attrs, attrs_st_birthtime_sec, (jlong)buf->st_birthtime); |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
498 |
#endif |
e8991539c4d7
8011536: (fs) BasicFileAttributes.creationTime() should return birth time (mac)
alanb
parents:
15275
diff
changeset
|
499 |
|
48204
b27d2f69e552
8191872: (fs) UnixNativeDispatcher conditionally compiles in support for high precision timestamps
bpb
parents:
47216
diff
changeset
|
500 |
#ifndef MACOSX |
15275
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
501 |
(*env)->SetLongField(env, attrs, attrs_st_atime_nsec, (jlong)buf->st_atim.tv_nsec); |
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
502 |
(*env)->SetLongField(env, attrs, attrs_st_mtime_nsec, (jlong)buf->st_mtim.tv_nsec); |
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
503 |
(*env)->SetLongField(env, attrs, attrs_st_ctime_nsec, (jlong)buf->st_ctim.tv_nsec); |
48204
b27d2f69e552
8191872: (fs) UnixNativeDispatcher conditionally compiles in support for high precision timestamps
bpb
parents:
47216
diff
changeset
|
504 |
#else |
b27d2f69e552
8191872: (fs) UnixNativeDispatcher conditionally compiles in support for high precision timestamps
bpb
parents:
47216
diff
changeset
|
505 |
(*env)->SetLongField(env, attrs, attrs_st_atime_nsec, (jlong)buf->st_atimespec.tv_nsec); |
b27d2f69e552
8191872: (fs) UnixNativeDispatcher conditionally compiles in support for high precision timestamps
bpb
parents:
47216
diff
changeset
|
506 |
(*env)->SetLongField(env, attrs, attrs_st_mtime_nsec, (jlong)buf->st_mtimespec.tv_nsec); |
b27d2f69e552
8191872: (fs) UnixNativeDispatcher conditionally compiles in support for high precision timestamps
bpb
parents:
47216
diff
changeset
|
507 |
(*env)->SetLongField(env, attrs, attrs_st_ctime_nsec, (jlong)buf->st_ctimespec.tv_nsec); |
15275
6e5b8f8361eb
6939260: (fs) BasicFileAttributes.lastModifiedTime() should return last modified time with higher precision
alanb
parents:
14342
diff
changeset
|
508 |
#endif |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
509 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
510 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
511 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
512 |
Java_sun_nio_fs_UnixNativeDispatcher_stat0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
513 |
jlong pathAddress, jobject attrs) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
514 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
515 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
516 |
struct stat64 buf; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
517 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
518 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
519 |
RESTARTABLE(stat64(path, &buf), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
520 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
521 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
522 |
} else { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
523 |
prepAttributes(env, &buf, attrs); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
524 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
525 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
526 |
|
37346
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
527 |
JNIEXPORT jint JNICALL |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
528 |
Java_sun_nio_fs_UnixNativeDispatcher_stat1(JNIEnv* env, jclass this, jlong pathAddress) { |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
529 |
int err; |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
530 |
struct stat64 buf; |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
531 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
532 |
|
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
533 |
RESTARTABLE(stat64(path, &buf), err); |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
534 |
if (err == -1) { |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
535 |
return 0; |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
536 |
} else { |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
537 |
return (jint)buf.st_mode; |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
538 |
} |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
539 |
} |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
540 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
541 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
542 |
Java_sun_nio_fs_UnixNativeDispatcher_lstat0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
543 |
jlong pathAddress, jobject attrs) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
544 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
545 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
546 |
struct stat64 buf; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
547 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
548 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
549 |
RESTARTABLE(lstat64(path, &buf), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
550 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
551 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
552 |
} else { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
553 |
prepAttributes(env, &buf, attrs); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
554 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
555 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
556 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
557 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
558 |
Java_sun_nio_fs_UnixNativeDispatcher_fstat(JNIEnv* env, jclass this, jint fd, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
559 |
jobject attrs) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
560 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
561 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
562 |
struct stat64 buf; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
563 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
564 |
RESTARTABLE(fstat64((int)fd, &buf), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
565 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
566 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
567 |
} else { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
568 |
prepAttributes(env, &buf, attrs); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
569 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
570 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
571 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
572 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
573 |
Java_sun_nio_fs_UnixNativeDispatcher_fstatat0(JNIEnv* env, jclass this, jint dfd, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
574 |
jlong pathAddress, jint flag, jobject attrs) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
575 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
576 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
577 |
struct stat64 buf; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
578 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
579 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
580 |
if (my_fstatat64_func == NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
581 |
JNU_ThrowInternalError(env, "should not reach here"); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
582 |
return; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
583 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
584 |
RESTARTABLE((*my_fstatat64_func)((int)dfd, path, &buf, (int)flag), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
585 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
586 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
587 |
} else { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
588 |
prepAttributes(env, &buf, attrs); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
589 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
590 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
591 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
592 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
593 |
Java_sun_nio_fs_UnixNativeDispatcher_chmod0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
594 |
jlong pathAddress, jint mode) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
595 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
596 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
597 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
598 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
599 |
RESTARTABLE(chmod(path, (mode_t)mode), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
600 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
601 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
602 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
603 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
604 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
605 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
606 |
Java_sun_nio_fs_UnixNativeDispatcher_fchmod(JNIEnv* env, jclass this, jint filedes, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
607 |
jint mode) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
608 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
609 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
610 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
611 |
RESTARTABLE(fchmod((int)filedes, (mode_t)mode), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
612 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
613 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
614 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
615 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
616 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
617 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
618 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
619 |
Java_sun_nio_fs_UnixNativeDispatcher_chown0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
620 |
jlong pathAddress, jint uid, jint gid) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
621 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
622 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
623 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
624 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
625 |
RESTARTABLE(chown(path, (uid_t)uid, (gid_t)gid), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
626 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
627 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
628 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
629 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
630 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
631 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
632 |
Java_sun_nio_fs_UnixNativeDispatcher_lchown0(JNIEnv* env, jclass this, jlong pathAddress, jint uid, jint gid) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
633 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
634 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
635 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
636 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
637 |
RESTARTABLE(lchown(path, (uid_t)uid, (gid_t)gid), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
638 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
639 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
640 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
641 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
642 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
643 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
644 |
Java_sun_nio_fs_UnixNativeDispatcher_fchown(JNIEnv* env, jclass this, jint filedes, jint uid, jint gid) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
645 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
646 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
647 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
648 |
RESTARTABLE(fchown(filedes, (uid_t)uid, (gid_t)gid), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
649 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
650 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
651 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
652 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
653 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
654 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
655 |
Java_sun_nio_fs_UnixNativeDispatcher_utimes0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
656 |
jlong pathAddress, jlong accessTime, jlong modificationTime) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
657 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
658 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
659 |
struct timeval times[2]; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
660 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
661 |
|
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
662 |
times[0].tv_sec = accessTime / 1000000; |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
663 |
times[0].tv_usec = accessTime % 1000000; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
664 |
|
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
665 |
times[1].tv_sec = modificationTime / 1000000; |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
666 |
times[1].tv_usec = modificationTime % 1000000; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
667 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
668 |
RESTARTABLE(utimes(path, ×[0]), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
669 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
670 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
671 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
672 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
673 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
674 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
675 |
Java_sun_nio_fs_UnixNativeDispatcher_futimes(JNIEnv* env, jclass this, jint filedes, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
676 |
jlong accessTime, jlong modificationTime) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
677 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
678 |
struct timeval times[2]; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
679 |
int err = 0; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
680 |
|
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
681 |
times[0].tv_sec = accessTime / 1000000; |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
682 |
times[0].tv_usec = accessTime % 1000000; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
683 |
|
3065
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
684 |
times[1].tv_sec = modificationTime / 1000000; |
452aaa2899fc
6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents:
2057
diff
changeset
|
685 |
times[1].tv_usec = modificationTime % 1000000; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
686 |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
687 |
#ifdef _ALLBSD_SOURCE |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
688 |
RESTARTABLE(futimes(filedes, ×[0]), err); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
689 |
#else |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
690 |
if (my_futimesat_func == NULL) { |
54692
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
691 |
JNU_ThrowInternalError(env, "my_futimesat_func is NULL"); |
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
692 |
return; |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
693 |
} |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
694 |
RESTARTABLE((*my_futimesat_func)(filedes, NULL, ×[0]), err); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
695 |
#endif |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
696 |
if (err == -1) { |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
11833
diff
changeset
|
697 |
throwUnixException(env, errno); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
698 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
699 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
700 |
|
54692
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
701 |
JNIEXPORT void JNICALL |
57568
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
702 |
Java_sun_nio_fs_UnixNativeDispatcher_futimens(JNIEnv* env, jclass this, jint filedes, |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
703 |
jlong accessTime, jlong modificationTime) |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
704 |
{ |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
705 |
struct timespec times[2]; |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
706 |
int err = 0; |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
707 |
|
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
708 |
times[0].tv_sec = accessTime / 1000000000; |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
709 |
times[0].tv_nsec = accessTime % 1000000000; |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
710 |
|
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
711 |
times[1].tv_sec = modificationTime / 1000000000; |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
712 |
times[1].tv_nsec = modificationTime % 1000000000; |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
713 |
|
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
714 |
if (my_futimens_func == NULL) { |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
715 |
JNU_ThrowInternalError(env, "my_futimens_func is NULL"); |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
716 |
return; |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
717 |
} |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
718 |
RESTARTABLE((*my_futimens_func)(filedes, ×[0]), err); |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
719 |
if (err == -1) { |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
720 |
throwUnixException(env, errno); |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
721 |
} |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
722 |
} |
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
723 |
|
460ac76019f4
8181493: (fs) Files.readAttributes(path, BasicFileAttributes.class) should preserve nano second time stamps
bpb
parents:
54692
diff
changeset
|
724 |
JNIEXPORT void JNICALL |
54692
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
725 |
Java_sun_nio_fs_UnixNativeDispatcher_lutimes0(JNIEnv* env, jclass this, |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
726 |
jlong pathAddress, jlong accessTime, jlong modificationTime) |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
727 |
{ |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
728 |
int err; |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
729 |
struct timeval times[2]; |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
730 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
731 |
|
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
732 |
times[0].tv_sec = accessTime / 1000000; |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
733 |
times[0].tv_usec = accessTime % 1000000; |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
734 |
|
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
735 |
times[1].tv_sec = modificationTime / 1000000; |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
736 |
times[1].tv_usec = modificationTime % 1000000; |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
737 |
|
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
738 |
#ifdef _ALLBSD_SOURCE |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
739 |
RESTARTABLE(lutimes(path, ×[0]), err); |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
740 |
#else |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
741 |
if (my_lutimes_func == NULL) { |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
742 |
JNU_ThrowInternalError(env, "my_lutimes_func is NULL"); |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
743 |
return; |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
744 |
} |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
745 |
RESTARTABLE((*my_lutimes_func)(path, ×[0]), err); |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
746 |
#endif |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
747 |
if (err == -1) { |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
748 |
throwUnixException(env, errno); |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
749 |
} |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
750 |
} |
22866513a80e
8220793: (fs) No support for changing modification time of symlink
bpb
parents:
52641
diff
changeset
|
751 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
752 |
JNIEXPORT jlong JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
753 |
Java_sun_nio_fs_UnixNativeDispatcher_opendir0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
754 |
jlong pathAddress) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
755 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
756 |
DIR* dir; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
757 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
758 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
759 |
/* EINTR not listed as a possible error */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
760 |
dir = opendir(path); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
761 |
if (dir == NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
762 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
763 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
764 |
return ptr_to_jlong(dir); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
765 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
766 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
767 |
JNIEXPORT jlong JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
768 |
Java_sun_nio_fs_UnixNativeDispatcher_fdopendir(JNIEnv* env, jclass this, int dfd) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
769 |
DIR* dir; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
770 |
|
3328
c7e12ed68f87
6864319: (fs) Eliminate static dependency on fdopendir (lnx)
alanb
parents:
3065
diff
changeset
|
771 |
if (my_fdopendir_func == NULL) { |
c7e12ed68f87
6864319: (fs) Eliminate static dependency on fdopendir (lnx)
alanb
parents:
3065
diff
changeset
|
772 |
JNU_ThrowInternalError(env, "should not reach here"); |
c7e12ed68f87
6864319: (fs) Eliminate static dependency on fdopendir (lnx)
alanb
parents:
3065
diff
changeset
|
773 |
return (jlong)-1; |
c7e12ed68f87
6864319: (fs) Eliminate static dependency on fdopendir (lnx)
alanb
parents:
3065
diff
changeset
|
774 |
} |
c7e12ed68f87
6864319: (fs) Eliminate static dependency on fdopendir (lnx)
alanb
parents:
3065
diff
changeset
|
775 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
776 |
/* EINTR not listed as a possible error */ |
3328
c7e12ed68f87
6864319: (fs) Eliminate static dependency on fdopendir (lnx)
alanb
parents:
3065
diff
changeset
|
777 |
dir = (*my_fdopendir_func)((int)dfd); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
778 |
if (dir == NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
779 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
780 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
781 |
return ptr_to_jlong(dir); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
782 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
783 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
784 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
785 |
Java_sun_nio_fs_UnixNativeDispatcher_closedir(JNIEnv* env, jclass this, jlong dir) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
786 |
DIR* dirp = jlong_to_ptr(dir); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
787 |
|
26209
f7860e8501d8
8055421: (fs) bad error handling in java.base/unix/native/libnio/fs/UnixNativeDispatcher.c
igerasim
parents:
25859
diff
changeset
|
788 |
if (closedir(dirp) == -1 && errno != EINTR) { |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
789 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
790 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
791 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
792 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
793 |
JNIEXPORT jbyteArray JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
794 |
Java_sun_nio_fs_UnixNativeDispatcher_readdir(JNIEnv* env, jclass this, jlong value) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
795 |
DIR* dirp = jlong_to_ptr(value); |
51597
4c78f4fd8370
8207744: Clean up inconsistent use of opendir/closedir versus opendir64/closedir64
bpb
parents:
51309
diff
changeset
|
796 |
struct dirent* ptr; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
797 |
|
51102
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
798 |
errno = 0; |
51597
4c78f4fd8370
8207744: Clean up inconsistent use of opendir/closedir versus opendir64/closedir64
bpb
parents:
51309
diff
changeset
|
799 |
ptr = readdir(dirp); |
51102
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
800 |
if (ptr == NULL) { |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
801 |
if (errno != 0) { |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
802 |
throwUnixException(env, errno); |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
803 |
} |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
804 |
return NULL; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
805 |
} else { |
51102
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
806 |
jsize len = strlen(ptr->d_name); |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
807 |
jbyteArray bytes = (*env)->NewByteArray(env, len); |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
808 |
if (bytes != NULL) { |
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
809 |
(*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)(ptr->d_name)); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
810 |
} |
51102
90144bc10fe6
8207340: (fs) UnixNativeDispatcher close and readdir usages should be fixed
alanb
parents:
48204
diff
changeset
|
811 |
return bytes; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
812 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
813 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
814 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
815 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
816 |
Java_sun_nio_fs_UnixNativeDispatcher_mkdir0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
817 |
jlong pathAddress, jint mode) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
818 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
819 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
820 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
821 |
/* EINTR not listed as a possible error */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
822 |
if (mkdir(path, (mode_t)mode) == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
823 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
824 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
825 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
826 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
827 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
828 |
Java_sun_nio_fs_UnixNativeDispatcher_rmdir0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
829 |
jlong pathAddress) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
830 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
831 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
832 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
833 |
/* EINTR not listed as a possible error */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
834 |
if (rmdir(path) == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
835 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
836 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
837 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
838 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
839 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
840 |
Java_sun_nio_fs_UnixNativeDispatcher_link0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
841 |
jlong existingAddress, jlong newAddress) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
842 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
843 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
844 |
const char* existing = (const char*)jlong_to_ptr(existingAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
845 |
const char* newname = (const char*)jlong_to_ptr(newAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
846 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
847 |
RESTARTABLE(link(existing, newname), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
848 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
849 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
850 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
851 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
852 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
853 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
854 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
855 |
Java_sun_nio_fs_UnixNativeDispatcher_unlink0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
856 |
jlong pathAddress) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
857 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
858 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
859 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
860 |
/* EINTR not listed as a possible error */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
861 |
if (unlink(path) == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
862 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
863 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
864 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
865 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
866 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
867 |
Java_sun_nio_fs_UnixNativeDispatcher_unlinkat0(JNIEnv* env, jclass this, jint dfd, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
868 |
jlong pathAddress, jint flags) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
869 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
870 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
871 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
872 |
if (my_unlinkat_func == NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
873 |
JNU_ThrowInternalError(env, "should not reach here"); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
874 |
return; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
875 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
876 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
877 |
/* EINTR not listed as a possible error */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
878 |
if ((*my_unlinkat_func)((int)dfd, path, (int)flags) == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
879 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
880 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
881 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
882 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
883 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
884 |
Java_sun_nio_fs_UnixNativeDispatcher_rename0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
885 |
jlong fromAddress, jlong toAddress) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
886 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
887 |
const char* from = (const char*)jlong_to_ptr(fromAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
888 |
const char* to = (const char*)jlong_to_ptr(toAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
889 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
890 |
/* EINTR not listed as a possible error */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
891 |
if (rename(from, to) == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
892 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
893 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
894 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
895 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
896 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
897 |
Java_sun_nio_fs_UnixNativeDispatcher_renameat0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
898 |
jint fromfd, jlong fromAddress, jint tofd, jlong toAddress) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
899 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
900 |
const char* from = (const char*)jlong_to_ptr(fromAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
901 |
const char* to = (const char*)jlong_to_ptr(toAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
902 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
903 |
if (my_renameat_func == NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
904 |
JNU_ThrowInternalError(env, "should not reach here"); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
905 |
return; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
906 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
907 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
908 |
/* EINTR not listed as a possible error */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
909 |
if ((*my_renameat_func)((int)fromfd, from, (int)tofd, to) == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
910 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
911 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
912 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
913 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
914 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
915 |
Java_sun_nio_fs_UnixNativeDispatcher_symlink0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
916 |
jlong targetAddress, jlong linkAddress) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
917 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
918 |
const char* target = (const char*)jlong_to_ptr(targetAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
919 |
const char* link = (const char*)jlong_to_ptr(linkAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
920 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
921 |
/* EINTR not listed as a possible error */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
922 |
if (symlink(target, link) == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
923 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
924 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
925 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
926 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
927 |
JNIEXPORT jbyteArray JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
928 |
Java_sun_nio_fs_UnixNativeDispatcher_readlink0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
929 |
jlong pathAddress) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
930 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
931 |
jbyteArray result = NULL; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
932 |
char target[PATH_MAX+1]; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
933 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
934 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
935 |
/* EINTR not listed as a possible error */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
936 |
int n = readlink(path, target, sizeof(target)); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
937 |
if (n == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
938 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
939 |
} else { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
940 |
jsize len; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
941 |
if (n == sizeof(target)) { |
51309
13e2e64337be
8186766: UnixNativeDispatcher::readlink() may truncate overlong paths
bpb
parents:
51102
diff
changeset
|
942 |
/* Traditionally readlink(2) should not return more than */ |
13e2e64337be
8186766: UnixNativeDispatcher::readlink() may truncate overlong paths
bpb
parents:
51102
diff
changeset
|
943 |
/* PATH_MAX bytes (no terminating null byte is appended). */ |
13e2e64337be
8186766: UnixNativeDispatcher::readlink() may truncate overlong paths
bpb
parents:
51102
diff
changeset
|
944 |
throwUnixException(env, ENAMETOOLONG); |
13e2e64337be
8186766: UnixNativeDispatcher::readlink() may truncate overlong paths
bpb
parents:
51102
diff
changeset
|
945 |
return NULL; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
946 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
947 |
target[n] = '\0'; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
948 |
len = (jsize)strlen(target); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
949 |
result = (*env)->NewByteArray(env, len); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
950 |
if (result != NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
951 |
(*env)->SetByteArrayRegion(env, result, 0, len, (jbyte*)target); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
952 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
953 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
954 |
return result; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
955 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
956 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
957 |
JNIEXPORT jbyteArray JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
958 |
Java_sun_nio_fs_UnixNativeDispatcher_realpath0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
959 |
jlong pathAddress) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
960 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
961 |
jbyteArray result = NULL; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
962 |
char resolved[PATH_MAX+1]; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
963 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
964 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
965 |
/* EINTR not listed as a possible error */ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
966 |
if (realpath(path, resolved) == NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
967 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
968 |
} else { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
969 |
jsize len = (jsize)strlen(resolved); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
970 |
result = (*env)->NewByteArray(env, len); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
971 |
if (result != NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
972 |
(*env)->SetByteArrayRegion(env, result, 0, len, (jbyte*)resolved); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
973 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
974 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
975 |
return result; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
976 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
977 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
978 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
979 |
Java_sun_nio_fs_UnixNativeDispatcher_access0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
980 |
jlong pathAddress, jint amode) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
981 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
982 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
983 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
984 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
985 |
RESTARTABLE(access(path, (int)amode), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
986 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
987 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
988 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
989 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
990 |
|
37346
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
991 |
JNIEXPORT jboolean JNICALL |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
992 |
Java_sun_nio_fs_UnixNativeDispatcher_exists0(JNIEnv* env, jclass this, jlong pathAddress) { |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
993 |
int err; |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
994 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
995 |
RESTARTABLE(access(path, F_OK), err); |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
996 |
return (err == 0) ? JNI_TRUE : JNI_FALSE; |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
997 |
} |
931e55c1287d
8154077: (fs) Reduce number of file system classes loaded during startup
alanb
parents:
34537
diff
changeset
|
998 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
999 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1000 |
Java_sun_nio_fs_UnixNativeDispatcher_statvfs0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1001 |
jlong pathAddress, jobject attrs) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1002 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1003 |
int err; |
31145
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
1004 |
#ifdef MACOSX |
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
1005 |
struct statfs buf; |
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
1006 |
#else |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1007 |
struct statvfs64 buf; |
31145
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
1008 |
#endif |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1009 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1010 |
|
31145
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
1011 |
#ifdef MACOSX |
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
1012 |
RESTARTABLE(statfs(path, &buf), err); |
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
1013 |
#else |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1014 |
RESTARTABLE(statvfs64(path, &buf), err); |
31145
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
1015 |
#endif |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1016 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1017 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1018 |
} else { |
22597
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
1019 |
#ifdef _AIX |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
1020 |
/* AIX returns ULONG_MAX in buf.f_blocks for the /proc file system. */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
1021 |
/* This is too big for a Java signed long and fools various tests. */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
1022 |
if (buf.f_blocks == ULONG_MAX) { |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
1023 |
buf.f_blocks = 0; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
1024 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
1025 |
/* The number of free or available blocks can never exceed the total number of blocks */ |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
1026 |
if (buf.f_blocks == 0) { |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
1027 |
buf.f_bfree = 0; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
1028 |
buf.f_bavail = 0; |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
1029 |
} |
7515a991bb37
8024854: PPC64: Basic changes and files to build the class library on AIX
simonis
parents:
17154
diff
changeset
|
1030 |
#endif |
31145
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
1031 |
#ifdef MACOSX |
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
1032 |
(*env)->SetLongField(env, attrs, attrs_f_frsize, long_to_jlong(buf.f_bsize)); |
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
1033 |
#else |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1034 |
(*env)->SetLongField(env, attrs, attrs_f_frsize, long_to_jlong(buf.f_frsize)); |
31145
af4093895e5f
8081843: (fs) FileStore.getTotalSpace returns unexpected results with >2TB file systems
bpb
parents:
26209
diff
changeset
|
1035 |
#endif |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1036 |
(*env)->SetLongField(env, attrs, attrs_f_blocks, long_to_jlong(buf.f_blocks)); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1037 |
(*env)->SetLongField(env, attrs, attrs_f_bfree, long_to_jlong(buf.f_bfree)); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1038 |
(*env)->SetLongField(env, attrs, attrs_f_bavail, long_to_jlong(buf.f_bavail)); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1039 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1040 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1041 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1042 |
JNIEXPORT jlong JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1043 |
Java_sun_nio_fs_UnixNativeDispatcher_pathconf0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1044 |
jlong pathAddress, jint name) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1045 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1046 |
long err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1047 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1048 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1049 |
err = pathconf(path, (int)name); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1050 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1051 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1052 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1053 |
return (jlong)err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1054 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1055 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1056 |
JNIEXPORT jlong JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1057 |
Java_sun_nio_fs_UnixNativeDispatcher_fpathconf(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1058 |
jint fd, jint name) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1059 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1060 |
long err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1061 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1062 |
err = fpathconf((int)fd, (int)name); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1063 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1064 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1065 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1066 |
return (jlong)err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1067 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1068 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1069 |
JNIEXPORT void JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1070 |
Java_sun_nio_fs_UnixNativeDispatcher_mknod0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1071 |
jlong pathAddress, jint mode, jlong dev) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1072 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1073 |
int err; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1074 |
const char* path = (const char*)jlong_to_ptr(pathAddress); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1075 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1076 |
RESTARTABLE(mknod(path, (mode_t)mode, (dev_t)dev), err); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1077 |
if (err == -1) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1078 |
throwUnixException(env, errno); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1079 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1080 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1081 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1082 |
JNIEXPORT jbyteArray JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1083 |
Java_sun_nio_fs_UnixNativeDispatcher_getpwuid(JNIEnv* env, jclass this, jint uid) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1084 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1085 |
jbyteArray result = NULL; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1086 |
int buflen; |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1087 |
char* pwbuf; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1088 |
|
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1089 |
/* allocate buffer for password record */ |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1090 |
buflen = (int)sysconf(_SC_GETPW_R_SIZE_MAX); |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1091 |
if (buflen == -1) |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1092 |
buflen = ENT_BUF_SIZE; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1093 |
pwbuf = (char*)malloc(buflen); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1094 |
if (pwbuf == NULL) { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1095 |
JNU_ThrowOutOfMemoryError(env, "native heap"); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1096 |
} else { |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1097 |
struct passwd pwent; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1098 |
struct passwd* p = NULL; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1099 |
int res = 0; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1100 |
|
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1101 |
errno = 0; |
40182
1e16a8fd76ba
8160997: Solaris: deprecated <pwd.h> and <gid.h> interfaces should be replaced
dcubed
parents:
37346
diff
changeset
|
1102 |
RESTARTABLE(getpwuid_r((uid_t)uid, &pwent, pwbuf, (size_t)buflen, &p), res); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1103 |
|
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1104 |
if (res != 0 || p == NULL || p->pw_name == NULL || *(p->pw_name) == '\0') { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1105 |
/* not found or error */ |
9688
2ef6a91ab99f
7043788: (fs) PosixFileAttributes.owner() or group() throws NPE if owner/group not in passwd/group database
alanb
parents:
9035
diff
changeset
|
1106 |
if (errno == 0) |
2ef6a91ab99f
7043788: (fs) PosixFileAttributes.owner() or group() throws NPE if owner/group not in passwd/group database
alanb
parents:
9035
diff
changeset
|
1107 |
errno = ENOENT; |
2ef6a91ab99f
7043788: (fs) PosixFileAttributes.owner() or group() throws NPE if owner/group not in passwd/group database
alanb
parents:
9035
diff
changeset
|
1108 |
throwUnixException(env, errno); |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1109 |
} else { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1110 |
jsize len = strlen(p->pw_name); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1111 |
result = (*env)->NewByteArray(env, len); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1112 |
if (result != NULL) { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1113 |
(*env)->SetByteArrayRegion(env, result, 0, len, (jbyte*)(p->pw_name)); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1114 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1115 |
} |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1116 |
free(pwbuf); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1117 |
} |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1118 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1119 |
return result; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1120 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1121 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1122 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1123 |
JNIEXPORT jbyteArray JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1124 |
Java_sun_nio_fs_UnixNativeDispatcher_getgrgid(JNIEnv* env, jclass this, jint gid) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1125 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1126 |
jbyteArray result = NULL; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1127 |
int buflen; |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1128 |
int retry; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1129 |
|
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1130 |
/* initial size of buffer for group record */ |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1131 |
buflen = (int)sysconf(_SC_GETGR_R_SIZE_MAX); |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1132 |
if (buflen == -1) |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1133 |
buflen = ENT_BUF_SIZE; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1134 |
|
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1135 |
do { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1136 |
struct group grent; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1137 |
struct group* g = NULL; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1138 |
int res = 0; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1139 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1140 |
char* grbuf = (char*)malloc(buflen); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1141 |
if (grbuf == NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1142 |
JNU_ThrowOutOfMemoryError(env, "native heap"); |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1143 |
return NULL; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1144 |
} |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1145 |
|
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1146 |
errno = 0; |
40182
1e16a8fd76ba
8160997: Solaris: deprecated <pwd.h> and <gid.h> interfaces should be replaced
dcubed
parents:
37346
diff
changeset
|
1147 |
RESTARTABLE(getgrgid_r((gid_t)gid, &grent, grbuf, (size_t)buflen, &g), res); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1148 |
|
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1149 |
retry = 0; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1150 |
if (res != 0 || g == NULL || g->gr_name == NULL || *(g->gr_name) == '\0') { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1151 |
/* not found or error */ |
9688
2ef6a91ab99f
7043788: (fs) PosixFileAttributes.owner() or group() throws NPE if owner/group not in passwd/group database
alanb
parents:
9035
diff
changeset
|
1152 |
if (errno == ERANGE) { |
2ef6a91ab99f
7043788: (fs) PosixFileAttributes.owner() or group() throws NPE if owner/group not in passwd/group database
alanb
parents:
9035
diff
changeset
|
1153 |
/* insufficient buffer size so need larger buffer */ |
2ef6a91ab99f
7043788: (fs) PosixFileAttributes.owner() or group() throws NPE if owner/group not in passwd/group database
alanb
parents:
9035
diff
changeset
|
1154 |
buflen += ENT_BUF_SIZE; |
2ef6a91ab99f
7043788: (fs) PosixFileAttributes.owner() or group() throws NPE if owner/group not in passwd/group database
alanb
parents:
9035
diff
changeset
|
1155 |
retry = 1; |
2ef6a91ab99f
7043788: (fs) PosixFileAttributes.owner() or group() throws NPE if owner/group not in passwd/group database
alanb
parents:
9035
diff
changeset
|
1156 |
} else { |
2ef6a91ab99f
7043788: (fs) PosixFileAttributes.owner() or group() throws NPE if owner/group not in passwd/group database
alanb
parents:
9035
diff
changeset
|
1157 |
if (errno == 0) |
2ef6a91ab99f
7043788: (fs) PosixFileAttributes.owner() or group() throws NPE if owner/group not in passwd/group database
alanb
parents:
9035
diff
changeset
|
1158 |
errno = ENOENT; |
2ef6a91ab99f
7043788: (fs) PosixFileAttributes.owner() or group() throws NPE if owner/group not in passwd/group database
alanb
parents:
9035
diff
changeset
|
1159 |
throwUnixException(env, errno); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1160 |
} |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1161 |
} else { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1162 |
jsize len = strlen(g->gr_name); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1163 |
result = (*env)->NewByteArray(env, len); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1164 |
if (result != NULL) { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1165 |
(*env)->SetByteArrayRegion(env, result, 0, len, (jbyte*)(g->gr_name)); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1166 |
} |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1167 |
} |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1168 |
|
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1169 |
free(grbuf); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1170 |
|
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1171 |
} while (retry); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1172 |
|
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1173 |
return result; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1174 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1175 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1176 |
JNIEXPORT jint JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1177 |
Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1178 |
jlong nameAddress) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1179 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1180 |
jint uid = -1; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1181 |
int buflen; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1182 |
char* pwbuf; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1183 |
|
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1184 |
/* allocate buffer for password record */ |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1185 |
buflen = (int)sysconf(_SC_GETPW_R_SIZE_MAX); |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1186 |
if (buflen == -1) |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1187 |
buflen = ENT_BUF_SIZE; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1188 |
pwbuf = (char*)malloc(buflen); |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1189 |
if (pwbuf == NULL) { |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1190 |
JNU_ThrowOutOfMemoryError(env, "native heap"); |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1191 |
} else { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1192 |
struct passwd pwent; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1193 |
struct passwd* p = NULL; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1194 |
int res = 0; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1195 |
const char* name = (const char*)jlong_to_ptr(nameAddress); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1196 |
|
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1197 |
errno = 0; |
40182
1e16a8fd76ba
8160997: Solaris: deprecated <pwd.h> and <gid.h> interfaces should be replaced
dcubed
parents:
37346
diff
changeset
|
1198 |
RESTARTABLE(getpwnam_r(name, &pwent, pwbuf, (size_t)buflen, &p), res); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1199 |
|
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1200 |
if (res != 0 || p == NULL || p->pw_name == NULL || *(p->pw_name) == '\0') { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1201 |
/* not found or error */ |
11109
f93eafffdf23
7115070: (fs) lookupPrincipalByName/lookupPrincipalByGroupName should treat ESRCH as not found
ngmr
parents:
9688
diff
changeset
|
1202 |
if (errno != 0 && errno != ENOENT && errno != ESRCH) |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1203 |
throwUnixException(env, errno); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1204 |
} else { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1205 |
uid = p->pw_uid; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1206 |
} |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1207 |
free(pwbuf); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1208 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1209 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1210 |
return uid; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1211 |
} |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1212 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1213 |
JNIEXPORT jint JNICALL |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1214 |
Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0(JNIEnv* env, jclass this, |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1215 |
jlong nameAddress) |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1216 |
{ |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1217 |
jint gid = -1; |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1218 |
int buflen, retry; |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1219 |
|
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1220 |
/* initial size of buffer for group record */ |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1221 |
buflen = (int)sysconf(_SC_GETGR_R_SIZE_MAX); |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1222 |
if (buflen == -1) |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1223 |
buflen = ENT_BUF_SIZE; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1224 |
|
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1225 |
do { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1226 |
struct group grent; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1227 |
struct group* g = NULL; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1228 |
int res = 0; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1229 |
char *grbuf; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1230 |
const char* name = (const char*)jlong_to_ptr(nameAddress); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1231 |
|
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1232 |
grbuf = (char*)malloc(buflen); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1233 |
if (grbuf == NULL) { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1234 |
JNU_ThrowOutOfMemoryError(env, "native heap"); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1235 |
return -1; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1236 |
} |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1237 |
|
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1238 |
errno = 0; |
40182
1e16a8fd76ba
8160997: Solaris: deprecated <pwd.h> and <gid.h> interfaces should be replaced
dcubed
parents:
37346
diff
changeset
|
1239 |
RESTARTABLE(getgrnam_r(name, &grent, grbuf, (size_t)buflen, &g), res); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1240 |
|
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1241 |
retry = 0; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1242 |
if (res != 0 || g == NULL || g->gr_name == NULL || *(g->gr_name) == '\0') { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1243 |
/* not found or error */ |
11109
f93eafffdf23
7115070: (fs) lookupPrincipalByName/lookupPrincipalByGroupName should treat ESRCH as not found
ngmr
parents:
9688
diff
changeset
|
1244 |
if (errno != 0 && errno != ENOENT && errno != ESRCH) { |
8171
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1245 |
if (errno == ERANGE) { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1246 |
/* insufficient buffer size so need larger buffer */ |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1247 |
buflen += ENT_BUF_SIZE; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1248 |
retry = 1; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1249 |
} else { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1250 |
throwUnixException(env, errno); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1251 |
} |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1252 |
} |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1253 |
} else { |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1254 |
gid = g->gr_gid; |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1255 |
} |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1256 |
|
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1257 |
free(grbuf); |
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1258 |
|
71793028dd76
7014794: (file) lookupPrincipalByGroupName fails to find large NIS groups
alanb
parents:
5506
diff
changeset
|
1259 |
} while (retry); |
2057
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1260 |
|
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1261 |
return gid; |
3acf8e5e2ca0
6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff
changeset
|
1262 |
} |