aboutsummaryrefslogtreecommitdiff
path: root/libdiskfs/dir-lookup.c
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2013-09-02 11:37:05 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2013-09-15 23:08:25 +0200
commit06d49cdadd9e96361f3fe49b9c940b88bb869284 (patch)
tree87f79b4aaa830c34f260c3057970b8e1d3c9fab3 /libdiskfs/dir-lookup.c
parent39e97c785a7b7f5fd5458986aa834e4069ce3b2f (diff)
downloadhurd-06d49cdadd9e96361f3fe49b9c940b88bb869284.tar.gz
hurd-06d49cdadd9e96361f3fe49b9c940b88bb869284.tar.bz2
hurd-06d49cdadd9e96361f3fe49b9c940b88bb869284.zip
libdiskfs: track file name in struct peropen
Track the relative path used to obtain a file handle in the struct peropen. * libdiskfs/diskfs.h (struct peropen): New field path. * libdiskfs/peropen-make.c (diskfs_make_peropen): Initialize path. * libdiskfs/peropen-rele.c (diskfs_release_peropen): Free path. * libdiskfs/fsys-getroot.c (diskfs_S_fsys_getroot): Initialize path. * libdiskfs/dir-lookup.c (diskfs_S_dir_lookup): Preserve the path.
Diffstat (limited to 'libdiskfs/dir-lookup.c')
-rw-r--r--libdiskfs/dir-lookup.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c
index 923be033..15a9b0cf 100644
--- a/libdiskfs/dir-lookup.c
+++ b/libdiskfs/dir-lookup.c
@@ -1,6 +1,6 @@
/* libdiskfs implementation of fs.defs:dir_lookup
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- 2002, 2008 Free Software Foundation, Inc.
+ 2002, 2008, 2013 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -41,6 +41,7 @@ diskfs_S_dir_lookup (struct protid *dircred,
struct node *np;
int nsymlink = 0;
char *nextname;
+ char *relpath;
int nextnamelen;
error_t error = 0;
char *pathbuf = 0;
@@ -68,6 +69,11 @@ diskfs_S_dir_lookup (struct protid *dircred,
while (path[0] == '/')
path++;
+ /* Preserve the path relative to diruser->po->path. */
+ relpath = strdup (path);
+ if (! relpath)
+ return ENOMEM;
+
*returned_port_poly = MACH_MSG_TYPE_MAKE_SEND;
*retry = FS_RETRY_NORMAL;
retryname[0] = '\0';
@@ -479,6 +485,22 @@ diskfs_S_dir_lookup (struct protid *dircred,
if (! error)
{
+ free (newpi->po->path);
+ if (dircred->po->path == NULL)
+ {
+ /* dircred 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", dircred->po->path, relpath);
+ }
+
+ if (! newpi->po->path)
+ error = errno;
+
*returned_port = ports_get_right (newpi);
ports_port_deref (newpi);
newpi = 0;
@@ -500,5 +522,7 @@ diskfs_S_dir_lookup (struct protid *dircred,
if (newpo)
diskfs_release_peropen (newpo);
+ free (relpath);
+
return error;
}