Mail Archives: cygwin-developers/1999/03/05/03:03:39
mmap() with the MAP_PRIVATE mapping type and the PROT_WRITE
protection mode, always fails in MapViewOfFile() with the error
of INVALID_PARAMETER (on Win95) or ACCESS_DENIED (on WinNT).
In this case, mmap() passes FILE_MAP_WRITE | FILE_MAP_COPY to
MapViewOfFile() as its access mode. But according to the
Platform SDK Documentation, it should be either FILE_MAP_WRITE
or FILE_MAP_COPY.
If its access mode is FILE_MAP_READ | FILE_MAP_COPY,
MapViewOfFile() works well against the document. I guess it
picks FILE_MAP_READ only. The following patch is based on this
guess.
--- mmap.cc- Wed Feb 03 13:55:21 1999
+++ mmap.cc Fri Feb 26 15:54:12 1999
@@ -181,16 +181,24 @@ mmap (caddr_t addr, size_t len, int prot
}
}
- DWORD access = (prot & PROT_WRITE) ? FILE_MAP_WRITE : FILE_MAP_READ;
- access |= (flags & MAP_PRIVATE) ? FILE_MAP_COPY : 0;
- DWORD protect;
+ DWORD protect, access;
- if (access & FILE_MAP_COPY)
- protect = PAGE_WRITECOPY;
- else if (access & FILE_MAP_WRITE)
- protect = PAGE_READWRITE;
+
+ if (!(prot & PROT_WRITE))
+ {
+ protect = PAGE_READONLY;
+ access = FILE_MAP_READ;
+ }
+ else if (flags & MAP_PRIVATE)
+ {
+ protect = PAGE_WRITECOPY;
+ access = FILE_MAP_COPY;
+ }
else
- protect = PAGE_READONLY;
+ {
+ protect = PAGE_READWRITE;
+ access = FILE_MAP_WRITE;
+ }
HANDLE hFile;
____
| AIST Kazuhiro Fujieda <fujieda AT jaist DOT ac DOT jp>
| HOKURIKU School of Information Science
o_/ 1990 Japan Advanced Institute of Science and Technology
- Raw text -