[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] remap translator: remap prefixes instead of complete file names
From: |
Joan Lledó |
Subject: |
[PATCH] remap translator: remap prefixes instead of complete file names |
Date: |
Sun, 15 Dec 2019 19:57:43 +0100 (CET) |
From: Joan Lledó <jlledom@member.fsf.org>
* 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.
---
trans/remap.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/trans/remap.c b/trans/remap.c
index 5afbaa02..e3d5fa0a 100644
--- a/trans/remap.c
+++ b/trans/remap.c
@@ -65,19 +65,23 @@ trivfs_S_dir_lookup (struct trivfs_protid *diruser,
mach_msg_type_name_t *retry_port_type)
{
struct remap *remap;
+ char dest[NAME_MAX] = { };
if (!diruser)
return EOPNOTSUPP;
for (remap = remaps; remap; remap = remap->next)
- /* FIXME: should match just prefix of filename too */
- if (!strcmp (remap->from, filename))
+ if (!strncmp (remap->from, filename, strlen (remap->from)))
{
+ snprintf (dest, NAME_MAX, "%s%s", remap->to,
+ filename + strlen (remap->from));
+
#ifdef DEBUG
- fprintf (stderr,"replacing %s with %s\n", remap->from, remap->to);
+ fprintf (stderr, "replacing %s with %s\n", filename, dest);
fflush (stderr);
#endif
- filename = remap->to;
+
+ strncpy (filename, dest, NAME_MAX);
break;
}
--
2.20.1