diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2021-12-19 12:26:46 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-12-25 21:31:57 +0100 |
commit | 6f68c39ee5f08410936ba7e8cc3a15f120cec05c (patch) | |
tree | ad092c5cc7713ac794a150fc7ab8bda96d055d30 /libnetfs | |
parent | 6f4426fb7cc3ed01ad6a1e752f4ed96b98cb0525 (diff) | |
download | hurd-6f68c39ee5f08410936ba7e8cc3a15f120cec05c.tar.gz hurd-6f68c39ee5f08410936ba7e8cc3a15f120cec05c.tar.bz2 hurd-6f68c39ee5f08410936ba7e8cc3a15f120cec05c.zip |
libnetfs: Implement RPC: io_map
* libnetfs/iostubs.c: implement io_map
Message-Id: <20211219112647.11512-3-jlledom@mailfence.com>
Diffstat (limited to 'libnetfs')
-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)) |