[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 04/17] libnetfs: track file name in struct peropen
From: |
Justus Winter |
Subject: |
[PATCH 04/17] libnetfs: track file name in struct peropen |
Date: |
Fri, 19 Jul 2013 17:25:06 +0200 |
---
libnetfs/dir-lookup.c | 23 +++++++++++++++++++++++
libnetfs/fsys-getroot.c | 6 +++++-
libnetfs/make-peropen.c | 8 ++++++++
libnetfs/netfs.h | 2 ++
libnetfs/release-peropen.c | 1 +
5 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c
index f1b6438..76b86a2 100644
--- a/libnetfs/dir-lookup.c
+++ b/libnetfs/dir-lookup.c
@@ -46,6 +46,7 @@ netfs_S_dir_lookup (struct protid *diruser,
int nsymlinks = 0;
struct node *dnp, *np;
char *nextname;
+ char *relpath;
error_t error;
struct protid *newpi;
struct iouser *user;
@@ -60,6 +61,11 @@ netfs_S_dir_lookup (struct protid *diruser,
while (*filename == '/')
filename++;
+ /* Preserve the path relative to diruser->po->path. */
+ relpath = strdup (filename);
+ if (! relpath)
+ return ENOMEM;
+
*retry_port_type = MACH_MSG_TYPE_MAKE_SEND;
*do_retry = FS_RETRY_NORMAL;
*retry_name = '\0';
@@ -390,6 +396,22 @@ netfs_S_dir_lookup (struct protid *diruser,
goto out;
}
+ free (newpi->po->path);
+ if (diruser->po->path == NULL)
+ {
+ /* diruser is the root directory. */
+ newpi->po->path = relpath;
+ relpath = NULL; /* Do not free relpath. */
+ }
+ else
+ {
+ newpi->po->path = NULL;
+ asprintf (&newpi->po->path, "%s/%s", diruser->po->path, relpath);
+ }
+
+ if (! newpi->po->path)
+ error = errno;
+
*retry_port = ports_get_right (newpi);
ports_port_deref (newpi);
@@ -398,5 +420,6 @@ netfs_S_dir_lookup (struct protid *diruser,
netfs_nput (np);
if (dnp)
netfs_nrele (dnp);
+ free (relpath);
return error;
}
diff --git a/libnetfs/fsys-getroot.c b/libnetfs/fsys-getroot.c
index a1dd5e5..0d80111 100644
--- a/libnetfs/fsys-getroot.c
+++ b/libnetfs/fsys-getroot.c
@@ -43,7 +43,11 @@ netfs_S_fsys_getroot (mach_port_t cntl,
error_t err;
struct protid *newpi;
mode_t type;
- struct peropen peropen_context = { root_parent: dotdot };
+ struct peropen peropen_context =
+ {
+ root_parent: dotdot,
+ path: NULL,
+ };
if (!pt)
return EOPNOTSUPP;
diff --git a/libnetfs/make-peropen.c b/libnetfs/make-peropen.c
index 92f58da..0d46ea3 100644
--- a/libnetfs/make-peropen.c
+++ b/libnetfs/make-peropen.c
@@ -31,6 +31,7 @@ netfs_make_peropen (struct node *np, int flags, struct
peropen *context)
po->refcnt = 0;
po->openstat = flags;
po->np = np;
+ po->path = NULL;
if (context)
{
@@ -47,6 +48,13 @@ netfs_make_peropen (struct node *np, int flags, struct
peropen *context)
if (po->shadow_root_parent != MACH_PORT_NULL)
mach_port_mod_refs (mach_task_self (), po->shadow_root_parent,
MACH_PORT_RIGHT_SEND, 1);
+
+ if (context->path)
+ {
+ po->path = strdup (context->path);
+ if (! po->path)
+ return ENOMEM;
+ }
}
netfs_nref (np);
diff --git a/libnetfs/netfs.h b/libnetfs/netfs.h
index d1ebed0..2b9454a 100644
--- a/libnetfs/netfs.h
+++ b/libnetfs/netfs.h
@@ -63,6 +63,8 @@ struct peropen
mach_port_t shadow_root_parent;
/* If in a shadow tree, its root node in this translator. */
struct node *shadow_root;
+
+ char *path;
};
/* A unique one of these exists for each node currently in use. */
diff --git a/libnetfs/release-peropen.c b/libnetfs/release-peropen.c
index 3e65099..d4d3574 100644
--- a/libnetfs/release-peropen.c
+++ b/libnetfs/release-peropen.c
@@ -41,6 +41,7 @@ netfs_release_peropen (struct peropen *po)
netfs_nput (po->np);
+ free (po->path);
free (po);
}
}
--
1.7.10.4
- Re: [PATCH 10/17] hurd: add fsys_get_children, (continued)
- Re: [PATCH 10/17] hurd: add fsys_get_children, Justus Winter, 2013/07/18
- Re: [PATCH 10/17] hurd: add fsys_get_children, Samuel Thibault, 2013/07/18
- Re: [PATCH 10/17] hurd: add fsys_get_children, Neal H. Walfield, 2013/07/18
- Re: [PATCH 10/17] hurd: add fsys_get_children, Richard Braun, 2013/07/18
- feature-mtab-translator (v3), Justus Winter, 2013/07/19
- [PATCH 01/17] libnetfs: implement file_get_translator_cntl, Justus Winter, 2013/07/19
- [PATCH 02/17] pfinet: Fix call to kfree_s, Justus Winter, 2013/07/19
- Re: [PATCH 02/17] pfinet: Fix call to kfree_s, Samuel Thibault, 2013/07/20
- [PATCH 03/17] libdiskfs: track file name in struct peropen, Justus Winter, 2013/07/19
- Re: [PATCH 03/17] libdiskfs: track file name in struct peropen, Neal H. Walfield, 2013/07/22
- [PATCH 04/17] libnetfs: track file name in struct peropen,
Justus Winter <=
- [PATCH 06/17] libdiskfs: add fsys_get_children, Justus Winter, 2013/07/19
- [PATCH 05/17] libfshelp: add translator-list.c, Justus Winter, 2013/07/19
- [PATCH 08/17] libtrivfs: add fsys_get_children, Justus Winter, 2013/07/19
- [PATCH 07/17] libnetfs: add fsys_get_children, Justus Winter, 2013/07/19
- Re: [PATCH 07/17] libnetfs: add fsys_get_children, Samuel Thibault, 2013/07/22
- Re: [PATCH 07/17] libnetfs: add fsys_get_children, Pierre Thierry, 2013/07/25
- Re: [PATCH 07/17] libnetfs: add fsys_get_children, Samuel Thibault, 2013/07/25
- [PATCH 09/17] trans/symlink.c: add fsys_get_children, Justus Winter, 2013/07/19
- [PATCH 17/17] add mtab prototype, Justus Winter, 2013/07/19
- Re: [PATCH 17/17] add mtab prototype, Neal H. Walfield, 2013/07/22