893N/A/*
3261N/A * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
893N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
893N/A *
893N/A * This code is free software; you can redistribute it and/or modify it
893N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
893N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
893N/A *
893N/A * This code is distributed in the hope that it will be useful, but WITHOUT
893N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
893N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
893N/A * version 2 for more details (a copy is included in the LICENSE file that
893N/A * accompanied this code).
893N/A *
893N/A * You should have received a copy of the GNU General Public License version
893N/A * 2 along with this work; if not, write to the Free Software Foundation,
893N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
893N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
893N/A */
893N/A
893N/Apackage sun.nio.fs;
893N/A
1609N/Aimport java.nio.file.attribute.*;
893N/Aimport java.io.IOException;
893N/A
893N/Aimport static sun.nio.fs.UnixNativeDispatcher.*;
893N/Aimport static sun.nio.fs.SolarisConstants.*;
893N/A
893N/A/**
893N/A * Solaris implementation of FileStore
893N/A */
893N/A
893N/Aclass SolarisFileStore
893N/A extends UnixFileStore
893N/A{
893N/A private final boolean xattrEnabled;
893N/A
893N/A SolarisFileStore(UnixPath file) throws IOException {
893N/A super(file);
893N/A this.xattrEnabled = xattrEnabled();
893N/A }
893N/A
893N/A SolarisFileStore(UnixFileSystem fs, UnixMountEntry entry) throws IOException {
893N/A super(fs, entry);
893N/A this.xattrEnabled = xattrEnabled();
893N/A }
893N/A
893N/A // returns true if extended attributes enabled
893N/A private boolean xattrEnabled() {
893N/A long res = 0L;
893N/A try {
893N/A res = pathconf(file(), _PC_XATTR_ENABLED);
893N/A } catch (UnixException x) {
893N/A // ignore
893N/A }
893N/A return (res != 0L);
893N/A }
893N/A
893N/A @Override
893N/A UnixMountEntry findMountEntry() throws IOException {
893N/A // On Solaris iterate over the entries in the mount table to find device
893N/A for (UnixMountEntry entry: file().getFileSystem().getMountEntries()) {
893N/A if (entry.dev() == dev()) {
893N/A return entry;
893N/A }
893N/A }
893N/A throw new IOException("Device not found in mnttab");
893N/A }
893N/A
893N/A @Override
1609N/A public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
1609N/A if (type == AclFileAttributeView.class) {
893N/A // lookup fstypes.properties
893N/A FeatureStatus status = checkIfFeaturePresent("nfsv4acl");
1609N/A switch (status) {
1609N/A case PRESENT : return true;
1609N/A case NOT_PRESENT : return false;
1609N/A default :
1609N/A // AclFileAttributeView available on ZFS
1609N/A return (type().equals("zfs"));
1609N/A }
893N/A }
1609N/A if (type == UserDefinedFileAttributeView.class) {
893N/A // lookup fstypes.properties
893N/A FeatureStatus status = checkIfFeaturePresent("xattr");
1609N/A switch (status) {
1609N/A case PRESENT : return true;
1609N/A case NOT_PRESENT : return false;
1609N/A default :
1609N/A // UserDefinedFileAttributeView available if extended
1609N/A // attributes supported
1609N/A return xattrEnabled;
1609N/A }
893N/A }
1609N/A return super.supportsFileAttributeView(type);
1609N/A }
893N/A
1609N/A @Override
1609N/A public boolean supportsFileAttributeView(String name) {
1609N/A if (name.equals("acl"))
1609N/A return supportsFileAttributeView(AclFileAttributeView.class);
1609N/A if (name.equals("user"))
1609N/A return supportsFileAttributeView(UserDefinedFileAttributeView.class);
893N/A return super.supportsFileAttributeView(name);
893N/A }
893N/A}