From: Miklos Szeredi Currently getcwd(2) on a detached mount will give a garbled result: > mkdir /mnt/foo > mount --bind /etc /mnt/foo > cd /mnt/foo/skel > /bin/pwd /mnt/foo/skel > umount -l /mnt/foo > /bin/pwd etcskel After the patch it will give a much saner "/skel" result. Thanks to John Johansen for pointing out this bug. Signed-off-by: Miklos Szeredi CC: John Johansen --- fs/dcache.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) Index: linux-2.6/fs/dcache.c =================================================================== --- linux-2.6.orig/fs/dcache.c 2008-05-29 12:46:22.000000000 +0200 +++ linux-2.6/fs/dcache.c 2008-05-29 12:46:22.000000000 +0200 @@ -1825,10 +1825,20 @@ char *__d_path(const struct path *path, return retval; global_root: - retval += 1; /* hit the slash */ - name = &dentry->d_name; - if (prepend(&retval, &buflen, name->name, name->len) != 0) - goto Elong; + /* + * If this is a root dentry, then overwrite the slash. This + * will also DTRT with pseudo filesystems which have root + * dentries named "foo:". + * + * Otherwise this is the root of a detached mount, so don't do + * anything. + */ + if (IS_ROOT(dentry)) { + retval += 1; + name = &dentry->d_name; + if (prepend(&retval, &buflen, name->name, name->len) != 0) + goto Elong; + } root->mnt = vfsmnt; root->dentry = dentry; return retval; -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/