[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 69/75: Fix O_DIRECTORY lookup on trivial translators
From: |
Samuel Thibault |
Subject: |
[hurd] 69/75: Fix O_DIRECTORY lookup on trivial translators |
Date: |
Thu, 14 Jan 2016 01:04:11 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch dde
in repository hurd.
commit 076957fe8c12344ddae2fa4b966c7be9be232654
Author: Flavio Cruz <address@hidden>
Date: Wed Jan 13 00:58:59 2016 +0100
Fix O_DIRECTORY lookup on trivial translators
* libdiskfs/dir-lookup.c (diskfs_S_dir_lookup): If mustbedir, make sure
entry is a directory by retrying "/", or starting the translator and
retrying "/".
* libnetfs/dir-lookup.c (netfs_S_dir_lookup): Likewise.
---
libdiskfs/dir-lookup.c | 21 +++++++++++++++------
libnetfs/dir-lookup.c | 22 ++++++++++++++++------
2 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c
index 75df9b8..8b986e4 100644
--- a/libdiskfs/dir-lookup.c
+++ b/libdiskfs/dir-lookup.c
@@ -161,7 +161,9 @@ diskfs_S_dir_lookup (struct protid *dircred,
*retry = FS_RETRY_REAUTH;
*returned_port = dircred->po->shadow_root_parent;
*returned_port_poly = MACH_MSG_TYPE_COPY_SEND;
- if (! lastcomp)
+ if (lastcomp && mustbedir) /* Trailing slash. */
+ strcpy (retryname, "/");
+ else if (!lastcomp)
strcpy (retryname, nextname);
err = 0;
goto out;
@@ -175,7 +177,9 @@ diskfs_S_dir_lookup (struct protid *dircred,
*retry = FS_RETRY_REAUTH;
*returned_port = dircred->po->root_parent;
*returned_port_poly = MACH_MSG_TYPE_COPY_SEND;
- if (!lastcomp)
+ if (lastcomp && mustbedir) /* Trailing slash. */
+ strcpy (retryname, "/");
+ else if (!lastcomp)
strcpy (retryname, nextname);
err = 0;
goto out;
@@ -213,7 +217,7 @@ diskfs_S_dir_lookup (struct protid *dircred,
/* If this is translated, start the translator (if necessary)
and return. */
- if ((((flags & O_NOTRANS) == 0) || !lastcomp)
+ if ((((flags & O_NOTRANS) == 0) || !lastcomp || mustbedir)
&& ((np->dn_stat.st_mode & S_IPTRANS)
|| S_ISFIFO (np->dn_stat.st_mode)
|| S_ISCHR (np->dn_stat.st_mode)
@@ -304,11 +308,16 @@ diskfs_S_dir_lookup (struct protid *dircred,
if (err != ENOENT)
{
*returned_port_poly = MACH_MSG_TYPE_MOVE_SEND;
- if (!lastcomp && !err)
+ if (!err)
{
char *end = strchr (retryname, '\0');
- *end++ = '/';
- strcpy (end, nextname);
+ if (mustbedir)
+ *end++ = '/'; /* Trailing slash. */
+ else if (!lastcomp) {
+ if (end != retryname)
+ *end++ = '/';
+ strcpy (end, nextname);
+ }
}
if (register_translator)
diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c
index 8b8cd6e..1fefd3f 100644
--- a/libnetfs/dir-lookup.c
+++ b/libnetfs/dir-lookup.c
@@ -128,7 +128,9 @@ netfs_S_dir_lookup (struct protid *diruser,
*do_retry = FS_RETRY_REAUTH;
*retry_port = diruser->po->shadow_root_parent;
*retry_port_type = MACH_MSG_TYPE_COPY_SEND;
- if (! lastcomp)
+ if (lastcomp && mustbedir) /* Trailing slash. */
+ strcpy (retry_name, "/");
+ else if (!lastcomp)
strcpy (retry_name, nextname);
error = 0;
pthread_mutex_unlock (&dnp->lock);
@@ -142,7 +144,9 @@ netfs_S_dir_lookup (struct protid *diruser,
*do_retry = FS_RETRY_REAUTH;
*retry_port = diruser->po->root_parent;
*retry_port_type = MACH_MSG_TYPE_COPY_SEND;
- if (!lastcomp)
+ if (lastcomp && mustbedir) /* Trailing slash. */
+ strcpy (retry_name, "/");
+ else if (!lastcomp)
strcpy (retry_name, nextname);
error = 0;
pthread_mutex_unlock (&dnp->lock);
@@ -194,7 +198,7 @@ netfs_S_dir_lookup (struct protid *diruser,
if (error)
goto out;
- if ((((flags & O_NOTRANS) == 0) || !lastcomp)
+ if ((((flags & O_NOTRANS) == 0) || !lastcomp || mustbedir)
&& ((np->nn_translated & S_IPTRANS)
|| S_ISFIFO (np->nn_translated)
|| S_ISCHR (np->nn_translated)
@@ -288,10 +292,16 @@ netfs_S_dir_lookup (struct protid *diruser,
if (error != ENOENT)
{
*retry_port_type = MACH_MSG_TYPE_MOVE_SEND;
- if (!lastcomp && !error)
+ if (!error)
{
- strcat (retry_name, "/");
- strcat (retry_name, nextname);
+ char *end = strchr (retry_name, '\0');
+ if (mustbedir)
+ *end++ = '/'; /* Trailing slash. */
+ else if (!lastcomp) {
+ if (end != retry_name)
+ *end++ = '/';
+ strcpy (end, nextname);
+ }
}
if (register_translator)
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 67/75: Fix pfinet crash, (continued)
- [hurd] 67/75: Fix pfinet crash, Samuel Thibault, 2016/01/13
- [hurd] 18/75: Drop spurious debugging or outdated changes, Samuel Thibault, 2016/01/13
- [hurd] 74/75: Merge remote-tracking branch 'incubator/dde' into dde-upstream, Samuel Thibault, 2016/01/13
- [hurd] 15/75: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd into dde, Samuel Thibault, 2016/01/13
- [hurd] 73/75: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd into dde, Samuel Thibault, 2016/01/13
- [hurd] 16/75: Add libhurd-slab, Samuel Thibault, 2016/01/13
- [hurd] 70/75: Merge remote-tracking branch 'incubator/dde' into dde-upstream, Samuel Thibault, 2016/01/13
- [hurd] 72/75: Drop devnode and libhurd-slab, now upstream, Samuel Thibault, 2016/01/13
- [hurd] 56/75: fix compiler warnings in hurd/nfs and hurd/nfsd, Samuel Thibault, 2016/01/13
- [hurd] 41/75: fix compiler warnings in hurd/libdiskfs, Samuel Thibault, 2016/01/13
- [hurd] 69/75: Fix O_DIRECTORY lookup on trivial translators,
Samuel Thibault <=
- [hurd] 47/75: fix compiler warnings in hurd/libstore, Samuel Thibault, 2016/01/13
- [hurd] 50/75: fix compiler warnings in hurd/procfs, Samuel Thibault, 2016/01/13
- [hurd] 54/75: fix compiler warnings in hurd/trans, Samuel Thibault, 2016/01/13
- [hurd] 58/75: Define IO_OUTTRAN so that term_on_pty returns a mach_port_t, Samuel Thibault, 2016/01/13
- [hurd] 49/75: fix compiler warnings in hurd/nfs and hurd/nfsd, Samuel Thibault, 2016/01/13
- [hurd] 35/75: fix compiler warnings in hurd/console-client, Samuel Thibault, 2016/01/13
- [hurd] 40/75: fix compiler warnings in hurd/isofs, Samuel Thibault, 2016/01/13
- [hurd] 57/75: Add missing libraries to fix link errors, Samuel Thibault, 2016/01/13
- [hurd] 52/75: fix compiler warnings in hurd/random, Samuel Thibault, 2016/01/13
- [hurd] 62/75: fix mach-defpager static linking, Samuel Thibault, 2016/01/13