fix file mode for read only mmap in unix
parent
c44349c74e
commit
3f764fc872
|
@ -4,26 +4,23 @@ USING: alien io io.files kernel math math.bitwise system unix
|
|||
io.backend.unix io.ports io.mmap destructors locals accessors ;
|
||||
IN: io.mmap.unix
|
||||
|
||||
: open-r/w ( path -- fd ) O_RDWR file-mode open-file ;
|
||||
|
||||
:: mmap-open ( path length prot flags -- alien fd )
|
||||
:: mmap-open ( path length prot flags open-mode -- alien fd )
|
||||
[
|
||||
f length prot flags
|
||||
path open-r/w [ <fd> |dispose drop ] keep
|
||||
path open-mode file-mode open-file [ <fd> |dispose drop ] keep
|
||||
[ 0 mmap dup MAP_FAILED = [ (io-error) ] when ] keep
|
||||
] with-destructors ;
|
||||
|
||||
M: unix (mapped-file-r/w)
|
||||
{ PROT_READ PROT_WRITE } flags
|
||||
{ MAP_FILE MAP_SHARED } flags
|
||||
mmap-open ;
|
||||
O_RDWR mmap-open ;
|
||||
|
||||
M: unix (mapped-file-reader)
|
||||
{ PROT_READ } flags
|
||||
{ MAP_FILE MAP_SHARED } flags
|
||||
mmap-open ;
|
||||
O_RDONLY mmap-open ;
|
||||
|
||||
M: unix close-mapped-file ( mmap -- )
|
||||
[ [ address>> ] [ length>> ] bi munmap io-error ]
|
||||
[ handle>> close-file ]
|
||||
bi ;
|
||||
[ handle>> close-file ] bi ;
|
||||
|
|
Loading…
Reference in New Issue