Explorar o código

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" <ebiederm@xmission.com>
Eric W. Biederman %!s(int64=10) %!d(string=hai) anos
pai
achega
75509fd88f
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  1. 10 0
      fs/nsfs.c

+ 10 - 0
fs/nsfs.c

@@ -4,6 +4,7 @@
 #include <linux/proc_ns.h>
 #include <linux/proc_ns.h>
 #include <linux/magic.h>
 #include <linux/magic.h>
 #include <linux/ktime.h>
 #include <linux/ktime.h>
+#include <linux/seq_file.h>
 
 
 static struct vfsmount *nsfs_mnt;
 static struct vfsmount *nsfs_mnt;
 
 
@@ -136,9 +137,18 @@ out_invalid:
 	return ERR_PTR(-EINVAL);
 	return ERR_PTR(-EINVAL);
 }
 }
 
 
+static int nsfs_show_path(struct seq_file *seq, struct dentry *dentry)
+{
+	struct inode *inode = d_inode(dentry);
+	const struct proc_ns_operations *ns_ops = dentry->d_fsdata;
+
+	return seq_printf(seq, "%s:[%lu]", ns_ops->name, inode->i_ino);
+}
+
 static const struct super_operations nsfs_ops = {
 static const struct super_operations nsfs_ops = {
 	.statfs = simple_statfs,
 	.statfs = simple_statfs,
 	.evict_inode = nsfs_evict,
 	.evict_inode = nsfs_evict,
+	.show_path = nsfs_show_path,
 };
 };
 static struct dentry *nsfs_mount(struct file_system_type *fs_type,
 static struct dentry *nsfs_mount(struct file_system_type *fs_type,
 			int flags, const char *dev_name, void *data)
 			int flags, const char *dev_name, void *data)