From 6092d048183b76bfa3f84b32f8158dd8d10bd811 Mon Sep 17 00:00:00 2001 From: Ram Pai Date: Thu, 27 Mar 2008 13:06:20 +0100 Subject: [patch 1/7] vfs: mountinfo: add dentry_path() [mszeredi@suse.cz] split big patch into managable chunks Add the following functions: dentry_path() seq_dentry() These are similar to d_path() and seq_path(). But instead of calculating the path within a mount namespace, they calculate the path from the root of the filesystem to a given dentry, ignoring mounts completely. Signed-off-by: Ram Pai Signed-off-by: Miklos Szeredi Signed-off-by: Al Viro --- include/linux/dcache.h | 1 + include/linux/seq_file.h | 2 ++ 2 files changed, 3 insertions(+) (limited to 'include') diff --git a/include/linux/dcache.h b/include/linux/dcache.h index fabd16d03a2..63960033b6f 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -302,6 +302,7 @@ extern int d_validate(struct dentry *, struct dentry *); extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...); extern char *d_path(struct path *, char *, int); +extern char *dentry_path(struct dentry *, char *, int); /* Allocation counts.. */ diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index d65796dc26d..11676ccef7b 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h @@ -10,6 +10,7 @@ struct seq_operations; struct file; struct path; struct inode; +struct dentry; struct seq_file { char *buf; @@ -44,6 +45,7 @@ int seq_printf(struct seq_file *, const char *, ...) __attribute__ ((format (printf,2,3))); int seq_path(struct seq_file *, struct path *, char *); +int seq_dentry(struct seq_file *, struct dentry *, char *); int single_open(struct file *, int (*)(struct seq_file *, void *), void *); int single_release(struct inode *, struct file *); -- cgit v1.2.3 From 9d1bc60138977d9c79471b344a64f2df13b2ccef Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Thu, 27 Mar 2008 13:06:21 +0100 Subject: [patch 2/7] vfs: mountinfo: add seq_file_root() Add a new function: seq_file_root() This is similar to seq_path(), but calculates the path relative to the given root, instead of current->fs->root. If the path was unreachable from root, then modify the root parameter to reflect this. Signed-off-by: Miklos Szeredi Signed-off-by: Al Viro --- include/linux/dcache.h | 1 + include/linux/seq_file.h | 2 ++ 2 files changed, 3 insertions(+) (limited to 'include') diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 63960033b6f..cfb1627ac51 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -301,6 +301,7 @@ extern int d_validate(struct dentry *, struct dentry *); */ extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...); +extern char *__d_path(const struct path *path, struct path *root, char *, int); extern char *d_path(struct path *, char *, int); extern char *dentry_path(struct dentry *, char *, int); diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index 11676ccef7b..5b5369c3c20 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h @@ -46,6 +46,8 @@ int seq_printf(struct seq_file *, const char *, ...) int seq_path(struct seq_file *, struct path *, char *); int seq_dentry(struct seq_file *, struct dentry *, char *); +int seq_path_root(struct seq_file *m, struct path *path, struct path *root, + char *esc); int single_open(struct file *, int (*)(struct seq_file *, void *), void *); int single_release(struct inode *, struct file *); -- cgit v1.2.3 From 73cd49ecdde92fdce131938bdaff4993010d181b Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Wed, 26 Mar 2008 22:11:34 +0100 Subject: [patch 3/7] vfs: mountinfo: add mount ID Add a unique ID to each vfsmount using the IDR infrastructure. The identifiers are reused after the vfsmount is freed. Signed-off-by: Miklos Szeredi Signed-off-by: Al Viro --- include/linux/mount.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/mount.h b/include/linux/mount.h index 87b24cea186..f0dfb17ffcc 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -56,6 +56,7 @@ struct vfsmount { struct list_head mnt_slave; /* slave list entry */ struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */ struct mnt_namespace *mnt_ns; /* containing namespace */ + int mnt_id; /* mount identifier */ /* * We put mnt_count & mnt_expiry_mark at the end of struct vfsmount * to let these frequently modified fields in a separate cache line -- cgit v1.2.3 From 719f5d7f0b90ac2c8f8ca4232eb322b266fea01e Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Thu, 27 Mar 2008 13:06:23 +0100 Subject: [patch 4/7] vfs: mountinfo: add mount peer group ID Add a unique ID to each peer group using the IDR infrastructure. The identifiers are reused after the peer group dissolves. The IDR structures are protected by holding namepspace_sem for write while allocating or deallocating IDs. IDs are allocated when a previously unshared vfsmount becomes the first member of a peer group. When a new member is added to an existing group, the ID is copied from one of the old members. IDs are freed when the last member of a peer group is unshared. Setting the MNT_SHARED flag on members of a subtree is done as a separate step, after all the IDs have been allocated. This way an allocation failure can be cleaned up easilty, without affecting the propagation state. Based on design sketch by Al Viro. Signed-off-by: Miklos Szeredi Signed-off-by: Al Viro --- include/linux/mount.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/mount.h b/include/linux/mount.h index f0dfb17ffcc..b4836d58f42 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -57,6 +57,7 @@ struct vfsmount { struct vfsmount *mnt_master; /* slave is on master->mnt_slave_list */ struct mnt_namespace *mnt_ns; /* containing namespace */ int mnt_id; /* mount identifier */ + int mnt_group_id; /* peer group identifier */ /* * We put mnt_count & mnt_expiry_mark at the end of struct vfsmount * to let these frequently modified fields in a separate cache line -- cgit v1.2.3 From a1a2c409b666befc58c2db9c7fbddf200f153470 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Thu, 27 Mar 2008 13:06:24 +0100 Subject: [patch 5/7] vfs: mountinfo: allow using process root Allow /proc//mountinfo to use the root of to calculate mountpoints. - move definition of 'struct proc_mounts' to - add the process's namespace and root to this structure - pass a pointer to 'struct proc_mounts' into seq_operations In addition the following cleanups are made: - use a common open function for /proc//{mounts,mountstat} - surround namespace.c part of these proc files with #ifdef CONFIG_PROC_FS - make the seq_operations structures const Signed-off-by: Miklos Szeredi Signed-off-by: Al Viro --- include/linux/mnt_namespace.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/linux/mnt_namespace.h b/include/linux/mnt_namespace.h index 8eed44f8ca7..c078aacc811 100644 --- a/include/linux/mnt_namespace.h +++ b/include/linux/mnt_namespace.h @@ -5,6 +5,7 @@ #include #include #include +#include struct mnt_namespace { atomic_t count; @@ -14,6 +15,13 @@ struct mnt_namespace { int event; }; +struct proc_mounts { + struct seq_file m; /* must be the first element */ + struct mnt_namespace *ns; + struct path root; + int event; +}; + extern struct mnt_namespace *copy_mnt_ns(unsigned long, struct mnt_namespace *, struct fs_struct *); extern void __put_mnt_ns(struct mnt_namespace *ns); @@ -37,5 +45,8 @@ static inline void get_mnt_ns(struct mnt_namespace *ns) atomic_inc(&ns->count); } +extern const struct seq_operations mounts_op; +extern const struct seq_operations mountstats_op; + #endif #endif -- cgit v1.2.3 From 2d4d4864ac08caff5c204a752bd004eed4f08760 Mon Sep 17 00:00:00 2001 From: Ram Pai Date: Thu, 27 Mar 2008 13:06:25 +0100 Subject: [patch 6/7] vfs: mountinfo: add /proc//mountinfo [mszeredi@suse.cz] rewrite and split big patch into managable chunks /proc/mounts in its current form lacks important information: - propagation state - root of mount for bind mounts - the st_dev value used within the filesystem - identifier for each mount and it's parent It also suffers from the following problems: - not easily extendable - ambiguity of mountpoints within a chrooted environment - doesn't distinguish between filesystem dependent and independent options - doesn't distinguish between per mount and per super block options This patch introduces /proc//mountinfo which attempts to address all these deficiencies. Code shared between /proc//mounts and /proc//mountinfo is extracted into separate functions. Thanks to Al Viro for the help in getting the design right. Signed-off-by: Ram Pai Signed-off-by: Miklos Szeredi Signed-off-by: Al Viro --- include/linux/mnt_namespace.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/linux/mnt_namespace.h b/include/linux/mnt_namespace.h index c078aacc811..830bbcd449d 100644 --- a/include/linux/mnt_namespace.h +++ b/include/linux/mnt_namespace.h @@ -46,6 +46,7 @@ static inline void get_mnt_ns(struct mnt_namespace *ns) } extern const struct seq_operations mounts_op; +extern const struct seq_operations mountinfo_op; extern const struct seq_operations mountstats_op; #endif -- cgit v1.2.3