summaryrefslogtreecommitdiff
path: root/storeio
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1997-07-17 20:10:39 +0000
committerMiles Bader <miles@gnu.org>1997-07-17 20:10:39 +0000
commit04301b2623ccdf8e43b2ee860a49457c7eb40105 (patch)
tree65b0bd74d54accf88e9915fae0c60e4cd1c9dd46 /storeio
parent499950fff2084508d656146114be898d94b76e2e (diff)
(trivfs_S_io_map):
Pass PROT argument to dev_get_memory_object.
Diffstat (limited to 'storeio')
-rw-r--r--storeio/io.c15
1 files changed, 10 insertions, 5 deletions
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);
}