diff --git a/jdk/src/share/sample/nio/file/Xdd.java b/jdk/src/share/sample/nio/file/Xdd.java index b540b31fd1b..b5102976077 100644 --- a/jdk/src/share/sample/nio/file/Xdd.java +++ b/jdk/src/share/sample/nio/file/Xdd.java @@ -57,9 +57,9 @@ public class Xdd { Path file = (args.length == 1) ? Paths.get(args[0]) : Paths.get(args[2]); - // check that user defined attributes are supported by the file system + // check that user defined attributes are supported by the file store FileStore store = file.getFileStore(); - if (!store.supportsFileAttributeView("user")) { + if (!store.supportsFileAttributeView(UserDefinedFileAttributeView.class)) { System.err.format("UserDefinedFileAttributeView not supported on %s\n", store); System.exit(-1); diff --git a/jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java b/jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java index 7eb45bde481..81132985b75 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java +++ b/jdk/src/solaris/classes/sun/nio/fs/LinuxFileStore.java @@ -25,6 +25,7 @@ package sun.nio.fs; +import java.nio.file.attribute.*; import java.util.*; import java.io.IOException; @@ -113,10 +114,12 @@ class LinuxFileStore } @Override - public boolean supportsFileAttributeView(String name) { + public boolean supportsFileAttributeView(Class type) { // support DosFileAttributeView and UserDefinedAttributeView if extended // attributes enabled - if (name.equals("dos") || name.equals("user")) { + if (type == DosFileAttributeView.class || + type == UserDefinedFileAttributeView.class) + { // lookup fstypes.properties FeatureStatus status = checkIfFeaturePresent("user_xattr"); if (status == FeatureStatus.PRESENT) @@ -142,7 +145,15 @@ class LinuxFileStore } return xattrEnabled; } + return super.supportsFileAttributeView(type); + } + @Override + public boolean supportsFileAttributeView(String name) { + if (name.equals("dos")) + return supportsFileAttributeView(DosFileAttributeView.class); + if (name.equals("user")) + return supportsFileAttributeView(UserDefinedFileAttributeView.class); return super.supportsFileAttributeView(name); } diff --git a/jdk/src/solaris/classes/sun/nio/fs/SolarisFileStore.java b/jdk/src/solaris/classes/sun/nio/fs/SolarisFileStore.java index aaa737137d3..8cf2bbe0818 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/SolarisFileStore.java +++ b/jdk/src/solaris/classes/sun/nio/fs/SolarisFileStore.java @@ -25,6 +25,7 @@ package sun.nio.fs; +import java.nio.file.attribute.*; import java.io.IOException; import static sun.nio.fs.UnixNativeDispatcher.*; @@ -72,27 +73,39 @@ class SolarisFileStore } @Override - public boolean supportsFileAttributeView(String name) { - if (name.equals("acl")) { + public boolean supportsFileAttributeView(Class type) { + if (type == AclFileAttributeView.class) { // lookup fstypes.properties FeatureStatus status = checkIfFeaturePresent("nfsv4acl"); - if (status == FeatureStatus.PRESENT) - return true; - if (status == FeatureStatus.NOT_PRESENT) - return false; - // AclFileAttributeView available on ZFS - return (type().equals("zfs")); + switch (status) { + case PRESENT : return true; + case NOT_PRESENT : return false; + default : + // AclFileAttributeView available on ZFS + return (type().equals("zfs")); + } } - if (name.equals("user")) { + if (type == UserDefinedFileAttributeView.class) { // lookup fstypes.properties FeatureStatus status = checkIfFeaturePresent("xattr"); - if (status == FeatureStatus.PRESENT) - return true; - if (status == FeatureStatus.NOT_PRESENT) - return false; - return xattrEnabled; + switch (status) { + case PRESENT : return true; + case NOT_PRESENT : return false; + default : + // UserDefinedFileAttributeView available if extended + // attributes supported + return xattrEnabled; + } } + return super.supportsFileAttributeView(type); + } + @Override + public boolean supportsFileAttributeView(String name) { + if (name.equals("acl")) + return supportsFileAttributeView(AclFileAttributeView.class); + if (name.equals("user")) + return supportsFileAttributeView(UserDefinedFileAttributeView.class); return super.supportsFileAttributeView(name); } diff --git a/jdk/src/solaris/classes/sun/nio/fs/UnixFileStore.java b/jdk/src/solaris/classes/sun/nio/fs/UnixFileStore.java index 02397648eae..f19b2f90fe8 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/UnixFileStore.java +++ b/jdk/src/solaris/classes/sun/nio/fs/UnixFileStore.java @@ -145,9 +145,8 @@ abstract class UnixFileStore { // lookup fstypes.properties FeatureStatus status = checkIfFeaturePresent("posix"); - if (status == FeatureStatus.NOT_PRESENT) - return false; - return true; + // assume supported if UNKNOWN + return (status != FeatureStatus.NOT_PRESENT); } return false; } diff --git a/jdk/src/windows/classes/sun/nio/fs/WindowsFileStore.java b/jdk/src/windows/classes/sun/nio/fs/WindowsFileStore.java index a906b54e0de..5af14f1673f 100644 --- a/jdk/src/windows/classes/sun/nio/fs/WindowsFileStore.java +++ b/jdk/src/windows/classes/sun/nio/fs/WindowsFileStore.java @@ -153,7 +153,7 @@ class WindowsFileStore public boolean supportsFileAttributeView(Class type) { if (type == null) throw new NullPointerException(); - if (type == BasicFileAttributeView.class) + if (type == BasicFileAttributeView.class || type == DosFileAttributeView.class) return true; if (type == AclFileAttributeView.class || type == FileOwnerAttributeView.class) return ((volInfo.flags() & FILE_PERSISTENT_ACLS) != 0); diff --git a/jdk/test/java/nio/file/FileStore/Basic.java b/jdk/test/java/nio/file/FileStore/Basic.java index 604795db435..85e6b992a57 100644 --- a/jdk/test/java/nio/file/FileStore/Basic.java +++ b/jdk/test/java/nio/file/FileStore/Basic.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 4313887 + * @bug 4313887 6873621 * @summary Unit test for java.nio.file.FileStore * @library .. */ @@ -67,6 +67,15 @@ public class Basic { * Test: File and FileStore attributes */ assertTrue(store1.supportsFileAttributeView("basic")); + assertTrue(store1.supportsFileAttributeView(BasicFileAttributeView.class)); + assertTrue(store1.supportsFileAttributeView("posix") == + store1.supportsFileAttributeView(PosixFileAttributeView.class)); + assertTrue(store1.supportsFileAttributeView("dos") == + store1.supportsFileAttributeView(DosFileAttributeView.class)); + assertTrue(store1.supportsFileAttributeView("acl") == + store1.supportsFileAttributeView(AclFileAttributeView.class)); + assertTrue(store1.supportsFileAttributeView("user") == + store1.supportsFileAttributeView(UserDefinedFileAttributeView.class)); /** * Test: Enumerate all FileStores