Skip to content

Commit

Permalink
Update stdlib/Mmap/src/Mmap.jl
Browse files Browse the repository at this point in the history
Co-authored-by: Jameson Nash <[email protected]>
  • Loading branch information
xgdgsc and vtjnash committed Nov 8, 2022
1 parent 434ba18 commit c3303b5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions stdlib/Mmap/src/Mmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,12 @@ function mmap(io::IO,
# platform-specific mmapping
@static if Sys.isunix()
prot, flags, iswrite = settings(file_desc, shared)
iswrite && grow && grow!(io, offset, len)
szfile = convert(Csize_t, len + offset)
!iswrite && szfile > filesize(io) && throw(ArgumentError("unable to increase file size to $szfile due to read-only permissions"))
if iswrite && grow
grow!(io, offset, len)
elseif szfile > filesize(io)
throw(ArgumentError("unable to increase file size to $szfile due to read-only permissions"))
end
# mmap the file
ptr = ccall(:jl_mmap, Ptr{Cvoid}, (Ptr{Cvoid}, Csize_t, Cint, Cint, RawFD, Int64),
C_NULL, mmaplen, prot, flags, file_desc, offset_page)
Expand Down

0 comments on commit c3303b5

Please sign in to comment.