From: Fuehrer@seabase.com (Gary Fuehrer)
Subject: mmap(,,,MAP_PRIVATE,,) bug and fix
13 Aug 1997 17:58:36 -0700
Approved: cygnus.gnu-win32@cygnus.com
Distribution: cygnus
Message-ID: <6CC63E2E4FC1D011A2A700609716117A266F05.cygnus.gnu-win32@seawolf>
Mime-Version: 1.0
Content-Type: text/plain
Original-To: "'gnu-win32@cygnus.com'" <gnu-win32@cygnus.com>
X-Priority: 3
X-Mailer: Internet Mail Service (5.0.1458.49)
Original-Sender: owner-gnu-win32@cygnus.com

The B18 implementation of mmap() fails when MAP_PRIVATE is used.

The problem is caused because of this pair of lines in mmap.cc:
  DWORD access = (prot & PROT_WRITE) ? FILE_MAP_WRITE : FILE_MAP_READ;


access |= (flags & MAP_PRIVATE) ? FILE_MAP_COPY : 0;


When MAP_PRIVATE is set, then "access" = "FILE_MAP_READ/WRITE |
MAP_PRIVATE".  When "access" is subsequently passed to MapViewOfFile(),
it fails.  The Microsoft documentation for MapViewOfFile() states the
following concerning the access parameter:
"This parameter can be one of the following values:...".  So, the
failure is because of trying to use more than one of the access types at
the same time.

Fix:  Change the above lines of code to the following (only the second
line is different):
  DWORD access = (prot & PROT_WRITE) ? FILE_MAP_WRITE : FILE_MAP_READ;


if (flags & MAP_PRIVATE) access = FILE_MAP_COPY;


I've tested this change and it seems to work correctly.  Will this fix
make it in for B19?

Gary

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".
