Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/nio/fs/SolarisFileStore.java
32288 views
/*1* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.nio.fs;2627import java.nio.file.attribute.*;28import java.io.IOException;2930import static sun.nio.fs.UnixNativeDispatcher.*;31import static sun.nio.fs.SolarisConstants.*;3233/**34* Solaris implementation of FileStore35*/3637class SolarisFileStore38extends UnixFileStore39{40private final boolean xattrEnabled;4142SolarisFileStore(UnixPath file) throws IOException {43super(file);44this.xattrEnabled = xattrEnabled();45}4647SolarisFileStore(UnixFileSystem fs, UnixMountEntry entry) throws IOException {48super(fs, entry);49this.xattrEnabled = xattrEnabled();50}5152// returns true if extended attributes enabled53private boolean xattrEnabled() {54long res = 0L;55try {56res = pathconf(file(), _PC_XATTR_ENABLED);57} catch (UnixException x) {58// ignore59}60return (res != 0L);61}6263@Override64UnixMountEntry findMountEntry() throws IOException {65// On Solaris iterate over the entries in the mount table to find device66for (UnixMountEntry entry: file().getFileSystem().getMountEntries()) {67if (entry.dev() == dev()) {68return entry;69}70}71throw new IOException("Device not found in mnttab");72}7374@Override75public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {76if (type == AclFileAttributeView.class) {77// lookup fstypes.properties78FeatureStatus status = checkIfFeaturePresent("nfsv4acl");79switch (status) {80case PRESENT : return true;81case NOT_PRESENT : return false;82default :83// AclFileAttributeView available on ZFS84return (type().equals("zfs"));85}86}87if (type == UserDefinedFileAttributeView.class) {88// lookup fstypes.properties89FeatureStatus status = checkIfFeaturePresent("xattr");90switch (status) {91case PRESENT : return true;92case NOT_PRESENT : return false;93default :94// UserDefinedFileAttributeView available if extended95// attributes supported96return xattrEnabled;97}98}99return super.supportsFileAttributeView(type);100}101102@Override103public boolean supportsFileAttributeView(String name) {104if (name.equals("acl"))105return supportsFileAttributeView(AclFileAttributeView.class);106if (name.equals("user"))107return supportsFileAttributeView(UserDefinedFileAttributeView.class);108return super.supportsFileAttributeView(name);109}110}111112113