Index: ChangeLog
===================================================================
RCS file: /cvsroot/hurd/hurd/ChangeLog,v
retrieving revision 1.132
diff -u -p -r1.132 ChangeLog
--- ChangeLog	7 Apr 2005 20:48:41 -0000	1.132
+++ ChangeLog	13 Jul 2005 19:21:17 -0000
@@ -1,3 +1,7 @@
+2005-07-13  Marcus Brinkmann  <marcus@gnu.org>
+
+	* configure.in: Add check for memory_object_create_proxy.
+
 2005-04-07  Alfred M. Szmidt  <ams@gnu.org>
 
 	* configure.in: Error out if MiG couldn't be found.
Index: configure.in
===================================================================
RCS file: /cvsroot/hurd/hurd/configure.in,v
retrieving revision 1.36
diff -u -p -r1.36 configure.in
--- configure.in	7 Apr 2005 20:48:40 -0000	1.36
+++ configure.in	13 Jul 2005 19:21:17 -0000
@@ -184,6 +184,9 @@ AC_SUBST(boot_store_types)dnl
 AC_MSG_CHECKING(boot store types)
 AC_MSG_RESULT($boot_store_types)
 
+# Check for memory_object_create_proxy in libmachuser.
+AC_CHECK_FUNCS(memory_object_create_proxy)
+
 # Check for ncursesw, which is needed for the console-curses client.
 hurd_LIB_NCURSESW
 
Index: ext2fs/ChangeLog
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/ChangeLog,v
retrieving revision 1.90
diff -u -p -r1.90 ChangeLog
--- ext2fs/ChangeLog	12 Jul 2005 15:29:22 -0000	1.90
+++ ext2fs/ChangeLog	13 Jul 2005 19:21:27 -0000
@@ -1,3 +1,12 @@
+2005-07-13  Marcus Brinkmann  <marcus@gnu.org>
+
+	* pager.c (diskfs_get_filemap): Add new argument USER.
+	[HAVE_MEMORY_OBJECT_CREATE_PROXY] Use proxy memory objects if
+	necessary.
+	* dir.c (diskfs_lookup_hard): Add new argument to invocation.
+	(diskfs_dirempty): Likewise.
+	* truncate.c (force_delayed_copies): Likewise.
+
 2005-07-12  Marcus Brinkmann  <marcus@gnu.org>
 
 	* pager.c (diskfs_get_filemap): Initialize upi->max_prot to PROT.
Index: ext2fs/dir.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/dir.c,v
retrieving revision 1.45
diff -u -p -r1.45 dir.c
--- ext2fs/dir.c	10 Jan 2004 22:08:58 -0000	1.45
+++ ext2fs/dir.c	13 Jul 2005 19:21:27 -0000
@@ -182,7 +182,7 @@ diskfs_lookup_hard (struct node *dp, con
     ds->stat = LOOKING;
 
   /* Map in the directory contents. */
-  memobj = diskfs_get_filemap (dp, prot);
+  memobj = diskfs_get_filemap (dp, prot, VM_PROT_ALL);
 
   if (memobj == MACH_PORT_NULL)
     return errno;
@@ -767,7 +767,7 @@ diskfs_dirempty (struct node *dp, struct
   vm_address_t buf = 0, curoff;
   struct ext2_dir_entry_2 *entry;
   int hit = 0;			/* Found something in the directory.  */
-  memory_object_t memobj = diskfs_get_filemap (dp, VM_PROT_READ);
+  memory_object_t memobj = diskfs_get_filemap (dp, VM_PROT_READ, VM_PROT_ALL);
 
   if (memobj == MACH_PORT_NULL)
     /* XXX should reflect error properly. */
Index: ext2fs/pager.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/pager.c,v
retrieving revision 1.74
diff -u -p -r1.74 pager.c
--- ext2fs/pager.c	12 Jul 2005 15:29:22 -0000	1.74
+++ ext2fs/pager.c	13 Jul 2005 19:21:30 -0000
@@ -781,7 +781,7 @@ create_disk_pager (void)
 /* Call this to create a FILE_DATA pager and return a send right.
    NODE must be locked.  */
 mach_port_t
-diskfs_get_filemap (struct node *node, vm_prot_t prot)
+diskfs_get_filemap (struct node *node, vm_prot_t prot, vm_prot_t prot_max)
 {
   mach_port_t right;
 
@@ -833,6 +833,32 @@ diskfs_get_filemap (struct node *node, v
 
   mach_port_insert_right (mach_task_self (), right, right,
 			  MACH_MSG_TYPE_MAKE_SEND);
+
+#ifdef HAVE_MEMORY_OBJECT_CREATE_PROXY
+  if (prot_max & (VM_PROT_READ | VM_PROT_WRITE)
+      != VM_PROT_READ | VM_PROT_WRITE)
+    {
+      error_t err;
+      mach_port_t object[1] = { right };
+      vm_offset_t offset[1] = { 0 };
+      vm_offset_t start[1] = { 0 };
+      vm_offset_t len[1] = { ~0 };
+
+      /* Create proxy object.  We have to create one proxy memory
+	 object per invocation, as Mach doesn't support caching for
+	 proxy memory objects, and we don't want to hold a hard
+	 reference.  This is why we try to avoid creating the memory
+	 object if it is not necessary.  */
+
+      err = memory_object_create_proxy (mach_task_self (), prot,
+					object, 1, offset, 1,
+					start, 1, len, 1, &right);
+      if (err)
+	right = MACH_PORT_NULL;
+
+      mach_port_deallocate (mach_task_self (), object[0]);
+    }
+#endif
 
   return right;
 }
Index: ext2fs/truncate.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ext2fs/truncate.c,v
retrieving revision 1.38
diff -u -p -r1.38 truncate.c
--- ext2fs/truncate.c	3 Dec 2000 04:41:37 -0000	1.38
+++ ext2fs/truncate.c	13 Jul 2005 19:21:34 -0000
@@ -235,7 +235,7 @@ force_delayed_copies (struct node *node,
       mach_port_t obj;
 
       pager_change_attributes (pager, MAY_CACHE, MEMORY_OBJECT_COPY_NONE, 1);
-      obj = diskfs_get_filemap (node, VM_PROT_READ);
+      obj = diskfs_get_filemap (node, VM_PROT_READ, VM_PROT_ALL);
       if (obj != MACH_PORT_NULL)
 	{
 	  /* XXX should cope with errors from diskfs_get_filemap */
Index: fatfs/ChangeLog
===================================================================
RCS file: /cvsroot/hurd/hurd/fatfs/ChangeLog,v
retrieving revision 1.12
diff -u -p -r1.12 ChangeLog
--- fatfs/ChangeLog	12 Jul 2005 15:29:22 -0000	1.12
+++ fatfs/ChangeLog	13 Jul 2005 19:21:34 -0000
@@ -1,3 +1,14 @@
+2005-07-13  Marcus Brinkmann  <marcus@gnu.org>
+
+	* pager.c (diskfs_get_filemap): Add new argument PROT_MAX.
+	[HAVE_MEMORY_OBJECT_CREATE_PROXY] Use proxy memory objects if
+	necessary.
+	* dir.c (diskfs_lookup_hard): Add new argument to
+	diskfs_get_filemap invocation.
+	(diskfs_dirempty): Likewise.
+	(diskfs_get_directs): Likewise.
+	* inode.c (read_node, write_node): Likewise.
+
 2005-07-12  Marcus Brinkmann  <marcus@gnu.org>
 
 	* pager.c (diskfs_get_filemap): Initialize upi->max_prot to PROT.
Index: fatfs/dir.c
===================================================================
RCS file: /cvsroot/hurd/hurd/fatfs/dir.c,v
retrieving revision 1.3
diff -u -p -r1.3 dir.c
--- fatfs/dir.c	2 Aug 2003 21:32:52 -0000	1.3
+++ fatfs/dir.c	13 Jul 2005 19:21:37 -0000
@@ -216,8 +216,8 @@ diskfs_lookup_hard (struct node *dp, con
   if (ds && (type == CREATE || type == RENAME))
     ds->stat = LOOKING;
 
-  /* Map in the directory contents. */
-  memobj = diskfs_get_filemap (dp, prot);
+  /* Map in the directory contents.  */
+  memobj = diskfs_get_filemap (dp, prot, VM_PROT_ALL);
 
   if (memobj == MACH_PORT_NULL)
     return errno;
@@ -770,7 +770,7 @@ diskfs_dirempty (struct node *dp, struct
   vm_address_t buf = 0, curoff;
   struct dirrect *entry;
   int hit = 0;                  /* Found something in the directory.  */
-  memory_object_t memobj = diskfs_get_filemap (dp, VM_PROT_READ);
+  memory_object_t memobj = diskfs_get_filemap (dp, VM_PROT_READ, VM_PROT_ALL);
 
   if (memobj == MACH_PORT_NULL)
     /* XXX should reflect error properly.  */
@@ -854,7 +854,7 @@ diskfs_get_directs (struct node *dp,
     }
 
   /* Map in the directory contents.  */
-  memobj = diskfs_get_filemap (dp, prot);
+  memobj = diskfs_get_filemap (dp, prot, VM_PROT_ALL);
 
   if (memobj == MACH_PORT_NULL)
     return errno;
Index: fatfs/inode.c
===================================================================
RCS file: /cvsroot/hurd/hurd/fatfs/inode.c,v
retrieving revision 1.5
diff -u -p -r1.5 inode.c
--- fatfs/inode.c	6 Aug 2003 21:47:57 -0000	1.5
+++ fatfs/inode.c	13 Jul 2005 19:21:37 -0000
@@ -313,7 +313,7 @@ read_node (struct node *np, vm_address_t
 	  assert (dp);
       
 	  /* Map in the directory contents. */
-	  memobj = diskfs_get_filemap (dp, prot);
+	  memobj = diskfs_get_filemap (dp, prot, VM_PROT_ALL);
       
 	  if (memobj == MACH_PORT_NULL)
 	    return errno;
@@ -484,7 +484,7 @@ write_node (struct node *np)
       mutex_lock (&dp->lock);
 
       /* Map in the directory contents. */
-      memobj = diskfs_get_filemap (dp, prot);
+      memobj = diskfs_get_filemap (dp, prot, VM_PROT_ALL);
 
       if (memobj == MACH_PORT_NULL)
 	{
Index: fatfs/pager.c
===================================================================
RCS file: /cvsroot/hurd/hurd/fatfs/pager.c,v
retrieving revision 1.4
diff -u -p -r1.4 pager.c
--- fatfs/pager.c	12 Jul 2005 15:29:22 -0000	1.4
+++ fatfs/pager.c	13 Jul 2005 19:21:41 -0000
@@ -760,7 +760,7 @@ create_fat_pager (void)
 /* Call this to create a FILE_DATA pager and return a send right.
    NODE must be locked.  */
 mach_port_t
-diskfs_get_filemap (struct node *node, vm_prot_t prot)
+diskfs_get_filemap (struct node *node, vm_prot_t prot, vm_prot_t prot_max)
 {
   mach_port_t right;
   
@@ -809,6 +809,32 @@ diskfs_get_filemap (struct node *node, v
     }
   while (right == MACH_PORT_NULL);
   spin_unlock (&node_to_page_lock);
+
+#ifdef HAVE_MEMORY_OBJECT_CREATE_PROXY
+  if (prot_max & (VM_PROT_READ | VM_PROT_WRITE)
+      != VM_PROT_READ | VM_PROT_WRITE)
+    {
+      error_t err;
+      mach_port_t object[1] = { right };
+      vm_offset_t offset[1] = { 0 };
+      vm_offset_t start[1] = { 0 };
+      vm_offset_t len[1] = { ~0 };
+
+      /* Create proxy object.  XXX We have to create one proxy memory
+	 object per invocation, as Mach doesn't support caching for
+	 proxy memory objects, and we don't want to hold a hard
+	 reference.  This is why we try to avoid creating the memory
+	 object if it is not necessary.  */
+
+      err = memory_object_create_proxy (mach_task_self (), prot,
+					object, 1, offset, 1,
+					start, 1, len, 1, &right);
+      if (err)
+	right = MACH_PORT_NULL;
+
+      mach_port_deallocate (mach_task_self (), object[0]);
+    }
+#endif
 
   mach_port_insert_right (mach_task_self (), right, right,
                           MACH_MSG_TYPE_MAKE_SEND);
Index: isofs/ChangeLog
===================================================================
RCS file: /cvsroot/hurd/hurd/isofs/ChangeLog,v
retrieving revision 1.38
diff -u -p -r1.38 ChangeLog
--- isofs/ChangeLog	23 Feb 2005 00:00:34 -0000	1.38
+++ isofs/ChangeLog	13 Jul 2005 19:21:44 -0000
@@ -1,3 +1,9 @@
+2005-07-13  Marcus Brinkmann  <marcus@gnu.org>
+
+	* pager.c (diskfs_get_filemap): Add new argument PROT_MAX.
+	[HAVE_MEMORY_OBJECT_CREATE_PROXY] Use proxy memory objects if
+	necessary.
+
 2005-02-23  Alfred M. Szmidt  <ams@gnu.org>
 
 	* Makefile (iso9660fs.static): New target.
Index: isofs/pager.c
===================================================================
RCS file: /cvsroot/hurd/hurd/isofs/pager.c,v
retrieving revision 1.6
diff -u -p -r1.6 pager.c
--- isofs/pager.c	7 Jan 2001 17:06:26 -0000	1.6
+++ isofs/pager.c	13 Jul 2005 19:21:44 -0000
@@ -150,7 +150,7 @@ diskfs_file_update (struct node *np,
 
 /* Create a FILE_DATA pager for the specified node */
 mach_port_t
-diskfs_get_filemap (struct node *np, vm_prot_t prot)
+diskfs_get_filemap (struct node *np, vm_prot_t prot, vm_prot_t prot_max)
 {
   struct user_pager_info *upi;
   mach_port_t right;
@@ -197,6 +197,32 @@ diskfs_get_filemap (struct node *np, vm_
   mach_port_insert_right (mach_task_self (), right, right, 
 			  MACH_MSG_TYPE_MAKE_SEND);
   
+#ifdef HAVE_MEMORY_OBJECT_CREATE_PROXY
+  if (prot_max & (VM_PROT_READ | VM_PROT_WRITE)
+      != VM_PROT_READ | VM_PROT_WRITE)
+    {
+      error_t err;
+      mach_port_t object[1] = { right };
+      vm_offset_t offset[1] = { 0 };
+      vm_offset_t start[1] = { 0 };
+      vm_offset_t len[1] = { ~0 };
+
+      /* Create proxy object.  We have to create one proxy memory
+	 object per invocation, as Mach doesn't support caching for
+	 proxy memory objects, and we don't want to hold a hard
+	 reference.  This is why we try to avoid creating the memory
+	 object if it is not necessary.  */
+
+      err = memory_object_create_proxy (mach_task_self (), prot,
+					object, 1, offset, 1,
+					start, 1, len, 1, &right);
+      if (err)
+	right = MACH_PORT_NULL;
+
+      mach_port_deallocate (mach_task_self (), object[0]);
+    }
+#endif
+
   return right;
 }
 
Index: libdiskfs/ChangeLog
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/ChangeLog,v
retrieving revision 1.185
diff -u -p -r1.185 ChangeLog
--- libdiskfs/ChangeLog	11 Feb 2004 08:28:49 -0000	1.185
+++ libdiskfs/ChangeLog	13 Jul 2005 19:21:56 -0000
@@ -1,3 +1,10 @@
+2005-07-13  Marcus Brinkmann  <marcus@gnu.org>
+
+	* diskfs.h (diskfs_get_filemap): Add a new argument USER.
+	* rdwr-internal.c (_diskfs_rdwr_internal): Likewise to invocation.
+	* io-map.c (get_filemap): New macro.
+	(diskfs_S_io_map): Use it instead of diskfs_get_filemap.
+
 2004-02-10  Roland McGrath  <roland@frob.com>
 
 	* opts-runtime.c (diskfs_runtime_argp): Include <argp.h>.
Index: libdiskfs/diskfs.h
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/diskfs.h,v
retrieving revision 1.98
diff -u -p -r1.98 diskfs.h
--- libdiskfs/diskfs.h	27 Jun 2002 19:19:13 -0000	1.98
+++ libdiskfs/diskfs.h	13 Jul 2005 19:22:04 -0000
@@ -510,10 +510,12 @@ void diskfs_sync_everything (int wait);
    irreversable.  */
 void diskfs_shutdown_pager ();
 
-/* The user must define this function.  Return a memory object port (send
-   right) for the file contents of NP.  PROT is the maximum allowable
-   access.  On errors, return MACH_PORT_NULL and set errno.  */
-mach_port_t diskfs_get_filemap (struct node *np, vm_prot_t prot);
+/* The user must define this function.  Return a memory object port
+   (send right) for the file contents of NP.  PROT_MIN is the minimum,
+   PROT_MAX the maximum allowable access.  On errors, return
+   MACH_PORT_NULL and set errno.  */
+mach_port_t diskfs_get_filemap (struct node *np, vm_prot_t prot_min,
+				vm_prot_t prot_max);
 
 /* The user must define this function.  Return true if there are pager
    ports exported that might be in use by users.  If this returns false, then
Index: libdiskfs/io-map.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/io-map.c,v
retrieving revision 1.11
diff -u -p -r1.11 io-map.c
--- libdiskfs/io-map.c	13 Sep 1999 06:33:47 -0000	1.11
+++ libdiskfs/io-map.c	13 Jul 2005 19:22:04 -0000
@@ -20,6 +20,9 @@
 #include "priv.h"
 #include "io_S.h"
 
+/* For io_map, we always have prot_min == prot_max.  */
+#define get_filemap(node,prot) diskfs_get_filemap (node, prot, prot)
+
 /* Implement io_map as described in <hurd/io.defs>. */
 kern_return_t
 diskfs_S_io_map (struct protid *cred,
@@ -43,18 +46,18 @@ diskfs_S_io_map (struct protid *cred,
   switch (flags)
     {
     case O_READ | O_WRITE:
-      *wrobj = *rdobj = diskfs_get_filemap (node, VM_PROT_READ |VM_PROT_WRITE);
+      *wrobj = *rdobj = get_filemap (node, VM_PROT_READ | VM_PROT_WRITE);
       if (*wrobj == MACH_PORT_NULL)
 	goto error;
       mach_port_mod_refs (mach_task_self (), *rdobj, MACH_PORT_RIGHT_SEND, 1);
       break;
     case O_READ:
-      *rdobj = diskfs_get_filemap (node, VM_PROT_READ);
+      *rdobj = get_filemap (node, VM_PROT_READ);
       if (*rdobj == MACH_PORT_NULL)
 	goto error;
       break;
     case O_WRITE:
-      *wrobj = diskfs_get_filemap (node, VM_PROT_WRITE);
+      *wrobj = get_filemap (node, VM_PROT_WRITE);
       if (*wrobj == MACH_PORT_NULL)
 	goto error;
       break;
Index: libdiskfs/rdwr-internal.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/rdwr-internal.c,v
retrieving revision 1.18
diff -u -p -r1.18 rdwr-internal.c
--- libdiskfs/rdwr-internal.c	24 Jan 2000 07:08:58 -0000	1.18
+++ libdiskfs/rdwr-internal.c	13 Jul 2005 19:22:04 -0000
@@ -53,7 +53,7 @@ _diskfs_rdwr_internal (struct node *np,
 	np->dn_set_atime = 1;
     }
 
-  memobj = diskfs_get_filemap (np, prot);
+  memobj = diskfs_get_filemap (np, prot, VM_PROT_ALL);
 
   if (memobj == MACH_PORT_NULL)
     return errno;
Index: tmpfs/ChangeLog
===================================================================
RCS file: /cvsroot/hurd/hurd/tmpfs/ChangeLog,v
retrieving revision 1.26
diff -u -p -r1.26 ChangeLog
--- tmpfs/ChangeLog	20 Mar 2005 02:21:31 -0000	1.26
+++ tmpfs/ChangeLog	13 Jul 2005 19:22:12 -0000
@@ -1,3 +1,11 @@
+2005-07-13  Marcus Brinkmann  <marcus@gnu.org>
+
+	* node.c (diskfs_get_filemap): Add new argument PROT_MAX.
+	[HAVE_MEMORY_OBJECT_CREATE_PROXY] Use proxy memory objects if
+	necessary.
+	(diskfs_S_file_get_storage_info): Add new argument to
+	diskfs_get_filemap invocation.
+
 2005-03-20  Marcus Brinkmann  <marcus@gnu.org>
 
 	* tmpfs.c (parse_opt): Use the right argument for parsing the
Index: tmpfs/node.c
===================================================================
RCS file: /cvsroot/hurd/hurd/tmpfs/node.c,v
retrieving revision 1.12
diff -u -p -r1.12 node.c
--- tmpfs/node.c	11 Jun 2002 21:40:50 -0000	1.12
+++ tmpfs/node.c	13 Jul 2005 19:22:12 -0000
@@ -462,9 +462,10 @@ diskfs_grow (struct node *np, off_t size
 }
 
 mach_port_t
-diskfs_get_filemap (struct node *np, vm_prot_t prot)
+diskfs_get_filemap (struct node *np, vm_prot_t prot, vm_prot_t prot_max)
 {
   error_t err;
+  mach_port_t right;
 
   if (np->dn->type != DT_REG)
     {
@@ -502,14 +503,40 @@ diskfs_get_filemap (struct node *np, vm_
 					   np->allocsize);
     }
 
-  /* XXX always writable */
+  right = np->dn->u.reg.memobj;
+
+#ifdef HAVE_MEMORY_OBJECT_CREATE_PROXY
+  if (prot_max & (VM_PROT_READ | VM_PROT_WRITE)
+      != VM_PROT_READ | VM_PROT_WRITE)
+    {
+      error_t err;
+      mach_port_t object[1] = { right };
+      vm_offset_t offset[1] = { 0 };
+      vm_offset_t start[1] = { 0 };
+      vm_offset_t len[1] = { ~0 };
+
+      /* Create proxy object.  We have to create one proxy memory
+	 object per invocation, as Mach doesn't support caching for
+	 proxy memory objects, and we don't want to hold a hard
+	 reference.  This is why we try to avoid creating the memory
+	 object if it is not necessary.  */
+
+      err = memory_object_create_proxy (mach_task_self (), prot,
+					object, 1, offset, 1,
+					start, 1, len, 1, &right);
+      if (err)
+	right = MACH_PORT_NULL;
+
+      return right;
+    }
+#endif
 
   /* Add a reference for each call, the caller will deallocate it.  */
-  err = mach_port_mod_refs (mach_task_self (), np->dn->u.reg.memobj,
+  err = mach_port_mod_refs (mach_task_self (), right,
 			    MACH_PORT_RIGHT_SEND, +1);
   assert_perror (err);
 
-  return np->dn->u.reg.memobj;
+  return right;
 }
 
 /* The user must define this function.  Return a `struct pager *' suitable
@@ -552,7 +579,8 @@ diskfs_S_file_get_storage_info (struct p
 				mach_msg_type_number_t *num_offsets,
 				char **data, mach_msg_type_number_t *data_len)
 {
-  mach_port_t memobj = diskfs_get_filemap (cred->po->np, VM_PROT_ALL);
+  mach_port_t memobj = diskfs_get_filemap (cred->po->np,
+					   VM_PROT_ALL, VM_PROT_ALL);
   if (memobj == MACH_PORT_NULL)
     return errno;
 
Index: ufs/ChangeLog
===================================================================
RCS file: /cvsroot/hurd/hurd/ufs/ChangeLog,v
retrieving revision 1.47
diff -u -p -r1.47 ChangeLog
--- ufs/ChangeLog	4 Oct 2002 20:55:55 -0000	1.47
+++ ufs/ChangeLog	13 Jul 2005 19:22:20 -0000
@@ -1,3 +1,13 @@
+2005-07-13  Marcus Brinkmann  <marcus@gnu.org>
+
+	* pager.c (diskfs_get_filemap): Add new argument PROT_MAX.
+	[HAVE_MEMORY_OBJECT_CREATE_PROXY] Use proxy memory objects if
+	necessary.
+	* sizes.c (diskfs_truncate, block_extended, diskfs_grow):
+	Likewise.
+	* dir.c (diskfs_lookup_hard, diskfs_dirempty): Add new argument to
+	diskfs_get_filemap invocation.
+
 2002-10-03  Roland McGrath  <roland@frob.com>
 
 	* dir.h (MAXNAMLEN): #undef before defining.
Index: ufs/dir.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ufs/dir.c,v
retrieving revision 1.45
diff -u -p -r1.45 dir.c
--- ufs/dir.c	1 Aug 2002 00:59:18 -0000	1.45
+++ ufs/dir.c	13 Jul 2005 19:22:22 -0000
@@ -148,7 +148,7 @@ diskfs_lookup_hard (struct node *dp, con
     ds->stat = LOOKING;
 
   /* Map in the directory contents. */
-  memobj = diskfs_get_filemap (dp, prot);
+  memobj = diskfs_get_filemap (dp, prot, VM_PROT_ALL);
 
   if (memobj == MACH_PORT_NULL)
     return errno;
@@ -739,7 +739,7 @@ diskfs_dirempty(struct node *dp,
   memory_object_t memobj;
   error_t err;
 
-  memobj = diskfs_get_filemap (dp, VM_PROT_READ);
+  memobj = diskfs_get_filemap (dp, VM_PROT_READ, VM_PROT_ALL);
 
   if (memobj == MACH_PORT_NULL)
     /* XXX should reflect error properly */
Index: ufs/pager.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ufs/pager.c,v
retrieving revision 1.48
diff -u -p -r1.48 pager.c
--- ufs/pager.c	13 Sep 1999 06:35:07 -0000	1.48
+++ ufs/pager.c	13 Jul 2005 19:22:22 -0000
@@ -547,7 +547,7 @@ flush_node_pager (struct node *node)
 /* Call this to create a FILE_DATA pager and return a send right.
    NP must be locked.  PROT is the max protection desired.  */
 mach_port_t
-diskfs_get_filemap (struct node *np, vm_prot_t prot)
+diskfs_get_filemap (struct node *np, vm_prot_t prot, vm_prot_t prot_max)
 {
   struct user_pager_info *upi;
   mach_port_t right;
@@ -600,6 +600,32 @@ diskfs_get_filemap (struct node *np, vm_
 
   mach_port_insert_right (mach_task_self (), right, right,
 			  MACH_MSG_TYPE_MAKE_SEND);
+
+#ifdef HAVE_MEMORY_OBJECT_CREATE_PROXY
+  if (prot_max & (VM_PROT_READ | VM_PROT_WRITE)
+      != VM_PROT_READ | VM_PROT_WRITE)
+    {
+      error_t err;
+      mach_port_t object[1] = { right };
+      vm_offset_t offset[1] = { 0 };
+      vm_offset_t start[1] = { 0 };
+      vm_offset_t len[1] = { ~0 };
+
+      /* Create proxy object.  XXX We have to create one proxy memory
+	 object per invocation, as Mach doesn't support caching for
+	 proxy memory objects, and we don't want to hold a hard
+	 reference.  This is why we try to avoid creating the memory
+	 object if it is not necessary.  */
+
+      err = memory_object_create_proxy (mach_task_self (), prot,
+					object, 1, offset, 1,
+					start, 1, len, 1, &right);
+      if (err)
+	right = MACH_PORT_NULL;
+
+      mach_port_deallocate (mach_task_self (), object[0]);
+    }
+#endif
 
   return right;
 }
Index: ufs/sizes.c
===================================================================
RCS file: /cvsroot/hurd/hurd/ufs/sizes.c,v
retrieving revision 1.40
diff -u -p -r1.40 sizes.c
--- ufs/sizes.c	13 Sep 1999 06:35:11 -0000	1.40
+++ ufs/sizes.c	13 Jul 2005 19:22:24 -0000
@@ -103,7 +103,8 @@ diskfs_truncate (struct node *np,
 
       pager_change_attributes (upi->p, MAY_CACHE,
 			       MEMORY_OBJECT_COPY_NONE, 1);
-      obj = diskfs_get_filemap (np, VM_PROT_READ | VM_PROT_WRITE);
+      obj = diskfs_get_filemap (np, VM_PROT_READ | VM_PROT_WRITE,
+				VM_PROT_ALL);
       if (obj != MACH_PORT_NULL)
 	{
 	  /* XXX should cope with errors from diskfs_get_filemap */
@@ -403,7 +404,8 @@ block_extended (struct node *np, 
       volatile int *pokeaddr;
 
       /* Map in this part of the file */
-      mapobj = diskfs_get_filemap (np, VM_PROT_WRITE | VM_PROT_READ);
+      mapobj = diskfs_get_filemap (np, VM_PROT_WRITE | VM_PROT_READ,
+				   VM_PROT_ALL);
 
       /* XXX Should cope with errors from diskfs_get_filemap and back
          out the operation here. */
@@ -484,7 +486,7 @@ diskfs_grow (struct node *np,
   assert (!diskfs_readonly);
 
   /* This reference will ensure that NP->dn->fileinfo stays allocated. */
-  pagerpt = diskfs_get_filemap (np, VM_PROT_WRITE|VM_PROT_READ);
+  pagerpt = diskfs_get_filemap (np, VM_PROT_WRITE|VM_PROT_READ, VM_PROT_ALL);
 
   if (pagerpt == MACH_PORT_NULL)
     return errno;
