summaryrefslogtreecommitdiff
path: root/libnetfs
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2013-10-17 11:20:30 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-01-12 19:17:59 +0100
commit9a7776ddef6626536f21c09090b8329168a053ce (patch)
tree66c35d03500e0040038e5cf62861cebbf4b85daf /libnetfs
parent9c2d39405c30b75bc817a6212a116421ebb927f1 (diff)
libnetfs: register passive translator startups
Detect passive translator startup and add the resulting active translator to the list of active translators. * libnetfs/dir-lookup.c (netfs_S_dir_lookup): Detect and register passive translator startup.
Diffstat (limited to 'libnetfs')
-rw-r--r--libnetfs/dir-lookup.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c
index 74351fa9..99a8746e 100644
--- a/libnetfs/dir-lookup.c
+++ b/libnetfs/dir-lookup.c
@@ -1,5 +1,5 @@
/*
- Copyright (C) 1995,96,97,98,99,2000,01,02,13
+ Copyright (C) 1995,96,97,98,99,2000,01,02,13,14
Free Software Foundation, Inc.
Written by Michael I. Bushnell, p/BSG.
@@ -67,6 +67,10 @@ netfs_S_dir_lookup (struct protid *diruser,
if (! relpath)
return ENOMEM;
+ /* Keep a pointer to the start of the filename for length
+ calculations. */
+ char *filename_start = filename;
+
*retry_port_type = MACH_MSG_TYPE_MAKE_SEND;
*do_retry = FS_RETRY_NORMAL;
*retry_name = '\0';
@@ -256,10 +260,16 @@ netfs_S_dir_lookup (struct protid *diruser,
}
}
+ boolean_t register_translator;
if (! error)
{
dirport = ports_get_send_right (newpi);
- ports_port_deref (newpi);
+
+ /* Check if an active translator is currently running. If
+ not, fshelp_fetch_root will start one. In that case, we
+ need to register it in the list of active
+ translators. */
+ register_translator = np->transbox.active == MACH_PORT_NULL;
error = fshelp_fetch_root (&np->transbox, diruser->po,
dirport,
@@ -283,9 +293,38 @@ netfs_S_dir_lookup (struct protid *diruser,
strcat (retry_name, "/");
strcat (retry_name, nextname);
}
+
+ if (register_translator)
+ {
+ char *translator_path = strdupa (relpath);
+ if (nextname != NULL)
+ {
+ /* This was not the last path component.
+ NEXTNAME points to the next component, locate
+ the end of the current component and use it
+ to trim TRANSLATOR_PATH. */
+ char *end = nextname;
+ while (*end != 0)
+ end--;
+ translator_path[end - filename_start] = '\0';
+ }
+
+ error = fshelp_set_active_translator (&newpi->pi,
+ translator_path,
+ np->transbox.active);
+ if (error)
+ {
+ ports_port_deref (newpi);
+ goto out;
+ }
+ }
+
+ ports_port_deref (newpi);
goto out;
}
+ ports_port_deref (newpi);
+
/* ENOENT means there was a hiccup, and the translator vanished
while NP was unlocked inside fshelp_fetch_root; continue as normal. */
error = 0;