about summary refs log tree commit diff
path: root/sysdeps/mach
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-12-12 02:42:14 +0000
committerRoland McGrath <roland@gnu.org>1995-12-12 02:42:14 +0000
commit65bf5fa3172ab9d77fd1792fae68ad85eed2a7b1 (patch)
treec3816deedd850359142a0003295cf4f1b0ea96f3 /sysdeps/mach
parent9b8a44cd18fbf1aedeb03e19f4bcdb06b0ee409b (diff)
downloadglibc-65bf5fa3172ab9d77fd1792fae68ad85eed2a7b1.tar.gz
glibc-65bf5fa3172ab9d77fd1792fae68ad85eed2a7b1.tar.xz
glibc-65bf5fa3172ab9d77fd1792fae68ad85eed2a7b1.zip
Regenerated
Fri Dec  8 13:04:51 1995  Roland McGrath  <roland@churchy.gnu.ai.mit.edu>

	* posix/glob.c: Implement new options GLOB_ALTDIRFUNC, GLOB_BRACE,
	GLOB_TILDE, GLOB_NOMAGIC.
	(glob): Use stat instead of lstat to determine directoriness.
	* posix/glob.h (GLOB_ALTDIRFUNC, GLOB_BRACE, GLOB_NOMAGIC, GLOB_TILDE):
	New flag bits.
	(__GLOB_FLAGS): Include them.
	(glob_t): New members gl_closedir, gl_readdir, gl_opendir, gl_lstat,
	gl_stat.
Diffstat (limited to 'sysdeps/mach')
-rw-r--r--sysdeps/mach/hurd/mmap.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/sysdeps/mach/hurd/mmap.c b/sysdeps/mach/hurd/mmap.c
index 0ef847f7c2..f42c4e55c3 100644
--- a/sysdeps/mach/hurd/mmap.c
+++ b/sysdeps/mach/hurd/mmap.c
@@ -38,6 +38,22 @@ __mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
   vm_prot_t vmprot;
   memory_object_t memobj;
   vm_address_t mapaddr;
+  vm_size_t pageoff;
+
+  pageoff = offset & (vm_page_size - 1);
+  offset &= ~(vm_page_size - 1);
+
+  mapaddr = (vm_address_t) addr;
+  if (flags & MAP_FIXED)
+    {
+      /* A specific address is requested.  It need not be page-aligned;
+	 it just needs to be congruent with the object offset.  */
+      if ((mapaddr & (vm_page_size - 1)) != pageoff)
+	return (caddr_t) (long int) __hurd_fail (EINVAL);
+      else
+	/* We will add back PAGEOFF after mapping.  */
+	mapaddr -= pageoff;
+    }
 
   vmprot = VM_PROT_NONE;
   if (prot & PROT_READ)
@@ -100,16 +116,16 @@ __mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
       }
     }
 
-  mapaddr = (vm_address_t) addr;
+  /* XXX handle MAP_INHERIT */
+
   err = __vm_map (__mach_task_self (),
 		  &mapaddr, (vm_size_t) len, (vm_address_t) 0,
 		  ! (flags & MAP_FIXED),
 		  memobj, (vm_offset_t) offset,
-		  flags & (MAP_COPY|MAP_PRIVATE),
+		  ! (flags & MAP_SHARED),
 		  vmprot, VM_PROT_ALL,
-		  (flags & MAP_INHERIT) == 0 ? VM_INHERIT_NONE :
-		  (flags & (MAP_COPY|MAP_PRIVATE)) ? VM_INHERIT_COPY :
-		  VM_INHERIT_SHARE);
+		  (flags & MAP_SHARED) ? VM_INHERIT_SHARE : VM_INHERIT_COPY);
+
   if (err == KERN_NO_SPACE && (flags & MAP_FIXED))
     {
       /* XXX this is not atomic as it is in unix! */
@@ -129,7 +145,13 @@ __mmap (caddr_t addr, size_t len, int prot, int flags, int fd, off_t offset)
   if (memobj != MACH_PORT_NULL)
     __mach_port_deallocate (__mach_task_self (), memobj);
 
-  return err ? (caddr_t) (long int) __hurd_fail (err) : (caddr_t) mapaddr;
+  if (err)
+    return (caddr_t) (long int) __hurd_fail (err);
+
+  /* Adjust the mapping address for the offset-within-page.  */
+  mapaddr += pageoff;
+
+  return (caddr_t) mapaddr;
 }
 
 weak_alias (__mmap, mmap)