Skip to content

Commit 75509fd

Browse files
committed
nsfs: Add a show_path method to fix mountinfo
Today mountinfo displays a very unhelpful "/" for nsfs files. Add a show_path method returning the same string as ns_dname. This results in a bind mount of /proc/<pid>/ns/net showing up in /proc/<pid>/mountinfo as "net:[1234...]" instead of "/". Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 77b1a97 commit 75509fd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

fs/nsfs.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/proc_ns.h>
55
#include <linux/magic.h>
66
#include <linux/ktime.h>
7+
#include <linux/seq_file.h>
78

89
static struct vfsmount *nsfs_mnt;
910

@@ -136,9 +137,18 @@ struct file *proc_ns_fget(int fd)
136137
return ERR_PTR(-EINVAL);
137138
}
138139

140+
static int nsfs_show_path(struct seq_file *seq, struct dentry *dentry)
141+
{
142+
struct inode *inode = d_inode(dentry);
143+
const struct proc_ns_operations *ns_ops = dentry->d_fsdata;
144+
145+
return seq_printf(seq, "%s:[%lu]", ns_ops->name, inode->i_ino);
146+
}
147+
139148
static const struct super_operations nsfs_ops = {
140149
.statfs = simple_statfs,
141150
.evict_inode = nsfs_evict,
151+
.show_path = nsfs_show_path,
142152
};
143153
static struct dentry *nsfs_mount(struct file_system_type *fs_type,
144154
int flags, const char *dev_name, void *data)

0 commit comments

Comments
 (0)