|
1 /* |
|
2 * Copyright 2008-2009 Sun Microsystems, Inc. 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. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 * have any questions. |
|
24 */ |
|
25 |
|
26 package sun.nio.fs; |
|
27 |
|
28 import java.io.IOException; |
|
29 |
|
30 import static sun.nio.fs.UnixNativeDispatcher.*; |
|
31 import static sun.nio.fs.SolarisConstants.*; |
|
32 |
|
33 /** |
|
34 * Solaris implementation of FileStore |
|
35 */ |
|
36 |
|
37 class SolarisFileStore |
|
38 extends UnixFileStore |
|
39 { |
|
40 private final boolean xattrEnabled; |
|
41 |
|
42 SolarisFileStore(UnixPath file) throws IOException { |
|
43 super(file); |
|
44 this.xattrEnabled = xattrEnabled(); |
|
45 } |
|
46 |
|
47 SolarisFileStore(UnixFileSystem fs, UnixMountEntry entry) throws IOException { |
|
48 super(fs, entry); |
|
49 this.xattrEnabled = xattrEnabled(); |
|
50 } |
|
51 |
|
52 // returns true if extended attributes enabled |
|
53 private boolean xattrEnabled() { |
|
54 long res = 0L; |
|
55 try { |
|
56 res = pathconf(file(), _PC_XATTR_ENABLED); |
|
57 } catch (UnixException x) { |
|
58 // ignore |
|
59 } |
|
60 return (res != 0L); |
|
61 } |
|
62 |
|
63 @Override |
|
64 UnixMountEntry findMountEntry() throws IOException { |
|
65 // On Solaris iterate over the entries in the mount table to find device |
|
66 for (UnixMountEntry entry: file().getFileSystem().getMountEntries()) { |
|
67 if (entry.dev() == dev()) { |
|
68 return entry; |
|
69 } |
|
70 } |
|
71 throw new IOException("Device not found in mnttab"); |
|
72 } |
|
73 |
|
74 @Override |
|
75 public boolean supportsFileAttributeView(String name) { |
|
76 if (name.equals("acl")) { |
|
77 // lookup fstypes.properties |
|
78 FeatureStatus status = checkIfFeaturePresent("nfsv4acl"); |
|
79 if (status == FeatureStatus.PRESENT) |
|
80 return true; |
|
81 if (status == FeatureStatus.NOT_PRESENT) |
|
82 return false; |
|
83 // AclFileAttributeView available on ZFS |
|
84 return (type().equals("zfs")); |
|
85 } |
|
86 if (name.equals("xattr")) { |
|
87 // lookup fstypes.properties |
|
88 FeatureStatus status = checkIfFeaturePresent("xattr"); |
|
89 if (status == FeatureStatus.PRESENT) |
|
90 return true; |
|
91 if (status == FeatureStatus.NOT_PRESENT) |
|
92 return false; |
|
93 return xattrEnabled; |
|
94 } |
|
95 |
|
96 return super.supportsFileAttributeView(name); |
|
97 } |
|
98 |
|
99 @Override |
|
100 boolean isLoopback() { |
|
101 return type().equals("lofs"); |
|
102 } |
|
103 } |