Skip to content

JDK-8030048: (fs) Support UserDefinedFileAttributeView/extended attributes on OS X / HFS+ #2017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from

Conversation

overheadhunter
Copy link
Contributor

@overheadhunter overheadhunter commented Jan 10, 2021

This adds support for UserDefinedFileAttributeView on macOS 10.4 and newer.

While the main audience for this will probably be macOS users, the relevant changes take place in (mostly existing) classes carrying BSD in their names as none of this is really macOS-specific.

Code is mostly copied from the Linux implementation except for three differences:

  1. max length for attribute names is 127 bytes
  2. we know for sure that APFS and HFS+ support extended attributes, therefore we simply return true from supportsFileAttributeView(UserDefinedFileAttributeView.class) for these two FS types, while for all other types support is determined experimentally in isExtendedAttributesEnabled(...)
  3. For the aforementioned check the new UnixConstants.ENOATTR is added, which seems to be macOS and BSD-specific.

As discussed in the mailing list, for ease of tracking changes it is not a goal of this patch to modernize the existing Linux implementation, nor to deduplicate anything.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8030048: (fs) Support UserDefinedFileAttributeView/extended attributes on OS X / HFS+

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2017/head:pull/2017
$ git checkout pull/2017

@bridgekeeper bridgekeeper bot added the oca Needs verification of OCA signatory status label Jan 10, 2021
@bridgekeeper
Copy link

bridgekeeper bot commented Jan 10, 2021

Hi @overheadhunter, welcome to this OpenJDK project and thanks for contributing!

We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing /signed in a comment in this pull request.

If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user overheadhunter" as summary for the issue.

If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing /covered in a comment in this pull request.

@openjdk
Copy link

openjdk bot commented Jan 10, 2021

@overheadhunter The following label will be automatically applied to this pull request:

  • nio

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the nio nio-dev@openjdk.org label Jan 10, 2021
@overheadhunter overheadhunter changed the title JDK-8030048 Add macOS support for UserDefinedFileAttributeView JDK-8030048: (fs) Support UserDefinedFileAttributeView/extended attributes on OS X / HFS+ Jan 10, 2021
@overheadhunter
Copy link
Contributor Author

overheadhunter commented Jan 10, 2021

/covered This patch is submitted on behalf of Skymatic GmbH, for whom I've recently sent in the signed OCA.

@overheadhunter
Copy link
Contributor Author

/covered

@bridgekeeper bridgekeeper bot added the oca-verify Needs verification of OCA signatory status label Jan 10, 2021
@bridgekeeper
Copy link

bridgekeeper bot commented Jan 10, 2021

Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated!

@bridgekeeper bridgekeeper bot removed oca Needs verification of OCA signatory status oca-verify Needs verification of OCA signatory status labels Jan 11, 2021
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 11, 2021
@mlbridge
Copy link

mlbridge bot commented Jan 11, 2021

Webrevs

@AlanBateman
Copy link
Contributor

Overall, this looks quite good and is easy to review.

I think the additions to BsdNativeDispatcher. will need a round or two of cleanup. They comments about XATTR_NOFOLLOW and other options documented in the man pages are a bit distracting. Also the style and excessive long lines aren't consistent with the existing code (and UnixNativeDispatcher).

One thing that we need to decide is whether the additional parameters (position, options) are exposed by BsdNativeDispatcher or not. I think I agree with your approach to have the signature match the methods in LinuxNativeDispatcher as that will make it easier to merge the two implementations later.

The comments that XATTR_NOFOLLOW is not applicable and other options not used is distracting and can be removed.

@overheadhunter
Copy link
Contributor Author

overheadhunter commented Jan 13, 2021

One thing that we need to decide is whether the additional parameters (position, options) are exposed by BsdNativeDispatcher or not. I think I agree with your approach to have the signature match the methods in LinuxNativeDispatcher as that will make it easier to merge the two implementations later.

Just to discuss all options, we could as well hide both params from Java entirely (set them inside of BsdNativeDispatcher.c)

The comments that XATTR_NOFOLLOW is not applicable and other options not used is distracting and can be removed.

Sure, but maybe it should be documented somewhere that none of the flags are required for this use case? Or do you think it is reasonable to assume that anyone stumbling upon this code will just look up the system calls' documentation to see what flags might have been possible?

that don't provide any insights not available on the native methods' man pages
(matching format in LinuxNativeDispatcher.java)
Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. I can sponsor once, you'll need to enter "/integrate"

@openjdk
Copy link

openjdk bot commented Jan 15, 2021

@overheadhunter This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8030048: (fs) Support UserDefinedFileAttributeView/extended attributes on OS X / HFS+

Reviewed-by: alanb

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 147 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@AlanBateman) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 15, 2021
@overheadhunter
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jan 15, 2021
@openjdk
Copy link

openjdk bot commented Jan 15, 2021

@overheadhunter
Your change (at version 9258c37) is now ready to be sponsored by a Committer.

@mlbridge
Copy link

mlbridge bot commented Jan 15, 2021

Mailing list message from Sebastian Stenzel on nio-dev:

Thank you, Alan, for guiding me through the process and reviewing the changes!

Regarding the deduplication I already have some ideas and questions, but I think I'll do this in a new thread in a couple of days.

@AlanBateman
Copy link
Contributor

/integrate

@openjdk
Copy link

openjdk bot commented Jan 16, 2021

@AlanBateman Only the author (@overheadhunter) is allowed to issue the integrate command. As this PR is ready to be sponsored, and you are an eligible sponsor, did you mean to issue the /sponsor command?

@AlanBateman
Copy link
Contributor

/sponsor

@openjdk openjdk bot closed this Jan 16, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed sponsor Pull request is ready to be sponsored ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 16, 2021
@openjdk
Copy link

openjdk bot commented Jan 16, 2021

@AlanBateman @overheadhunter Since your change was applied there have been 152 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

Pushed as commit afd3f78.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@mlbridge
Copy link

mlbridge bot commented Jan 16, 2021

Mailing list message from Alan Bateman on nio-dev:

On 15/01/2021 20:19, Sebastian Stenzel wrote:

:
Thank you, Alan, for guiding me through the process and reviewing the changes!

Regarding the deduplication I already have some ideas and questions, but I think I'll do this in a new thread in a couple of days.

No problem, it's a good contribution for something that the maintainers
in this area never got time to work on.

One issue is that has come up since the commit is that
UserDefinedFileAttributeView/Basic.java is failing on macOS 10.13
systems. I've created JDK-8259865 [1] to track it. I can't duplicate it
on 10.14 and 10.15. I think the issue is that fgetxattr is not failing
with -1/ERANGE when the buffer is too small. We may have to disable
support for user defined file attributes on systems older than 10.14.

-Alan

[1] https://bugs.openjdk.java.net/browse/JDK-8259865

@overheadhunter overheadhunter deleted the feature/macos-xattr branch January 17, 2021 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated nio nio-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

2 participants