From 966522f2fa9239d9c2ba08152cc7019d996c2516 Mon Sep 17 00:00:00 2001 From: Sergiu Ivanov Date: Thu, 29 Jan 2009 17:16:06 +0200 Subject: Added the function to create proxy nodes for ports Since we want netfs_S_dir_lookup to ask the client to do a retry when it sets a new dynamic translator, nsmux has to give the client a *proxy* of the port to the root of the current dynamic translator, so that the retry gets back in nsmux. For this we need to create proxy nodes for ports, which is precisely what node_create_from_port does. --- node.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ node.h | 3 +++ 2 files changed, 57 insertions(+) diff --git a/node.c b/node.c index 9786b8888..f686a0043 100644 --- a/node.c +++ b/node.c @@ -162,6 +162,60 @@ error_t node_create_proxy (lnode_t * lnode, node_t ** node) return err; } /*node_create_proxy */ +/*---------------------------------------------------------------------------*/ +/*Creates a proxy (or a shadow) node for the supplied port*/ +error_t node_create_from_port (mach_port_t port, node_t ** node) +{ + error_t err = 0; + + /*Create a new netnode */ + netnode_t * netnode_new = malloc (sizeof (netnode_t)); + + /*Reset the memory allocated for the new netnode (just in case :-) ) */ + memset (netnode_new, 0, sizeof (netnode_t)); + + /*If the memory could not be allocated */ + if (netnode_new == NULL) + err = ENOMEM; + else + { + /*create a new node from the netnode */ + node_t * node_new = netfs_make_node (netnode_new); + + /*If the creation failed */ + if (node_new == NULL) + { + /*set the error code */ + err = ENOMEM; + + /*destroy the netnode created above */ + free (netnode_new); + + /*stop */ + return err; + } + + /*this node is ``orphan'' -- it is not associated to any lnode + and has some service functions only */ + node_new->nn->lnode = NULL; + + /*setup the information in the netnode */ + node_new->nn->flags = 0; + node_new->nn->ncache_next = node_new->nn->ncache_prev = NULL; + + /*initialize the data fields dealing with positioning this node + in the dynamic translator stack */ + node_new->nn->trans_cntl = MACH_PORT_NULL; + node_new->nn->below = NULL; + + /*store the result of creation in the second parameter */ + *node = node_new; + } + + /*Return the result of operations */ + return err; +} /*node_create_from_port */ + /*---------------------------------------------------------------------------*/ /*Destroys the specified node and removes a light reference from the associated light node*/ diff --git a/node.h b/node.h index 3611945d6..89de42118 100644 --- a/node.h +++ b/node.h @@ -119,6 +119,9 @@ error_t node_create (lnode_t * lnode, node_t ** node); /*Derives a new proxy from `lnode`*/ error_t node_create_proxy (lnode_t * lnode, node_t ** node); /*---------------------------------------------------------------------------*/ +/*Creates a proxy (or a shadow) node for the supplied port*/ +error_t node_create_from_port (mach_port_t port, node_t ** node); +/*---------------------------------------------------------------------------*/ /*Destroys the specified node and removes a light reference from the associated light node*/ void node_destroy (node_t * np); -- cgit v1.2.3