src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java
author bpb
Thu, 12 Apr 2018 14:03:46 -0700
changeset 49586 09905cd87bb2
parent 48460 bdbbf56c302e
child 51100 523eedf01aa7
permissions -rw-r--r--
8009632: (fs) FileStore.supportsFileAttributeView does not detect user_xattr enabled on ext4 Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     1
/*
48460
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
     2
 * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     4
 *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3721
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3721
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    10
 *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    15
 * accompanied this code).
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    16
 *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3721
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3721
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3721
diff changeset
    23
 * questions.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    24
 */
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    25
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    26
package sun.nio.fs;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    27
3721
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
    28
import java.nio.file.attribute.*;
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    29
import java.util.*;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    30
import java.io.IOException;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    31
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    32
/**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    33
 * Linux implementation of FileStore
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    34
 */
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    35
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    36
class LinuxFileStore
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    37
    extends UnixFileStore
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    38
{
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    39
    // used when checking if extended attributes are enabled or not
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    40
    private volatile boolean xattrChecked;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    41
    private volatile boolean xattrEnabled;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    42
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    43
    LinuxFileStore(UnixPath file) throws IOException {
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    44
        super(file);
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    45
    }
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    46
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    47
    LinuxFileStore(UnixFileSystem fs, UnixMountEntry entry) throws IOException {
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    48
        super(fs, entry);
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    49
    }
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    50
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    51
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    52
     * Finds, and returns, the mount entry for the file system where the file
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    53
     * resides.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    54
     */
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    55
    @Override
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    56
    UnixMountEntry findMountEntry() throws IOException {
3065
452aaa2899fc 6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents: 2057
diff changeset
    57
        LinuxFileSystem fs = (LinuxFileSystem)file().getFileSystem();
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    58
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    59
        // step 1: get realpath
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    60
        UnixPath path = null;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    61
        try {
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    62
            byte[] rp = UnixNativeDispatcher.realpath(file());
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    63
            path = new UnixPath(fs, rp);
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    64
        } catch (UnixException x) {
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    65
            x.rethrowAsIOException(file());
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    66
        }
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    67
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    68
        // step 2: find mount point
48460
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    69
        List<UnixMountEntry> procMountsEntries =
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    70
            fs.getMountEntries("/proc/mounts");
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    71
        UnixPath parent = path.getParent();
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    72
        while (parent != null) {
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    73
            UnixFileAttributes attrs = null;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    74
            try {
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    75
                attrs = UnixFileAttributes.get(parent, true);
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    76
            } catch (UnixException x) {
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    77
                x.rethrowAsIOException(parent);
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    78
            }
48460
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    79
            if (attrs.dev() != dev()) {
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    80
                // step 3: lookup mounted file systems (use /proc/mounts to
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    81
                // ensure we find the file system even when not in /etc/mtab)
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    82
                byte[] dir = path.asByteArray();
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    83
                for (UnixMountEntry entry : procMountsEntries) {
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    84
                    if (Arrays.equals(dir, entry.dir()))
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    85
                        return entry;
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    86
                }
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    87
            }
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    88
            path = parent;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    89
            parent = parent.getParent();
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    90
        }
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    91
48460
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    92
        // step 3: lookup mounted file systems (use /proc/mounts to
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    93
        // ensure we find the file system even when not in /etc/mtab)
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    94
        byte[] dir = path.asByteArray();
48460
bdbbf56c302e 8165852: (fs) Mount point not found for a file which is present in overlayfs
bpb
parents: 47216
diff changeset
    95
        for (UnixMountEntry entry : procMountsEntries) {
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    96
            if (Arrays.equals(dir, entry.dir()))
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    97
                return entry;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    98
        }
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    99
3065
452aaa2899fc 6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents: 2057
diff changeset
   100
        throw new IOException("Mount point not found");
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   101
    }
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   102
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   103
    // returns true if extended attributes enabled on file system where given
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   104
    // file resides, returns false if disabled or unable to determine.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   105
    private boolean isExtendedAttributesEnabled(UnixPath path) {
34537
ca5ca0e04c96 8139133: Changing the modification time on a unix domain socket file fails
bpb
parents: 25859
diff changeset
   106
        int fd = -1;
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   107
        try {
34537
ca5ca0e04c96 8139133: Changing the modification time on a unix domain socket file fails
bpb
parents: 25859
diff changeset
   108
            fd = path.openForAttributeAccess(false);
ca5ca0e04c96 8139133: Changing the modification time on a unix domain socket file fails
bpb
parents: 25859
diff changeset
   109
ca5ca0e04c96 8139133: Changing the modification time on a unix domain socket file fails
bpb
parents: 25859
diff changeset
   110
            // fgetxattr returns size if called with size==0
ca5ca0e04c96 8139133: Changing the modification time on a unix domain socket file fails
bpb
parents: 25859
diff changeset
   111
            byte[] name = Util.toBytes("user.java");
ca5ca0e04c96 8139133: Changing the modification time on a unix domain socket file fails
bpb
parents: 25859
diff changeset
   112
            LinuxNativeDispatcher.fgetxattr(fd, name, 0L, 0);
ca5ca0e04c96 8139133: Changing the modification time on a unix domain socket file fails
bpb
parents: 25859
diff changeset
   113
            return true;
ca5ca0e04c96 8139133: Changing the modification time on a unix domain socket file fails
bpb
parents: 25859
diff changeset
   114
        } catch (UnixException e) {
ca5ca0e04c96 8139133: Changing the modification time on a unix domain socket file fails
bpb
parents: 25859
diff changeset
   115
            // attribute does not exist
ca5ca0e04c96 8139133: Changing the modification time on a unix domain socket file fails
bpb
parents: 25859
diff changeset
   116
            if (e.errno() == UnixConstants.ENODATA)
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   117
                return true;
34537
ca5ca0e04c96 8139133: Changing the modification time on a unix domain socket file fails
bpb
parents: 25859
diff changeset
   118
        } finally {
ca5ca0e04c96 8139133: Changing the modification time on a unix domain socket file fails
bpb
parents: 25859
diff changeset
   119
            UnixNativeDispatcher.close(fd);
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   120
        }
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   121
        return false;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   122
    }
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   123
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   124
    @Override
3721
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
   125
    public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
3065
452aaa2899fc 6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents: 2057
diff changeset
   126
        // support DosFileAttributeView and UserDefinedAttributeView if extended
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   127
        // attributes enabled
3721
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
   128
        if (type == DosFileAttributeView.class ||
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
   129
            type == UserDefinedFileAttributeView.class)
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
   130
        {
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   131
            // lookup fstypes.properties
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   132
            FeatureStatus status = checkIfFeaturePresent("user_xattr");
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   133
            if (status == FeatureStatus.PRESENT)
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   134
                return true;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   135
            if (status == FeatureStatus.NOT_PRESENT)
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   136
                return false;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   137
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   138
            // if file system is mounted with user_xattr option then assume
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   139
            // extended attributes are enabled
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   140
            if ((entry().hasOption("user_xattr")))
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   141
                return true;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   142
49586
09905cd87bb2 8009632: (fs) FileStore.supportsFileAttributeView does not detect user_xattr enabled on ext4
bpb
parents: 48460
diff changeset
   143
            // for ext3 and ext4 user_xattr option is enabled by default so
09905cd87bb2 8009632: (fs) FileStore.supportsFileAttributeView does not detect user_xattr enabled on ext4
bpb
parents: 48460
diff changeset
   144
            // check for explicit disabling of this option
09905cd87bb2 8009632: (fs) FileStore.supportsFileAttributeView does not detect user_xattr enabled on ext4
bpb
parents: 48460
diff changeset
   145
            if (entry().fstype().equals("ext3") ||
09905cd87bb2 8009632: (fs) FileStore.supportsFileAttributeView does not detect user_xattr enabled on ext4
bpb
parents: 48460
diff changeset
   146
                entry().fstype().equals("ext4")) {
09905cd87bb2 8009632: (fs) FileStore.supportsFileAttributeView does not detect user_xattr enabled on ext4
bpb
parents: 48460
diff changeset
   147
                return !entry().hasOption("nouser_xattr");
09905cd87bb2 8009632: (fs) FileStore.supportsFileAttributeView does not detect user_xattr enabled on ext4
bpb
parents: 48460
diff changeset
   148
            }
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   149
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   150
            // not ext3/4 so probe mount point
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   151
            if (!xattrChecked) {
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   152
                UnixPath dir = new UnixPath(file().getFileSystem(), entry().dir());
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   153
                xattrEnabled = isExtendedAttributesEnabled(dir);
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   154
                xattrChecked = true;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   155
            }
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   156
            return xattrEnabled;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   157
        }
14011
3d24d5dcf602 6950237: Test java/nio/file/Path/CopyAndMove.java does not work correctly when test dir in on VFAT
dxu
parents: 7668
diff changeset
   158
        // POSIX attributes not supported on FAT
3d24d5dcf602 6950237: Test java/nio/file/Path/CopyAndMove.java does not work correctly when test dir in on VFAT
dxu
parents: 7668
diff changeset
   159
        if (type == PosixFileAttributeView.class && entry().fstype().equals("vfat"))
3d24d5dcf602 6950237: Test java/nio/file/Path/CopyAndMove.java does not work correctly when test dir in on VFAT
dxu
parents: 7668
diff changeset
   160
            return false;
3721
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
   161
        return super.supportsFileAttributeView(type);
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
   162
    }
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   163
3721
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
   164
    @Override
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
   165
    public boolean supportsFileAttributeView(String name) {
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
   166
        if (name.equals("dos"))
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
   167
            return supportsFileAttributeView(DosFileAttributeView.class);
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
   168
        if (name.equals("user"))
1adb60cc9f39 6873621: (file) FileStore.supportsFileAttributeView(Class<FileAttributeView> type) returns wrong result
alanb
parents: 3065
diff changeset
   169
            return supportsFileAttributeView(UserDefinedFileAttributeView.class);
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   170
        return super.supportsFileAttributeView(name);
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   171
    }
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   172
}