Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com To: cygwin-developers AT sourceware DOT cygnus DOT com Subject: mmap bug X-Emacs: Emacs 20.2, MULE 3.0 (MOMIJINOGA), Meadow-1.00 (MIDORI) MIME-Version: 1.0 (generated by SEMI MIME-Edit 0.100 - "Shijima") Content-Type: text/plain; charset=US-ASCII From: Kazuhiro Fujieda Date: 05 Mar 1999 17:03:44 +0900 Message-ID: Lines: 53 X-Mailer: Semi-gnus 6.0.4 (based on Quassia Gnus v0.23) 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 | HOKURIKU School of Information Science o_/ 1990 Japan Advanced Institute of Science and Technology