< prev index next >

src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java

Print this page
rev 51055 : 8206448: (fs) Extended attributes assumed to be enabled on ext3 (lnx)
Summary: Assume extended attributes are only explicitly enable on ext3
Reviewed-by: mbaesken, alanb
rev 51056 : imported patch xattr-ext3-8206448.01
rev 51057 : imported patch xattr-ext3-8206448.02

*** 23,35 **** * questions. */ package sun.nio.fs; - import java.nio.file.attribute.*; - import java.util.*; import java.io.IOException; /** * Linux implementation of FileStore */ --- 23,40 ---- * questions. */ package sun.nio.fs; import java.io.IOException; + import java.nio.file.attribute.DosFileAttributeView; + import java.nio.file.attribute.FileAttributeView; + import java.nio.file.attribute.PosixFileAttributeView; + import java.nio.file.attribute.UserDefinedFileAttributeView; + import java.util.Arrays; + import java.util.List; + import java.util.regex.Pattern; /** * Linux implementation of FileStore */
*** 119,128 **** --- 124,145 ---- UnixNativeDispatcher.close(fd); } return false; } + // get kernel version as a three element array {major, minor, micro} + private static int[] getKernelVersion() { + Pattern pattern = Pattern.compile("\\D+"); + String[] matches = pattern.split(System.getProperty("os.version")); + int[] majorMinorMicro = new int[3]; + int length = Math.min(matches.length, majorMinorMicro.length); + for (int i = 0; i < length; i++) { + majorMinorMicro[i] = Integer.valueOf(matches[i]); + } + return majorMinorMicro; + } + @Override public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) { // support DosFileAttributeView and UserDefinedAttributeView if extended // attributes enabled if (type == DosFileAttributeView.class ||
*** 138,152 **** // if file system is mounted with user_xattr option then assume // extended attributes are enabled if ((entry().hasOption("user_xattr"))) return true; ! // for ext3 and ext4 user_xattr option is enabled by default so ! // check for explicit disabling of this option ! if (entry().fstype().equals("ext3") || ! entry().fstype().equals("ext4")) { ! return !entry().hasOption("nouser_xattr"); } // not ext3/4 so probe mount point if (!xattrChecked) { UnixPath dir = new UnixPath(file().getFileSystem(), entry().dir()); --- 155,189 ---- // if file system is mounted with user_xattr option then assume // extended attributes are enabled if ((entry().hasOption("user_xattr"))) return true; ! // check for explicit disabling of extended attributes ! if (entry().hasOption("nouser_xattr")) { ! return false; ! } ! ! // user_{no}xattr options not present but we special-case ext3 as ! // we know that extended attributes are not enabled by default. ! if (entry().fstype().equals("ext3")) { ! return false; ! } ! ! // user_xattr option not present but we special-case ext4 as we ! // know that extended attributes are enabled by default for ! // kernel version >= 2.6.39 ! if (entry().fstype().equals("ext4")) { ! if (!xattrChecked) { ! // check kernel version ! int[] kernelVersion = getKernelVersion(); ! xattrEnabled = kernelVersion[0] > 2 || ! (kernelVersion[0] == 2 && kernelVersion[1] > 6) || ! (kernelVersion[0] == 2 && kernelVersion[1] == 6 && ! kernelVersion[2] >= 39); ! xattrChecked = true; ! } ! return xattrEnabled; } // not ext3/4 so probe mount point if (!xattrChecked) { UnixPath dir = new UnixPath(file().getFileSystem(), entry().dir());
< prev index next >