[7.6.0] Actually fix setting the mtime on a shared disk cache. #25473
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The earlier attempt in e9a18ce was not the correct fix, due to the requirements spelled out in the utimensat(2) man page: if the current user has write permission but is not the owner of the file, it may set both atime and mtime to UTIME_NOW, but any other combination is forbidden. Although in theory we could still leave the atime alone in other cases, it's not worth the complexity: atime is often unreliable and Bazel doesn't care about it, anyway.
Unfortunately, it's difficult to write an integration test for this, because we can't arrange for the existence of multiple users in our CI environment.
Fixes #23512.
PiperOrigin-RevId: 729042375
Change-Id: I7ca5e8bc0858a9796f448fca554d0c9465579e19
Commit e7aef80