Skip to content

Commit

Permalink
if non-regular file skip trying to grow since we know that will fail …
Browse files Browse the repository at this point in the history
…the ftruncate syscall

Co-Authored-By: Jameson Nash <vtjnash+github@gmail.com>
  • Loading branch information
IanButterworth and vtjnash committed Sep 4, 2024
1 parent 984f884 commit bc0c3d9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stdlib/Mmap/src/Mmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ grow!(::Anonymous,o::Integer,l::Integer) = return
function grow!(io::IO, offset::Integer, len::Integer)
pos = position(io)
filelen = filesize(io)
# If non-regular file skip trying to grow since we know that will fail the ftruncate syscall
filelen == 0 && isfile(stat(io)) && return
if filelen < offset + len
failure = ccall(:jl_ftruncate, Cint, (Cint, Int64), fd(io), offset+len)
Base.systemerror(:ftruncate, failure != 0)
Expand Down

0 comments on commit bc0c3d9

Please sign in to comment.