Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/nio/fs/SolarisFileSystem.java
32288 views
1
/*
2
* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
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.
24
*/
25
26
package sun.nio.fs;
27
28
import java.nio.file.*;
29
import java.io.IOException;
30
import java.util.*;
31
import java.security.AccessController;
32
import sun.security.action.GetPropertyAction;
33
import static sun.nio.fs.SolarisNativeDispatcher.*;
34
35
/**
36
* Solaris implementation of FileSystem
37
*/
38
39
class SolarisFileSystem extends UnixFileSystem {
40
private final boolean hasSolaris11Features;
41
42
SolarisFileSystem(UnixFileSystemProvider provider, String dir) {
43
super(provider, dir);
44
45
// check os.version
46
String osversion = AccessController
47
.doPrivileged(new GetPropertyAction("os.version"));
48
String[] vers = Util.split(osversion, '.');
49
assert vers.length >= 2;
50
int majorVersion = Integer.parseInt(vers[0]);
51
int minorVersion = Integer.parseInt(vers[1]);
52
this.hasSolaris11Features =
53
(majorVersion > 5 || (majorVersion == 5 && minorVersion >= 11));
54
}
55
56
@Override
57
boolean isSolaris() {
58
return true;
59
}
60
61
@Override
62
public WatchService newWatchService()
63
throws IOException
64
{
65
// FEN available since Solaris 11
66
if (hasSolaris11Features) {
67
return new SolarisWatchService(this);
68
} else {
69
return new PollingWatchService();
70
}
71
}
72
73
74
// lazy initialization of the list of supported attribute views
75
private static class SupportedFileFileAttributeViewsHolder {
76
static final Set<String> supportedFileAttributeViews =
77
supportedFileAttributeViews();
78
private static Set<String> supportedFileAttributeViews() {
79
Set<String> result = new HashSet<>();
80
result.addAll(standardFileAttributeViews());
81
// additional Solaris-specific views
82
result.add("acl");
83
result.add("user");
84
return Collections.unmodifiableSet(result);
85
}
86
}
87
88
@Override
89
public Set<String> supportedFileAttributeViews() {
90
return SupportedFileFileAttributeViewsHolder.supportedFileAttributeViews;
91
}
92
93
@Override
94
void copyNonPosixAttributes(int ofd, int nfd) {
95
SolarisUserDefinedFileAttributeView.copyExtendedAttributes(ofd, nfd);
96
// TDB: copy ACL from source to target
97
}
98
99
/**
100
* Returns object to iterate over entries in /etc/mnttab
101
*/
102
@Override
103
Iterable<UnixMountEntry> getMountEntries() {
104
ArrayList<UnixMountEntry> entries = new ArrayList<>();
105
try {
106
UnixPath mnttab = new UnixPath(this, "/etc/mnttab");
107
long fp = fopen(mnttab, "r");
108
try {
109
for (;;) {
110
UnixMountEntry entry = new UnixMountEntry();
111
int res = getextmntent(fp, entry);
112
if (res < 0)
113
break;
114
entries.add(entry);
115
}
116
} finally {
117
fclose(fp);
118
}
119
} catch (UnixException x) {
120
// nothing we can do
121
}
122
return entries;
123
}
124
125
@Override
126
FileStore getFileStore(UnixMountEntry entry) throws IOException {
127
return new SolarisFileStore(this, entry);
128
}
129
}
130
131