]> Pileus Git - ~andy/linux/blobdiff - fs/dcache.c
vfs: In d_path don't call d_dname on a mount point
[~andy/linux] / fs / dcache.c
index 4bdb300b16e2e940bab8eeb07417b7f87914815f..f7282ebf1a37dde6e6c62a80d6049c895dd4c36c 100644 (file)
@@ -3061,8 +3061,13 @@ char *d_path(const struct path *path, char *buf, int buflen)
         * thus don't need to be hashed.  They also don't need a name until a
         * user wants to identify the object in /proc/pid/fd/.  The little hack
         * below allows us to generate a name for these objects on demand:
+        *
+        * Some pseudo inodes are mountable.  When they are mounted
+        * path->dentry == path->mnt->mnt_root.  In that case don't call d_dname
+        * and instead have d_path return the mounted path.
         */
-       if (path->dentry->d_op && path->dentry->d_op->d_dname)
+       if (path->dentry->d_op && path->dentry->d_op->d_dname &&
+           (!IS_ROOT(path->dentry) || path->dentry != path->mnt->mnt_root))
                return path->dentry->d_op->d_dname(path->dentry, buf, buflen);
 
        rcu_read_lock();