From 04301b2623ccdf8e43b2ee860a49457c7eb40105 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 17 Jul 1997 20:10:39 +0000 Subject: (trivfs_S_io_map): Pass PROT argument to dev_get_memory_object. --- storeio/io.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'storeio') diff --git a/storeio/io.c b/storeio/io.c index 8b31a3e6..4586c683 100644 --- a/storeio/io.c +++ b/storeio/io.c @@ -44,21 +44,26 @@ trivfs_S_io_map (struct trivfs_protid *cred, else { mach_port_t memobj; - error_t err = - dev_get_memory_object (((struct open *)cred->po->hook)->dev, &memobj); + int flags = cred->po->openmodes; + vm_prot_t prot = + ((flags & O_READ) ? VM_PROT_READ : 0) + | ((flags & O_WRITE) ? VM_PROT_WRITE : 0); + struct open *open = (struct open *)cred->po->hook; + error_t err = dev_get_memory_object (open->dev, prot, &memobj); if (!err) { - if (cred->po->openmodes & O_READ) + if (flags & O_READ) *rd_obj = memobj; else *rd_obj = MACH_PORT_NULL; - if (cred->po->openmodes & O_WRITE) + if (flags & O_WRITE) *wr_obj = memobj; else *wr_obj = MACH_PORT_NULL; - if ((cred->po->openmodes & (O_READ|O_WRITE)) == (O_READ|O_WRITE)) + if ((flags & (O_READ|O_WRITE)) == (O_READ|O_WRITE) + && memobj != MACH_PORT_NULL) mach_port_mod_refs (mach_task_self (), memobj, MACH_PORT_RIGHT_SEND, 1); } -- cgit v1.2.3