From 2a061ebb71bf7a93d5e7ed71fa13dd7005745965 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 13 Sep 1999 06:35:11 +0000 Subject: Reverted changes related to io_map_segment. --- libdiskfs/io-map.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'libdiskfs/io-map.c') 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; } -- cgit v1.2.3