8206448: (fs) Extended attributes assumed to be enabled on ext3 (lnx)
Assume extended attributes are only explicitly enable on ext3 Reviewed-by: mbaesken, alanb
This commit is contained in:
parent
96cf046edc
commit
cbefa6b920
@ -25,9 +25,14 @@
|
|||||||
|
|
||||||
package sun.nio.fs;
|
package sun.nio.fs;
|
||||||
|
|
||||||
import java.nio.file.attribute.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.io.IOException;
|
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
|
* Linux implementation of FileStore
|
||||||
@ -121,6 +126,18 @@ class LinuxFileStore
|
|||||||
return false;
|
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
|
@Override
|
||||||
public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
|
public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) {
|
||||||
// support DosFileAttributeView and UserDefinedAttributeView if extended
|
// support DosFileAttributeView and UserDefinedAttributeView if extended
|
||||||
@ -140,11 +157,31 @@ class LinuxFileStore
|
|||||||
if ((entry().hasOption("user_xattr")))
|
if ((entry().hasOption("user_xattr")))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// for ext3 and ext4 user_xattr option is enabled by default so
|
// check for explicit disabling of extended attributes
|
||||||
// check for explicit disabling of this option
|
if (entry().hasOption("nouser_xattr")) {
|
||||||
if (entry().fstype().equals("ext3") ||
|
return false;
|
||||||
entry().fstype().equals("ext4")) {
|
}
|
||||||
return !entry().hasOption("nouser_xattr");
|
|
||||||
|
// 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
|
// not ext3/4 so probe mount point
|
||||||
|
Loading…
x
Reference in New Issue
Block a user