[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 56/87: hurd: fix semantic of file_get_children
From: |
Samuel Thibault |
Subject: |
[hurd] 56/87: hurd: fix semantic of file_get_children |
Date: |
Sun, 09 Nov 2014 11:05:04 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 334801c52c9844c06eacbe2e3af65852f7412e3c
Author: Justus Winter <address@hidden>
Date: Sun Aug 31 14:47:42 2014 +0200
hurd: fix semantic of file_get_children
When first introduced as fsys_get_children, it made sense to return
the list of children using paths relative to the root of the
filesystem that was queried. Making the get_children method part of
the fsys protocol was a mistake that has since been corrected in
9366d6b2.
Instead of returning paths relative to the root of the translator,
return paths relative to the path of the receiving node.
This fixes a problem with the mtab translator. Previously, the mtab
translator invoked on a target that was not the root directory of a
translator would compute invalid paths, e.g.:
/hurd/mtab: /any/path/servers/socket/26 No such file or directory
* hurd/fs.defs (file_get_children): Update comment.
* libfshelp/translator-list.c (fshelp_get_active_translators): Add
argument PREFIX. Filter entries not beginning with PREFIX if
non-NULL, and omit PREFIX from the returned paths.
* libfshelp/fshelp.h (fshelp_get_active_translators): Update comment
accordingly. Also clarify that both FILTER and PREFIX can be NULL.
* libdiskfs/file-get-children.c (diskfs_S_file_get_children): Update
comment, pass prefix to fshelp_get_active_translators.
* libnetfs/file-get-children.c (netfs_S_file_get_children): Likewise.
---
hurd/fs.defs | 4 ++--
libdiskfs/file-get-children.c | 9 +++++----
libfshelp/fshelp.h | 9 ++++++---
libfshelp/translator-list.c | 21 +++++++++++++++++----
libnetfs/file-get-children.c | 9 +++++----
5 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/hurd/fs.defs b/hurd/fs.defs
index 2452682..a4a48cc 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 4581e4e..98d5d60 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 5d3a0ce..1c6f04a 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 3ece711..be7ce4d 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 bd7e8fc..e8ceddf 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;
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 58/87: libdiskfs: fix /servers/exec lookup, (continued)
- [hurd] 58/87: libdiskfs: fix /servers/exec lookup, Samuel Thibault, 2014/11/09
- [hurd] 59/87: hurd: make memory_object parameter polymorphic, Samuel Thibault, 2014/11/09
- [hurd] 61/87: procfs: fix typo in comment, Samuel Thibault, 2014/11/09
- [hurd] 53/87: libtrivfs: fix typo, Samuel Thibault, 2014/11/09
- [hurd] 64/87: BSD apps want sin_zero cleared in sys_getname., Samuel Thibault, 2014/11/09
- [hurd] 60/87: trans/hello{, -mt}: properly escape contents in trivfs_append_args, Samuel Thibault, 2014/11/09
- [hurd] 66/87: exec: redzone page zero before loading anything, Samuel Thibault, 2014/11/09
- [hurd] 52/87: libdiskfs: fix reference counting of peropen objects, Samuel Thibault, 2014/11/09
- [hurd] 62/87: hurd: add symbolic name for the mtab translator, Samuel Thibault, 2014/11/09
- [hurd] 70/87: procfs: generalize the translator linkage code, Samuel Thibault, 2014/11/09
- [hurd] 56/87: hurd: fix semantic of file_get_children,
Samuel Thibault <=
- [hurd] 47/87: Make the ncursesw driver of the console client compile properly, Samuel Thibault, 2014/11/09
- [hurd] 65/87: exec: add proper argument parsing, add --device-master-port, Samuel Thibault, 2014/11/09
- [hurd] 18/87: hurd: fix type of optimal_transfer_size, Samuel Thibault, 2014/11/09
- [hurd] 50/87: sutils: add urandom device target to MAKEDEV, Samuel Thibault, 2014/11/09
- [hurd] 45/87: Revert "libpipe: fix calls to pipe_send with no data", Samuel Thibault, 2014/11/09
- [hurd] 57/87: include: detect use-after-free errors using the reference counts, Samuel Thibault, 2014/11/09
- [hurd] 73/87: libdiskfs: remove code counting cache misses, Samuel Thibault, 2014/11/09
- [hurd] 82/87: Fix dead name notification in static binaries, Samuel Thibault, 2014/11/09
- [hurd] 68/87: procfs: implement /proc/filesystems, Samuel Thibault, 2014/11/09
- [hurd] 71/87: procfs: reorganize rootdir.c, Samuel Thibault, 2014/11/09