diff options
author | Joan Lledó <jlledom@member.fsf.org> | 2019-12-20 19:59:29 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2019-12-22 20:33:22 +0100 |
commit | 9f2d27d4f305efae7cbd6f537940dde3581bee74 (patch) | |
tree | d5a094d19eccefec0da7cc0fce7f33695fe6e957 /trans | |
parent | f0b177197381359ff2cb1799640244817fd3b3db (diff) | |
download | hurd-9f2d27d4f305efae7cbd6f537940dde3581bee74.tar.gz hurd-9f2d27d4f305efae7cbd6f537940dde3581bee74.tar.bz2 hurd-9f2d27d4f305efae7cbd6f537940dde3581bee74.zip |
remap translator: remap prefixes instead of complete file names
* trans/remap.c:
* trivfs_S_dir_lookup():
* Match and replace prefixes instead of complete
file names. This is needed to remap entire file
systems, not only trivial ones.
Message-Id: <20191220185911.6448-2-jlledom@mailfence.com>
Diffstat (limited to 'trans')
-rw-r--r-- | trans/remap.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/trans/remap.c b/trans/remap.c index 5afbaa02..fcd276d6 100644 --- a/trans/remap.c +++ b/trans/remap.c @@ -65,21 +65,30 @@ trivfs_S_dir_lookup (struct trivfs_protid *diruser, mach_msg_type_name_t *retry_port_type) { struct remap *remap; + string_t dest = { }; + size_t prefix_size; if (!diruser) return EOPNOTSUPP; for (remap = remaps; remap; remap = remap->next) - /* FIXME: should match just prefix of filename too */ - if (!strcmp (remap->from, filename)) - { + { + prefix_size = strlen (remap->from); + if (!strncmp (remap->from, filename, prefix_size) + && (filename[prefix_size] == '\0' || filename[prefix_size] == '/')) + { + snprintf (dest, sizeof (dest), "%s%s", remap->to, + filename + prefix_size); + #ifdef DEBUG - fprintf (stderr,"replacing %s with %s\n", remap->from, remap->to); - fflush (stderr); + fprintf (stderr, "replacing %s with %s\n", filename, dest); + fflush (stderr); #endif - filename = remap->to; - break; - } + + filename = dest; + break; + } + } *do_retry = FS_RETRY_REAUTH; *retry_port = getcrdir (); |