summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hurd/fs.defs4
-rw-r--r--libdiskfs/file-get-children.c9
-rw-r--r--libfshelp/fshelp.h9
-rw-r--r--libfshelp/translator-list.c21
-rw-r--r--libnetfs/file-get-children.c9
5 files changed, 35 insertions, 17 deletions
diff --git a/hurd/fs.defs b/hurd/fs.defs
index 24526826..a4a48cc8 100644
--- a/hurd/fs.defs
+++ b/hurd/fs.defs
@@ -354,8 +354,8 @@ routine file_reparent (
out new_file: mach_port_send_t);
/* Return any active translators bound to nodes below FILE. CHILDREN
- is an argz vector containing file names relative to the root of the
- receiving translator. */
+ is an argz vector containing file names relative to the path of
+ FILE. */
routine file_get_children (
file: file_t;
RPT
diff --git a/libdiskfs/file-get-children.c b/libdiskfs/file-get-children.c
index 4581e4e0..98d5d60e 100644
--- a/libdiskfs/file-get-children.c
+++ b/libdiskfs/file-get-children.c
@@ -24,9 +24,9 @@
#include <argz.h>
-/* Return any active translators bound to nodes of the receiving
- filesystem. CHILDREN is an argz vector containing file names
- relative to the root of the receiving translator. */
+/* Return any active translators bound to nodes below CRED. CHILDREN
+ is an argz vector containing file names relative to the path of
+ CRED. */
error_t
diskfs_S_file_get_children (struct protid *cred,
char **children,
@@ -79,7 +79,8 @@ diskfs_S_file_get_children (struct protid *cred,
char *c = NULL;
size_t c_len = 0;
- err = fshelp_get_active_translators (&c, &c_len, check_access);
+ err = fshelp_get_active_translators (&c, &c_len, check_access,
+ cred->po->path);
if (err)
goto errout;
diff --git a/libfshelp/fshelp.h b/libfshelp/fshelp.h
index 5d3a0ceb..1c6f04a2 100644
--- a/libfshelp/fshelp.h
+++ b/libfshelp/fshelp.h
@@ -61,12 +61,15 @@ fshelp_remove_active_translator (mach_port_t active);
included in the list. */
typedef error_t (*fshelp_filter) (const char *path);
-/* Records the list of active translators into the argz vector
- specified by TRANSLATORS filtered by FILTER. */
+/* Records the list of active translators below PREFIX into the argz
+ vector specified by TRANSLATORS filtered by FILTER. If PREFIX is
+ NULL, entries with any prefix are considered. If FILTER is NULL,
+ no filter is applied. */
error_t
fshelp_get_active_translators (char **translators,
size_t *translators_len,
- fshelp_filter filter);
+ fshelp_filter filter,
+ const char *prefix);
/* Passive translator linkage */
diff --git a/libfshelp/translator-list.c b/libfshelp/translator-list.c
index 3ece7112..be7ce4de 100644
--- a/libfshelp/translator-list.c
+++ b/libfshelp/translator-list.c
@@ -160,19 +160,32 @@ fshelp_remove_active_translator (mach_port_t active)
return err;
}
-/* Records the list of active translators into the argz vector
- specified by TRANSLATORS filtered by FILTER. */
+/* Records the list of active translators below PREFIX into the argz
+ vector specified by TRANSLATORS filtered by FILTER. If PREFIX is
+ NULL, entries with any prefix are considered. If FILTER is NULL,
+ no filter is applied. */
error_t
fshelp_get_active_translators (char **translators,
size_t *translators_len,
- fshelp_filter filter)
+ fshelp_filter filter,
+ const char *prefix)
{
error_t err = 0;
pthread_mutex_lock (&translator_ihash_lock);
+ if (prefix && strlen (prefix) == 0)
+ prefix = NULL;
+
HURD_IHASH_ITERATE (&translator_ihash, value)
{
struct translator *t = value;
+
+ if (prefix != NULL
+ && (strncmp (t->name, prefix, strlen (prefix)) != 0
+ || t->name[strlen (prefix)] != '/'))
+ /* Skip this entry, as it is not below PREFIX. */
+ continue;
+
if (filter)
{
char *dir = strdup (t->name);
@@ -192,7 +205,7 @@ fshelp_get_active_translators (char **translators,
}
err = argz_add (translators, translators_len,
- t->name);
+ &t->name[prefix? strlen (prefix) + 1: 0]);
if (err)
break;
}
diff --git a/libnetfs/file-get-children.c b/libnetfs/file-get-children.c
index bd7e8fcf..e8ceddf3 100644
--- a/libnetfs/file-get-children.c
+++ b/libnetfs/file-get-children.c
@@ -24,9 +24,9 @@
#include <argz.h>
-/* Return any active translators bound to nodes of the receiving
- filesystem. CHILDREN is an argz vector containing file names
- relative to the root of the receiving translator. */
+/* Return any active translators bound to nodes below CRED. CHILDREN
+ is an argz vector containing file names relative to the path of
+ CRED. */
error_t
netfs_S_file_get_children (struct protid *cred,
char **children,
@@ -93,7 +93,8 @@ netfs_S_file_get_children (struct protid *cred,
char *c = NULL;
size_t c_len = 0;
- err = fshelp_get_active_translators (&c, &c_len, check_access);
+ err = fshelp_get_active_translators (&c, &c_len, check_access,
+ cred->po->path);
if (err)
goto errout;