summaryrefslogtreecommitdiff
path: root/libdiskfs/io-map.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-09-13 06:35:11 +0000
committerRoland McGrath <roland@gnu.org>1999-09-13 06:35:11 +0000
commit2a061ebb71bf7a93d5e7ed71fa13dd7005745965 (patch)
treec03dbbcdb1ab820ed98049bf3ad866ca4125ae2c /libdiskfs/io-map.c
parentd5192f3ae0bc49683b16882e47d1bc39607d5363 (diff)
Reverted changes related to io_map_segment.
Diffstat (limited to 'libdiskfs/io-map.c')
-rw-r--r--libdiskfs/io-map.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/libdiskfs/io-map.c b/libdiskfs/io-map.c
index acd8adc6..6268f2c5 100644
--- a/libdiskfs/io-map.c
+++ b/libdiskfs/io-map.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1994, 1997, 1999 Free Software Foundation
+ Copyright (C) 1994, 1997 Free Software Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -28,6 +28,46 @@ diskfs_S_io_map (struct protid *cred,
memory_object_t *wrobj,
mach_msg_type_name_t *wrtype)
{
- return diskfs_S_io_map_segment (cred, 0, rdobj, rdtype, wrobj, wrtype);
+ int flags;
+ struct node *node;
+
+ if (!cred)
+ return EOPNOTSUPP;
+
+ *wrobj = *rdobj = MACH_PORT_NULL;
+
+ node = cred->po->np;
+ flags = cred->po->openstat & (O_READ | O_WRITE);
+
+ mutex_lock (&node->lock);
+ switch (flags)
+ {
+ case O_READ | O_WRITE:
+ *wrobj = *rdobj = diskfs_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);
+ if (*rdobj == MACH_PORT_NULL)
+ goto error;
+ break;
+ case O_WRITE:
+ *wrobj = diskfs_get_filemap (node, VM_PROT_WRITE);
+ if (*wrobj == MACH_PORT_NULL)
+ goto error;
+ break;
+ }
+ mutex_unlock (&node->lock);
+
+ *rdtype = MACH_MSG_TYPE_MOVE_SEND;
+ *wrtype = MACH_MSG_TYPE_MOVE_SEND;
+
+ return 0;
+
+error:
+ mutex_unlock (&node->lock);
+ return errno;
}