]> gitweb.factorcode.org Git - factor.git/commitdiff
fix file mode for read only mmap in unix
authorDoug Coleman <erg@jobim.local>
Sun, 26 Apr 2009 01:02:41 +0000 (20:02 -0500)
committerDoug Coleman <erg@jobim.local>
Sun, 26 Apr 2009 01:03:13 +0000 (20:03 -0500)
basis/io/mmap/unix/unix.factor

index 0424321b84a65885781b34e69dcf2d8857ce3b81..7d12d52361c3284aca17d9aabf6395f320f76bac 100644 (file)
@@ -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 ;