[patch 5/7] vfs: mountinfo: allow using process root

Allow /proc/<pid>/mountinfo to use the root of <pid> to calculate
mountpoints.

 - move definition of 'struct proc_mounts' to <linux/mnt_namespace.h>
 - 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/<pid>/{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 <mszeredi@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Miklos Szeredi 2008-03-27 13:06:24 +01:00 committed by Al Viro
parent 719f5d7f0b
commit a1a2c409b6
3 changed files with 70 additions and 63 deletions

View file

@ -724,20 +724,21 @@ void save_mount_options(struct super_block *sb, char *options)
}
EXPORT_SYMBOL(save_mount_options);
#ifdef CONFIG_PROC_FS
/* iterator */
static void *m_start(struct seq_file *m, loff_t *pos)
{
struct mnt_namespace *n = m->private;
struct proc_mounts *p = m->private;
down_read(&namespace_sem);
return seq_list_start(&n->list, *pos);
return seq_list_start(&p->ns->list, *pos);
}
static void *m_next(struct seq_file *m, void *v, loff_t *pos)
{
struct mnt_namespace *n = m->private;
struct proc_mounts *p = m->private;
return seq_list_next(v, &n->list, pos);
return seq_list_next(v, &p->ns->list, pos);
}
static void m_stop(struct seq_file *m, void *v)
@ -794,7 +795,7 @@ static int show_vfsmnt(struct seq_file *m, void *v)
return err;
}
struct seq_operations mounts_op = {
const struct seq_operations mounts_op = {
.start = m_start,
.next = m_next,
.stop = m_stop,
@ -833,12 +834,13 @@ static int show_vfsstat(struct seq_file *m, void *v)
return err;
}
struct seq_operations mountstats_op = {
const struct seq_operations mountstats_op = {
.start = m_start,
.next = m_next,
.stop = m_stop,
.show = show_vfsstat,
};
#endif /* CONFIG_PROC_FS */
/**
* may_umount_tree - check if a mount tree is busy