-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8343417: (fs) BasicFileAttributeView.setTimes uses microsecond precision with NOFOLLOW_LINKS #21886
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
Conversation
…ion with NOFOLLOW_LINKS
👋 Welcome back bpb! A progress list of the required criteria for merging this PR into |
@bplb 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:
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 89 new commits pushed to the
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. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
* | ||
* We hard code fd to FD_ATCWD and flags to AT_SYMLINK_NOFOLLOW. | ||
*/ | ||
static void utimensat(UnixPath path, long times0, long times1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The *at methods that are supposed to map 1-1 to the similarly named sys calls so I'm a bit uncomfortable having this one work differently and hardcode dirfd to FD_ATCWD. I wonder if we could generate a value for FD_ATCWD in UnixConstants.java.template so that the use site would more closely match the sys call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could generate a value for FD_ATCWD in UnixConstants.java.template so that the use site would more closely match the sys call.
Sure, no problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So changed in 26feef6.
…responding system call
} | ||
if (!useLutimes) { | ||
if (!useUtimensat && !useLutimes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the utimesat method to match the sys call is good. Now I wonder if we go further and use fd from openForAttribtueAccess(false) with utimesat. That would remove the window between the lstat and utimesat(AT_FDCWD...) where the file may be replaced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed UnixFileAttributes.get calls lstat. Calling symlink.openForAttributeAccess(false) however yields
java.nio.file.FileSystemException: symlink: No such file or directory or unable to access attributes of symbolic link
According to symlink(7):
The last access and last modification timestamps of a symbolic link can be changed using utimensat(2) or lutimes(3).
It looks like futimens will not work with a symlink's fd so that utimensat is necessary here to obtain nsec precision. I don't see a way to close the window between lstat and utimensat, which anyway was already there for the lutimes case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that the logic in 08f5b7d is quite correct yet. It might be possible if followLinks is false and the file is not a symlink, that lutimes would be used even though futimens is supported, thus decreasing the timestamp resolution.
I think what you have is correct now but it's hard to follow as it's one of 4 sys calls. What would you think about use a local enum class and a switch and get rid of the 4 booleans. Alternatively, invert the setup so that if the follow case is first. The follow case should map to fd+futimens or utimes, no need for futimes. For the !follow case then it should map to lutimesnsat or lutimes. I realise this is adding to the work on this change but right now it's hard for anyone to touch this method due to the many cases. |
It definitely needs reworking but I do not know the details as yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed with Brian about some refactoring setTimes to make it more maintainable, and maybe drop the use of methods that only support micro seconds precision The AIX port may hold us back, not sure. So approving for now, there will be cleanup to follow.
/integrate |
Going to push as commit 56c588b.
Your commit was automatically rebased without conflicts. |
Add support for setting the last access and last modification times of symbolic links with nanosecond precision on Linux where the system call
utimensat(2)
is available.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21886/head:pull/21886
$ git checkout pull/21886
Update a local copy of the PR:
$ git checkout pull/21886
$ git pull https://git.openjdk.org/jdk.git pull/21886/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21886
View PR using the GUI difftool:
$ git pr show -t 21886
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21886.diff
Using Webrev
Link to Webrev Comment