]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: support mmap with PROT_NONE
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 7 Feb 2015 21:22:40 +0000 (22:22 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 7 Feb 2015 21:22:40 +0000 (22:22 +0100)
ChangeLog
sysdeps/mach/hurd/mmap.c

index 4ba04cdd86b16c2b80007aad0d68f0e77032f3c5..3c1959633869039c5884ba954c60af6945be8da0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
        * hurd/hurd/signal.h (_hurd_critical_section_lock): Don't unlock
        sigstate.
+       * sysdeps/mach/hurd/mmap.c (__mmap): Also handle PROT_NONE case.
 
 2015-02-07  Samuel Thibault  <samuel.thibault@ens-lyon.org>
 
index ca340450128b4d930e1ddfc32015aaf5a95cb099..393008f2fe0b3f3e1d6df8144dcb2124073588b1 100644 (file)
@@ -97,6 +97,13 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
          }
        switch (prot & (PROT_READ|PROT_WRITE))
          {
+         /* Although it apparently doesn't make sense to map a file with
+            protection set to PROT_NONE, it is actually sometimes done.
+            In particular, that's how localedef reserves some space for
+            the locale archive file, the rationale being that some
+            implementations take into account whether the mapping is
+            anonymous or not when selecting addresses.  */
+         case PROT_NONE:
          case PROT_READ:
            memobj = robj;
            if (wobj != MACH_PORT_NULL)
@@ -126,8 +133,8 @@ __mmap (__ptr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
                return (__ptr_t) (long int) __hurd_fail (EACCES);
              }
            break;
-         default:              /* impossible */
-           return 0;
+         default:
+           __builtin_unreachable ();
          }
        break;
        /* XXX handle MAP_NOEXTEND */