Commit 430d81ac authored by Miklos Szeredi's avatar Miklos Szeredi Committed by James Toy

"vfs: fix d_path() for unreachable paths" prefixes unreachable paths

with "(unreachable)" in the result of getcwd(2), /proc/*/mounts,
/proc/*/cwd, /proc/*/fd/*, etc...

Hugh Dickins reported that an old version of gnome-vfs-daemon crashes
because it finds an entry in /proc/mounts where the mountpoint is
unreachable.

This patch reverts /proc/mounts to the old behavior (or rather a less
crazy version of the old behavior).
Reported-by: default avatarHugh Dickins <hugh.dickins@tiscali.co.uk>
Reported-by: default avatarValdis Kletnieks <Valdis.Kletnieks@vt.edu>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Andreas Gruenbacher <agruen@suse.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 4d3bdc0a
......@@ -789,6 +789,61 @@ static void show_type(struct seq_file *m, struct super_block *sb)
}
}
/*
* Same as d_path() except it doesn't stick "(unreachable)" in front
* of unreachable paths.
*/
static char *d_path_compat(struct path *path, char *buf, int buflen)
{
char *res;
struct path root;
struct path tmp;
read_lock(&current->fs->lock);
root = current->fs->root;
path_get(&root);
read_unlock(&current->fs->lock);
spin_lock(&dcache_lock);
tmp = root;
res = __d_path(path, &tmp, buf, buflen);
if (!IS_ERR(res) &&
(tmp.mnt != root.mnt || tmp.dentry != root.dentry)) {
/*
* Unreachable path found, redo with the global root
* so we get a normal looking path.
*/
res = __d_path(path, &tmp, buf, buflen);
}
spin_unlock(&dcache_lock);
path_put(&root);
return res;
}
/*
* Some old programs break if /proc/mounts contains a mountpoint
* beginning with "(unreachable)". Revert this back to the old way of
* displaying the path from the global root instead.
*/
static int show_path_old(struct seq_file *m, struct path *path, char *esc)
{
char *buf;
size_t size = seq_get_buf(m, &buf);
int res = -1;
if (size) {
char *p = d_path_compat(path, buf, size);
if (!IS_ERR(p)) {
char *end = mangle_path(buf, p, esc);
if (end)
res = end - buf;
}
}
seq_commit(m, res);
return res;
}
static int show_vfsmnt(struct seq_file *m, void *v)
{
struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
......@@ -797,7 +852,7 @@ static int show_vfsmnt(struct seq_file *m, void *v)
mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
seq_putc(m, ' ');
seq_path(m, &mnt_path, " \t\n\\");
show_path_old(m, &mnt_path, " \t\n\\");
seq_putc(m, ' ');
show_type(m, mnt->mnt_sb);
seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment