summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergiu Ivanov <unlimitedscolobb@gmail.com>2008-12-12 21:28:52 +0200
committerSergiu Ivanov <unlimitedscolobb@gmail.com>2008-12-12 21:28:52 +0200
commitfd0bc23b08aa9ff76d61f753149b5e4fbf2c5a30 (patch)
tree34f6dea23e5727d2240cf4c2b69d5992c0dd543e
parenta54273639f6afd659c15326cb997922fcecfe89a (diff)
Ports in shadow nodes are opened by the translator starting routine now.
Before, netfs_S_dir_lookup used to open the ports in shadow, nodes. This could cause conflicts with the flags required by the translator starting up on the node. Now the port is opened only based on the flags requested by the translator being launched.
-rw-r--r--node.c19
-rw-r--r--node.h3
-rw-r--r--nsmux.c76
3 files changed, 64 insertions, 34 deletions
diff --git a/node.c b/node.c
index 866bd1977..f98966a45 100644
--- a/node.c
+++ b/node.c
@@ -658,10 +658,12 @@ error_t node_unlink_file (node_t * dir, char *name)
} /*node_unlink_file */
/*---------------------------------------------------------------------------*/
-/*Sets the given translators on the specified node*/
+/*Sets the given translators on the specified node. Looks up the node
+ as required by the translators being started.*/
error_t node_set_translators (struct protid * diruser, node_t * np,
char *trans, /*set these on `node` */
- size_t ntrans, int flags, mach_port_t * port)
+ size_t ntrans, int flags, char * filename,
+ mach_port_t * port)
{
error_t err;
mach_port_t p;
@@ -750,6 +752,19 @@ error_t node_set_translators (struct protid * diruser, node_t * np,
if (err)
return err;
+ /*open the ports to underlying real file as required by the
+ translator and a service port (TODO: deal with this
+ ``service'' port) */
+ np->nn->port = file_name_lookup_under
+ (diruser->po->np->nn->port, filename, flags, 0);
+ if(!np->nn->port)
+ return ENOENT;
+
+ np->nn->port_notrans = file_name_lookup_under
+ (diruser->po->np->nn->port, filename, flags | O_NOTRANS, 0);
+ if(!np->nn->port)
+ return ENOENT;
+
/*duplicate the supplied user */
err = iohelp_dup_iouser (&user, diruser->user);
if (err)
diff --git a/node.h b/node.h
index 0ab636680..0f7201083 100644
--- a/node.h
+++ b/node.h
@@ -158,7 +158,8 @@ error_t node_unlink_file (node_t * dir, char *name);
port to the topmost one opened as `flags` require*/
error_t node_set_translators (struct protid *diruser, node_t * np,
char *trans, /*set these on `node` */
- size_t ntrans, int flags, mach_port_t * port);
+ size_t ntrans, int flags, char * filename,
+ mach_port_t * port);
/*---------------------------------------------------------------------------*/
/*Kill the topmost translator for this node*/
/*This function will normally be called from netfs_attempt_lookup,
diff --git a/nsmux.c b/nsmux.c
index 5ac3c0fdf..459e03a1e 100644
--- a/nsmux.c
+++ b/nsmux.c
@@ -201,9 +201,10 @@ error_t netfs_validate_stat (struct node * np, struct iouser * cred)
}
else
{
- /*We, most probably, have something which is not a directory. Therefore
- we will open the port and close it after the stat, so that additional
- resources are not consumed. */
+ /*We, most probably, have something which is not a
+ directory. Therefore we will open the port and close
+ it after the stat, so that additional resources are
+ not consumed. */
/*the parent node of the current node */
node_t *dnp;
@@ -632,39 +633,52 @@ error_t
/*If this file is not a directory */
if (err || !S_ISDIR (stat.st_mode))
{
- /*lookup the required file with the supplied flags */
- p = file_name_lookup_under (dir->nn->port, name, flags, 0);
- if (p == MACH_PORT_NULL)
- return EBADF;
-
- /*obtain the untranslated version of the file, too (for filters) */
- p_notrans = file_name_lookup_under
- (dir->nn->port, name, O_NOTRANS, 0);
- if (p_notrans == MACH_PORT_NULL)
- return EBADF;
-
/*remember we do not have a directory */
isdir = 0;
- /*If a proxy node is not required */
if (!proxy)
- /*stop here, we want only the port to the file */
- return 0;
+ {
+ /*We don't need to do lookups here if a proxy shadow node
+ is required. The lookup will be done by the translator
+ starting procedure.*/
+ p = file_name_lookup_under (dir->nn->port, name, flags, 0);
+ if (p == MACH_PORT_NULL)
+ return EBADF;
+
+ /*obtain the untranslated version of the file, too (for filters) */
+ p_notrans = file_name_lookup_under
+ (dir->nn->port, name, O_NOTRANS, 0);
+ if (p_notrans == MACH_PORT_NULL)
+ return EBADF;
+
+ /*If a proxy node is not required */
+ if (!proxy)
+ /*stop here, we want only the port to the file */
+ return 0;
+ }
+ else
+ p = p_notrans = MACH_PORT_NULL;
}
else
{
- /*lookup the port with the right to read the contents of the
- directory */
- p = file_name_lookup_under
- (dir->nn->port, name, flags | O_READ | O_DIRECTORY, 0);
- if (p == MACH_PORT_NULL)
- return EBADF; /*not enough rights? */
-
- /*obtain the untranslated version of the file, too (for filters) */
- p_notrans = file_name_lookup_under
- (dir->nn->port, name, O_NOTRANS, 0);
- if (p_notrans == MACH_PORT_NULL)
- return EBADF;
+ if (!lastcomp || !proxy)
+ {
+ p = file_name_lookup_under
+ (dir->nn->port, name, flags | O_READ | O_DIRECTORY, 0);
+ if (p == MACH_PORT_NULL)
+ return EBADF; /*not enough rights? */
+
+ /*obtain the untranslated version of the file, too (for filters) */
+ p_notrans = file_name_lookup_under
+ (dir->nn->port, name, O_NOTRANS, 0);
+ if (p_notrans == MACH_PORT_NULL)
+ return EBADF;
+ }
+ else
+ /*If we are at the last component of the path and need to
+ open a directory, do not do the lookup; the translator
+ starting procedure will do that.*/
+ p = p_notrans = MACH_PORT_NULL;
/*we have a directory here */
isdir = 1;
@@ -1018,7 +1032,7 @@ error_t
else
{
/* Attempt a lookup on the next pathname component. */
- /*error = netfs_attempt_lookup (diruser->user, dnp, filename, &np); */
+ /*error = netfs_attempt_lookup (diruser->user, dnp, filename, &np);*/
/*attempt an improved lookup on the next pathname component */
error = netfs_attempt_lookup_improved
@@ -1039,7 +1053,7 @@ error_t
/*set the list of translators on this node */
node_set_translators
(diruser, np, np->nn->trans, np->nn->ntrans, flags,
- &file);
+ filename, &file);
/*lock the the node and add a new reference */
mutex_lock (&np->lock);