Skip to content

Commit

Permalink
avoid file ownership requirement in touch (#28819)
Browse files Browse the repository at this point in the history
Using `futimes` and passing NULL for the `times` parameter sets the current and access file times, but does not require file ownwership.

From man page:
> If times is NULL, the access and modification times are set to the current time. The caller must be the owner of the file, have permission to write the file, or be the superuser.
  • Loading branch information
tanmaykm authored and JeffBezanson committed Sep 28, 2018
1 parent e1f42b1 commit 3b3a163
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions base/file.jl
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,13 @@ We can see the [`mtime`](@ref) has been modified by `touch`.
function touch(path::AbstractString)
f = open(path, JL_O_WRONLY | JL_O_CREAT, 0o0666)
try
t = time()
futime(f,t,t)
if Sys.isunix()
ret = ccall(:futimes, Cint, (Cint, Ptr{Cvoid}), fd(f), C_NULL)
systemerror(:futimes, ret != 0, extrainfo=path)
else
t = time()
futime(f,t,t)
end
finally
close(f)
end
Expand Down

2 comments on commit 3b3a163

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.