diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2001-10-31 01:14:17 +0100 |
---|---|---|
committer | Joan Lledó <jlledom@member.fsf.org> | 2021-11-21 11:40:17 +0100 |
commit | 503ffa1918fc90db58a6d224961be442fd3b881b (patch) | |
tree | cbe698ca3b5716c4d1f0c3720538bb532b71deac | |
parent | 1986629e8dcfdacf372b8b222facd465e5d1eceb (diff) |
libnetfs: Implement RPC: io_map
* libnetfs/iostubs.c: implement io_map
-rw-r--r-- | libnetfs/iostubs.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/libnetfs/iostubs.c b/libnetfs/iostubs.c index a5ff4504..df48f8b7 100644 --- a/libnetfs/iostubs.c +++ b/libnetfs/iostubs.c @@ -1,4 +1,4 @@ -/* +/* Copyright (C) 1995 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. @@ -23,11 +23,51 @@ #include "io_S.h" error_t __attribute__((weak)) -netfs_S_io_map (struct protid *user, +netfs_S_io_map (struct protid *user, mach_port_t *rdobj, mach_msg_type_name_t *rdobjtype, mach_port_t *wrobj, mach_msg_type_name_t *wrobjtype) { - return EOPNOTSUPP; + int flags; + struct node *node; + + if (!user) + return EOPNOTSUPP; + + *wrobj = *rdobj = MACH_PORT_NULL; + + node = user->po->np; + flags = user->po->openstat & (O_READ | O_WRITE); + + pthread_mutex_lock (&node->lock); + switch (flags) + { + case O_READ | O_WRITE: + *wrobj = *rdobj = netfs_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 = netfs_get_filemap (node, VM_PROT_READ); + if (*rdobj == MACH_PORT_NULL) + goto error; + break; + case O_WRITE: + *wrobj = netfs_get_filemap (node, VM_PROT_WRITE); + if (*wrobj == MACH_PORT_NULL) + goto error; + break; + } + pthread_mutex_unlock (&node->lock); + + *rdobjtype = MACH_MSG_TYPE_MOVE_SEND; + *wrobjtype = MACH_MSG_TYPE_MOVE_SEND; + + return 0; + +error: + pthread_mutex_unlock (&node->lock); + return errno; } error_t __attribute__((weak)) |