bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH tarfs 1/6] Plumb io_map () through the backend layer


From: Sergey Bugaev
Subject: [RFC PATCH tarfs 1/6] Plumb io_map () through the backend layer
Date: Thu, 29 Apr 2021 21:57:11 +0300

---
 backend.h |  3 +++
 netfs.c   | 36 ++++++++++++++++++++++++++++++------
 tarfs.c   |  9 +++++++++
 3 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/backend.h b/backend.h
index 82bbee77b..0b281f686 100644
--- a/backend.h
+++ b/backend.h
@@ -110,6 +110,9 @@ struct fs_backend
      or S_IFCHR).  */
   error_t (* mkdev_node)   (struct node *node, mode_t type, dev_t indexes);
 
+  /* Returns memory objects for mapping this node. */
+  error_t (* io_map) (struct node *node, memory_object_t *rdobj, 
memory_object_t *wrobj);
+
   /* Free all resources associated to NODE.  */
   void (* free_node) (struct node *node);
 
diff --git a/netfs.c b/netfs.c
index 6ed7e3f39..6a6f14f94 100644
--- a/netfs.c
+++ b/netfs.c
@@ -821,14 +821,38 @@ netfs_S_file_syncfs (struct protid *user,
   return err;
 }
 
-/* The following stub has been added as a reminder.  */
-#if 0
 error_t
-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)
 {
-  error (0, 0, "Warning: io_map () not supported");
-  return EOPNOTSUPP;
+  error_t err;
+  struct node *node;
+
+  if (!user)
+    return EOPNOTSUPP;
+
+  if (!(user->po->openstat & O_READ))
+    {
+      *rdobj = MACH_PORT_NULL;
+      rdobj = NULL;
+    }
+  if (!(user->po->openstat & O_WRITE))
+    {
+      *wrobj = MACH_PORT_NULL;
+      wrobj = NULL;
+    }
+
+  if (rdobj || wrobj)
+    {
+      node = user->po->np;
+      pthread_mutex_lock (&node->lock);
+      err = backend.io_map (node, rdobj, wrobj);
+      pthread_mutex_unlock (&node->lock);
+    }
+
+  *rdobjtype = MACH_MSG_TYPE_MAKE_SEND;
+  *wrobjtype = MACH_MSG_TYPE_MAKE_SEND;
+
+  return err;
 }
-#endif
diff --git a/tarfs.c b/tarfs.c
index 1a01040a2..c1d9a5cc1 100644
--- a/tarfs.c
+++ b/tarfs.c
@@ -1010,6 +1010,14 @@ tarfs_mkdev_node (struct node *node, mode_t type, dev_t 
indexes)
   return EOPNOTSUPP;
 }
 
+error_t
+tarfs_io_map (struct node *node, memory_object_t *rdobj, memory_object_t 
*wrobj)
+{
+  error (0, 0, "Warning: io_map () not supported");
+  return EOPNOTSUPP;
+}
+
+
 
 /* Rounds SIZE to the upper RECORDSIZE.  */
 static inline size_t
@@ -1370,6 +1378,7 @@ struct fs_backend tarfs_backend =
   tarfs_link_node,
   tarfs_symlink_node,
   tarfs_mkdev_node,
+  tarfs_io_map,
 
   tarfs_free_node,
 
-- 
2.31.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]