Skip to content

Commit

Permalink
8306770: (fs) Remove obsolete os.version check from sun.nio.fs.BsdFil…
Browse files Browse the repository at this point in the history
…eStore.supportsFileAttributeView

Reviewed-by: bpb, iris, lancea, alanb
  • Loading branch information
Roger Riggs committed Apr 25, 2023
1 parent 9d1fe65 commit 5f50e99
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/java.base/macosx/classes/sun/nio/fs/BsdFileStore.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,7 +29,6 @@
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 @@ -93,11 +92,8 @@ public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type

// typical macOS file system types that are known to support xattr
String fstype = entry().fstype();
if ("hfs".equals(fstype))
if ("hfs".equals(fstype) || "apfs".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 @@ -113,17 +109,4 @@ 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 5f50e99

@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.