bug-hurd
[Top][All Lists]
Advanced

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

[PATCH 3/4] Add the necessary infrastructure to serve passive translator


From: Justus Winter
Subject: [PATCH 3/4] Add the necessary infrastructure to serve passive translators
Date: Tue, 16 Jul 2013 10:51:22 +0200

* netfs.c (netfs_get_translator): New function.
* procfs.c (procfs_get_translator): Likewise.
* procfs.h (struct procfs_node_ops): New field get_translator.
(procfs_get_translator): New function declaration.
---
 netfs.c  |   11 +++++++++++
 procfs.c |   12 ++++++++++++
 procfs.h |    6 ++++++
 3 files changed, 29 insertions(+)

diff --git a/netfs.c b/netfs.c
index c139d11..276c57c 100644
--- a/netfs.c
+++ b/netfs.c
@@ -230,6 +230,17 @@ void netfs_node_norefs (struct node *np)
   pthread_spin_lock (&netfs_node_refcnt_lock);
 }
 
+/* The user may define this function (but should define it together
+   with netfs_set_translator).  For locked node NODE with S_IPTRANS
+   set in its mode, look up the name of its translator.  Store the
+   name into newly malloced storage, and return it in *ARGZ; set
+   *ARGZ_LEN to the total length.  */
+error_t netfs_get_translator (struct node *np, char **argz,
+                             size_t *argz_len)
+{
+  return procfs_get_translator (np, argz, argz_len);
+}
+
 
 /* Libnetfs callbacks managed with libfshelp. */
 
diff --git a/procfs.c b/procfs.c
index 96b6fd2..7507682 100644
--- a/procfs.c
+++ b/procfs.c
@@ -205,3 +205,15 @@ void procfs_cleanup (struct node *np)
 
   free (np->nn);
 }
+
+error_t procfs_get_translator (struct node *np,
+                               char **argz,
+                               size_t *argz_len)
+{
+  if (np->nn->ops->get_translator)
+    return np->nn->ops->get_translator (np->nn->hook, argz, argz_len);
+
+  *argz = NULL;
+  *argz_len = 0;
+  return 0;
+}
diff --git a/procfs.h b/procfs.h
index 64782ec..d04bbad 100644
--- a/procfs.h
+++ b/procfs.h
@@ -51,6 +51,9 @@ struct procfs_node_ops
 
   /* Destroy this node.  */
   void (*cleanup) (void *hook);
+
+  /* Get the passive translator record.  */
+  error_t (*get_translator) (void *hook, char **argz, size_t *argz_len);
 };
 
 /* These helper functions can be used as procfs_node_ops.cleanup_contents. */
@@ -91,3 +94,6 @@ error_t procfs_get_contents (struct node *np, char **data, 
ssize_t *data_len);
 error_t procfs_lookup (struct node *np, const char *name, struct node **npp);
 void procfs_cleanup (struct node *np);
 
+/* Get the passive translator record if any.  */
+error_t procfs_get_translator (struct node *np, char **argz, size_t *argz_len);
+
-- 
1.7.10.4




reply via email to

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