[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 52/70: libdiskfs: track file name in struct peropen
From: |
Samuel Thibault |
Subject: |
[hurd] 52/70: libdiskfs: track file name in struct peropen |
Date: |
Mon, 16 Sep 2013 07:41:44 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 06d49cdadd9e96361f3fe49b9c940b88bb869284
Author: Justus Winter <address@hidden>
Date: Mon Sep 2 11:37:05 2013 +0200
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.
---
libdiskfs/dir-lookup.c | 26 +++++++++++++++++++++++++-
libdiskfs/diskfs.h | 3 +++
libdiskfs/fsys-getroot.c | 3 ++-
libdiskfs/peropen-make.c | 8 ++++++++
libdiskfs/peropen-rele.c | 1 +
5 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c
index 923be03..15a9b0c 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;
}
diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
index 0f9c1d3..2489517 100644
--- a/libdiskfs/diskfs.h
+++ b/libdiskfs/diskfs.h
@@ -69,6 +69,9 @@ struct peropen
mach_port_t shadow_root_parent;
/* If in a shadow tree, its root node in this translator. */
struct node *shadow_root;
+
+ /* Path relative to the root of the translator. */
+ char *path;
};
/* A unique one of these exists for each node currently in use (and
diff --git a/libdiskfs/fsys-getroot.c b/libdiskfs/fsys-getroot.c
index 2e11da4..39973a8 100644
--- a/libdiskfs/fsys-getroot.c
+++ b/libdiskfs/fsys-getroot.c
@@ -51,7 +51,8 @@ diskfs_S_fsys_getroot (fsys_t controlport,
{
root_parent: dotdot,
shadow_root_parent: MACH_PORT_NULL,
- shadow_root: _diskfs_chroot_directory ? diskfs_root_node : NULL /* XXX */
+ shadow_root: _diskfs_chroot_directory ? diskfs_root_node : NULL, /* XXX */
+ path: NULL,
};
if (!pt)
diff --git a/libdiskfs/peropen-make.c b/libdiskfs/peropen-make.c
index d37516c..b11b2ad 100644
--- a/libdiskfs/peropen-make.c
+++ b/libdiskfs/peropen-make.c
@@ -34,6 +34,7 @@ diskfs_make_peropen (struct node *np, int flags, struct
peropen *context,
po->refcnt = 0;
po->openstat = flags;
po->np = np;
+ po->path = NULL;
if (context)
{
@@ -50,6 +51,13 @@ diskfs_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;
+ }
}
else
{
diff --git a/libdiskfs/peropen-rele.c b/libdiskfs/peropen-rele.c
index 08276ec..d3f7492 100644
--- a/libdiskfs/peropen-rele.c
+++ b/libdiskfs/peropen-rele.c
@@ -45,5 +45,6 @@ diskfs_release_peropen (struct peropen *po)
diskfs_nput (po->np);
+ free (po->path);
free (po);
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 68/70: Handle notification on page eviction, (continued)
- [hurd] 68/70: Handle notification on page eviction, Samuel Thibault, 2013/09/16
- [hurd] 65/70: trans: add mtab translator, Samuel Thibault, 2013/09/16
- [hurd] 49/70: proc: remove unused file exc-reply.defs, Samuel Thibault, 2013/09/16
- [hurd] 47/70: hurd: add proc_{get,set}_code, Samuel Thibault, 2013/09/16
- [hurd] 44/70: mount: handle -t auto, Samuel Thibault, 2013/09/16
- [hurd] 55/70: libdiskfs: add fsys_get_children, Samuel Thibault, 2013/09/16
- [hurd] 18/70: libshouldbeinlibc: Add nullauth.{c,h}, Samuel Thibault, 2013/09/16
- [hurd] 39/70: libnetfs: register libnetfs-based translators as important, Samuel Thibault, 2013/09/16
- [hurd] 51/70: libihash: add HURD_IHASH_ITERATE_ITEMS macro, Samuel Thibault, 2013/09/16
- [hurd] 15/70: Define and use symbolic names for important processes, Samuel Thibault, 2013/09/16
- [hurd] 52/70: libdiskfs: track file name in struct peropen,
Samuel Thibault <=
- [hurd] 50/70: proc: Remove unused declaration of zombie_list, Samuel Thibault, 2013/09/16
- [hurd] 31/70: Merge branch 'master-merge2' into master-merge, Samuel Thibault, 2013/09/16
- [hurd] 12/70: umount: add a umount utility, Samuel Thibault, 2013/09/16
- [hurd] 10/70: sutils: allow multiple entries for the device "none", Samuel Thibault, 2013/09/16
- [hurd] 08/70: mount: implement -O, --test-opts, Samuel Thibault, 2013/09/16
- [hurd] 07/70: mount: add -f and --fake arguments, Samuel Thibault, 2013/09/16
- [hurd] 11/70: sutils: fix the semantic of -t, --types in fstab.c, Samuel Thibault, 2013/09/16
- [hurd] 42/70: trans: register symlink translators as important, Samuel Thibault, 2013/09/16
- [hurd] 33/70: Reserve RPC ID for proc_set_init_task, Samuel Thibault, 2013/09/16
- [hurd] 06/70: mount: fix mount -oremount with one parameter, Samuel Thibault, 2013/09/16