aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-07-10 21:04:14 +0000
committerCorinna Vinschen <corinna@vinschen.de>2001-07-10 21:04:14 +0000
commit8595942c8e647ad48535a6964385c69a8e5f983b (patch)
tree879133631ad15b982c05e06f71f1716d742e2847
parenta8506a19178de9e822fb94b4f7e954643c9e407f (diff)
downloadnewlib-8595942c8e647ad48535a6964385c69a8e5f983b.zip
newlib-8595942c8e647ad48535a6964385c69a8e5f983b.tar.gz
newlib-8595942c8e647ad48535a6964385c69a8e5f983b.tar.bz2
* mmap.cc (fhandler_disk_file::mmap): Try to open file mappings
by a unified name when running under 9x/ME. If that failes, create the file mapping using the unified name.
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/mmap.cc34
2 files changed, 33 insertions, 7 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 362a100..2f4bf3c 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+Tue Jul 10 23:01:00 2001 Corinna Vinschen <corinna@vinschen.de>
+
+ * mmap.cc (fhandler_disk_file::mmap): Try to open file mappings
+ by a unified name when running under 9x/ME. If that failes, create
+ the file mapping using the unified name.
+
Mon Jul 9 10:43:00 2001 Corinna Vinschen <corinna@vinschen.de>
* uinfo.cc (internal_getlogin): Add pointer check.
diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc
index 37cc321..78e60f1 100644
--- a/winsup/cygwin/mmap.cc
+++ b/winsup/cygwin/mmap.cc
@@ -22,6 +22,7 @@ details. */
#include "sigproc.h"
#include "pinfo.h"
#include "security.h"
+#include "sys/cygwin.h"
#define PAGE_CNT(bytes) howmany(bytes,getpagesize())
@@ -739,13 +740,32 @@ fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access,
else
protect = PAGE_READONLY;
- HANDLE h = CreateFileMapping (get_handle (),
- &sec_none,
- protect,
- 0,
- get_handle () == INVALID_HANDLE_VALUE ? len : 0,
- NULL);
- if (h == 0)
+ HANDLE h;
+
+ /* On 9x/ME try first to open the mapping by name when opening a
+ shared file object. This is needed since 9x/ME only shares
+ objects between processes by name. What a mess... */
+ if (os_being_run != winNT
+ && get_handle () != INVALID_HANDLE_VALUE
+ && get_device () == FH_DISK
+ && !(access & FILE_MAP_COPY))
+ {
+ /* Grrr, the whole stuff is just needed to try to get a reliable
+ mapping of the same file. Even that uprising isn't bullet
+ proof but it does it's best... */
+ char namebuf[MAX_PATH];
+ cygwin_conv_to_full_posix_path (get_name (), namebuf);
+ for (int i = strlen (namebuf) - 1; i >= 0; --i)
+ namebuf[i] = cyg_tolower (namebuf [i]);
+
+ if (!(h = OpenFileMapping (access, TRUE, namebuf)))
+ h = CreateFileMapping (get_handle(), &sec_none, protect, 0, 0, namebuf);
+ }
+ else
+ h = CreateFileMapping (get_handle (), &sec_none, protect, 0,
+ get_handle () == INVALID_HANDLE_VALUE ? len : 0,
+ NULL);
+ if (!h)
{
__seterrno ();
syscall_printf ("-1 = mmap(): CreateFileMapping failed with %E");