diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2013-07-16 10:51:22 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2013-07-20 17:55:16 +0200 |
commit | 890f987c15029d7e29f7deea0bba0b8d4ecaeaeb (patch) | |
tree | a8d6b438f9792c5fddb2c9b17fb9f18f4ddcec5f | |
parent | 641249f6b143c4e22825e18e0dbe22bb04d21138 (diff) |
Add the necessary infrastructure to serve passive translators
* 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.
-rw-r--r-- | netfs.c | 11 | ||||
-rw-r--r-- | procfs.c | 12 | ||||
-rw-r--r-- | procfs.h | 6 |
3 files changed, 29 insertions, 0 deletions
@@ -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. */ @@ -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; +} @@ -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); + |