[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 90/98: trans/mtab: populate mtab objects on demand
From: |
Samuel Thibault |
Subject: |
[hurd] 90/98: trans/mtab: populate mtab objects on demand |
Date: |
Tue, 14 Jan 2014 02:00:05 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 8070f62fb5240ee5b924d0dae501a50f4662ffe9
Author: Justus Winter <address@hidden>
Date: Thu Nov 14 15:36:36 2013 +0100
trans/mtab: populate mtab objects on demand
Previously the mtab content was generated in the open hook. Delay this
until the data is needed. A follow up patch will take advantage of
this to both simplify the logic in mtab_populate and make it more
robust at the same time.
* trans/mtab.c (open_hook): Do not eagerly populate the mtab.
(trivfs_S_io_read): Populate the mtab struct on demand.
(trivfs_S_io_seek): Likewise.
(trivfs_S_io_readable): Likewise.
---
trans/mtab.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/trans/mtab.c b/trans/mtab.c
index 250de7d..9b867b7 100644
--- a/trans/mtab.c
+++ b/trans/mtab.c
@@ -1,6 +1,6 @@
/* This is an mtab translator.
- Copyright (C) 2013 Free Software Foundation, Inc.
+ Copyright (C) 2013,14 Free Software Foundation, Inc.
Written by Justus Winter <address@hidden>
@@ -594,7 +594,30 @@ open_hook (struct trivfs_peropen *peropen)
mtab->contents = NULL;
mtab->contents_len = 0;
- return mtab_populate (mtab, target_path, insecure);
+ /* The mtab object is initialized, but not yet populated. We delay
+ that until that data is really needed. This avoids the following
+ problems:
+
+ Suppose you have
+
+ settrans -ac /foo /hurd/mtab /
+
+ If you now access /foo, the mtab translator will walk the tree of
+ all active translators starting from /. If it visits /foo, it
+ will talk to itself. Previously the translator migitated this by
+ comparing the control port of the translator with its own. This
+ does not work if you got two mtab translators like this:
+
+ settrans -ac /foo /hurd/mtab /
+ settrans -ac /bar /hurd/mtab /
+
+ With a single-threaded mtab server this results in a dead-lock,
+ with a multi-threaded server this will create more and more
+ threads.
+
+ Delaying the data generation until it is really needed cleanly
+ avoids these kind of problems. */
+ return 0;
}
static void
@@ -624,6 +647,14 @@ trivfs_S_io_read (struct trivfs_protid *cred,
/* Get the offset. */
op = cred->po->hook;
+
+ if (op->contents == NULL)
+ {
+ error_t err = mtab_populate (op, target_path, insecure);
+ if (err)
+ return err;
+ }
+
if (offs == -1)
offs = op->offs;
@@ -666,6 +697,13 @@ trivfs_S_io_seek (struct trivfs_protid *cred,
struct mtab *op = cred->po->hook;
+ if (op->contents == NULL)
+ {
+ error_t err = mtab_populate (op, target_path, insecure);
+ if (err)
+ return err;
+ }
+
switch (whence)
{
case SEEK_CUR:
@@ -711,6 +749,13 @@ trivfs_S_io_readable (struct trivfs_protid *cred,
struct mtab *op = cred->po->hook;
+ if (op->contents == NULL)
+ {
+ error_t err = mtab_populate (op, target_path, insecure);
+ if (err)
+ return err;
+ }
+
*amount = op->contents_len - op->offs;
return 0;
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 03/98: libports: fix the thread counts in case the thread creation fails, (continued)
- [hurd] 03/98: libports: fix the thread counts in case the thread creation fails, Samuel Thibault, 2014/01/13
- [hurd] 76/98: utils/settrans: fix the teardown of chrooted environments, Samuel Thibault, 2014/01/13
- [hurd] 16/98: libshouldbeinlibc: fix reference counting in port_name_xlator_create, Samuel Thibault, 2014/01/13
- [hurd] 95/98: libfshelp: fix the api of fshelp_set_active_translator, Samuel Thibault, 2014/01/13
- [hurd] 98/98: Merge remote-tracking branch 'upstream/master' into upstream, Samuel Thibault, 2014/01/13
- [hurd] 17/98: utils: implement portinfo --search, Samuel Thibault, 2014/01/13
- [hurd] 10/98: auth: fix use of uninitialized variable err, Samuel Thibault, 2014/01/13
- [hurd] 61/98: trans: fix transparent reauthentication in fakeroot, Samuel Thibault, 2014/01/13
- [hurd] 01/98: pfinet: fix emission on the loopback device, Samuel Thibault, 2014/01/13
- [hurd] 63/98: libfshelp: use a hash table in get-identity.c, Samuel Thibault, 2014/01/13
- [hurd] 90/98: trans/mtab: populate mtab objects on demand,
Samuel Thibault <=
- [hurd] 09/98: init: fix memory leak, Samuel Thibault, 2014/01/13
- [hurd] 88/98: libports: remove the threadvars stack size hack, Samuel Thibault, 2014/01/13
- [hurd] 02/98: Normalize whitespace at the end of each file to '\n', Samuel Thibault, 2014/01/13
- [hurd] 84/98: utils/rpctrace: handle MACH_MSG_TYPE_PORT_SEND rights in trace_and_forward, Samuel Thibault, 2014/01/13
- [hurd] 82/98: utils/rpctrace: generalize code in rewrite_right, Samuel Thibault, 2014/01/13
- [hurd] 86/98: utils/rpctrace: fix output so that replies can be attributed to requests, Samuel Thibault, 2014/01/13
- [hurd] 81/98: utils/mount: fix autodetection of fat file systems, Samuel Thibault, 2014/01/13
- [hurd] 79/98: trans/fakeroot: remove dead code, Samuel Thibault, 2014/01/13
- [hurd] 85/98: utils/rpctrace: escape non-printable characters in strings, Samuel Thibault, 2014/01/13
- [hurd] 80/98: trans/fakeroot: remove dead code, Samuel Thibault, 2014/01/13