Use f
-variants of chmod()
and chown()
#3479
Merged
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.
These variants have lower overhead than their path-taking counterparts. This makes compressing the github dataset something like 10% faster, recovering much of the regression introduced in the 3 added syscalls of #3432.
Note that this requires making some changes to the flow of these syscalls. Previously, we
close()
-ed the file, thenutime()
-ed it, thench{mod,own}()
-ed it. However, anfd
is only valid while the file is open, so in order to callfchmod()
andfchown()
, we need to move those calls to before weclose()
the file. While there is also afutimens()
, we can't use it, since theutime()
call has to come after weclose()
the file, so that we end up with the desiredatime
. (If weutime()
thenclose()
, theclose()
will override theatime
we set.) So the new order isfch{mod,own}()
,close()
,utime()
. This raises minor questions about whether this will now produce situations where wechown()
the file away in such a way that we then don't have permissions toutime()
it. But I think those concerns are unfounded.man utimensat
says we need:But we can only
chown()
the file away to a differentuid
if:So I think it's unlikely there are situations where we can
chown()
something away to a state where we can't thenutime()
it.