Change d_path() so that it will never return a path starting with '/' if
the path doesn't lead up to the chroot directory. Also ensure that the
path returned never is the empty string: this would only occur with a lazily 
unmounted file system; return "." in that case instead.

Signed-off-by: Andreas Gruenbacher <[EMAIL PROTECTED]>

---
 fs/dcache.c |   18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1829,8 +1829,11 @@ global_root:
                        buffer++;
                        buflen++;
                }
-               if (is_slash)
+               if (is_slash) {
+                       if (*buffer == '\0')
+                               *--buffer = '.';
                        goto out;
+               }
        }
        if (buflen < namelen)
                goto Elong;
@@ -1843,18 +1846,6 @@ Elong:
        goto out;
 }
 
-static char *__connect_d_path(char *path, char *buffer)
-{
-       if (!IS_ERR(path) && *path != '/') {
-               /* Pretend that disconnected paths are hanging off the root. */
-               if (path == buffer)
-                       path = ERR_PTR(-ENAMETOOLONG);
-               else
-                       *--path = '/';
-       }
-       return path;
-}
-
 /* write full pathname into buffer and return start of pathname */
 char *d_path(struct dentry *dentry, struct vfsmount *vfsmnt, char *buf,
             int buflen)
@@ -1868,7 +1859,6 @@ char *d_path(struct dentry *dentry, stru
        root = dget(current->fs->root);
        read_unlock(&current->fs->lock);
        res = __d_path(dentry, vfsmnt, root, rootmnt, buf, buflen, 0);
-       res = __connect_d_path(res, buf);
        dput(root);
        mntput(rootmnt);
        return res;

-- 
Andreas Gruenbacher <[EMAIL PROTECTED]>
SUSE Labs, SUSE LINUX Products GmbH
GF: Markus Rex, HRB 16746 (AG Nuernberg)

GPG: AF77 FAD1 1819 D442 400F  4BC8 409A 6903 4FDD EE02

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to