Skip to content

Commit

Permalink
8259865: (fs) test/jdk/java/nio/file/attribute/UserDefinedFileAttribu…
Browse files Browse the repository at this point in the history
…teView/Basic.java failing on macOS 10.13

Reviewed-by: dcubed
  • Loading branch information
Alan Bateman committed Jan 17, 2021
1 parent da4cf05 commit 5f2e280
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/java.base/macosx/classes/sun/nio/fs/BsdFileStore.java
Expand Up @@ -25,9 +25,11 @@

package sun.nio.fs;

import java.nio.file.attribute.*;
import java.util.*;
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.attribute.UserDefinedFileAttributeView;
import java.io.IOException;
import java.util.Arrays;
import sun.security.action.GetPropertyAction;

/**
* Bsd implementation of FileStore
Expand Down Expand Up @@ -111,9 +113,12 @@ public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type
return false;

// typical macOS file system types that are known to support xattr
if (entry().fstype().equals("apfs")
|| entry().fstype().equals("hfs")) {
String fstype = entry().fstype();
if ("hfs".equals(fstype))
return true;
if ("apfs".equals(fstype)) {
// fgetxattr broken on APFS prior to 10.14
return isOsVersionGte(10, 14);
}

// probe file system capabilities
Expand All @@ -129,4 +134,17 @@ public boolean supportsFileAttributeView(String name) {
return supportsFileAttributeView(UserDefinedFileAttributeView.class);
return super.supportsFileAttributeView(name);
}

/**
* Returns true if the OS major/minor version is greater than, or equal, to the
* given major/minor version.
*/
private static boolean isOsVersionGte(int requiredMajor, int requiredMinor) {
String osVersion = GetPropertyAction.privilegedGetProperty("os.version");
String[] vers = Util.split(osVersion, '.');
int majorVersion = Integer.parseInt(vers[0]);
int minorVersion = Integer.parseInt(vers[1]);
return (majorVersion > requiredMajor)
|| (majorVersion == requiredMajor && minorVersion >= requiredMinor);
}
}

1 comment on commit 5f2e280

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.