summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergiu Ivanov <unlimitedscolobb@gmail.com>2009-01-29 17:16:06 +0200
committerSergiu Ivanov <unlimitedscolobb@gmail.com>2009-01-29 17:16:06 +0200
commit966522f2fa9239d9c2ba08152cc7019d996c2516 (patch)
treead2ccd0ed60cd3c53d7becb55f20d5cd858e332a
parentb7d7c04378644966ae873878b5485fac1a708dc9 (diff)
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.
-rw-r--r--node.c54
-rw-r--r--node.h3
2 files changed, 57 insertions, 0 deletions
diff --git a/node.c b/node.c
index 9786b8888..f686a0043 100644
--- a/node.c
+++ b/node.c
@@ -163,6 +163,60 @@ error_t node_create_proxy (lnode_t * lnode, node_t ** node)
} /*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*/
void node_destroy (node_t * np)
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);