mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
vfs: take /proc/*/mounts and friends to fs/proc_namespace.c
rationale: that stuff is far tighter bound to fs/namespace.c than to the guts of procfs proper. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
3a2393d71d
commit
0226f4923f
6 changed files with 368 additions and 351 deletions
114
fs/proc/base.c
114
fs/proc/base.c
|
@ -631,120 +631,6 @@ static const struct inode_operations proc_def_inode_operations = {
|
|||
.setattr = proc_setattr,
|
||||
};
|
||||
|
||||
static int mounts_open_common(struct inode *inode, struct file *file,
|
||||
const struct seq_operations *op)
|
||||
{
|
||||
struct task_struct *task = get_proc_task(inode);
|
||||
struct nsproxy *nsp;
|
||||
struct mnt_namespace *ns = NULL;
|
||||
struct path root;
|
||||
struct proc_mounts *p;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (task) {
|
||||
rcu_read_lock();
|
||||
nsp = task_nsproxy(task);
|
||||
if (nsp) {
|
||||
ns = nsp->mnt_ns;
|
||||
if (ns)
|
||||
get_mnt_ns(ns);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
if (ns && get_task_root(task, &root) == 0)
|
||||
ret = 0;
|
||||
put_task_struct(task);
|
||||
}
|
||||
|
||||
if (!ns)
|
||||
goto err;
|
||||
if (ret)
|
||||
goto err_put_ns;
|
||||
|
||||
ret = -ENOMEM;
|
||||
p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL);
|
||||
if (!p)
|
||||
goto err_put_path;
|
||||
|
||||
file->private_data = &p->m;
|
||||
ret = seq_open(file, op);
|
||||
if (ret)
|
||||
goto err_free;
|
||||
|
||||
p->m.private = p;
|
||||
p->ns = ns;
|
||||
p->root = root;
|
||||
p->m.poll_event = ns->event;
|
||||
|
||||
return 0;
|
||||
|
||||
err_free:
|
||||
kfree(p);
|
||||
err_put_path:
|
||||
path_put(&root);
|
||||
err_put_ns:
|
||||
put_mnt_ns(ns);
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mounts_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
struct proc_mounts *p = file->private_data;
|
||||
path_put(&p->root);
|
||||
put_mnt_ns(p->ns);
|
||||
return seq_release(inode, file);
|
||||
}
|
||||
|
||||
static unsigned mounts_poll(struct file *file, poll_table *wait)
|
||||
{
|
||||
struct proc_mounts *p = file->private_data;
|
||||
unsigned res = POLLIN | POLLRDNORM;
|
||||
|
||||
poll_wait(file, &p->ns->poll, wait);
|
||||
if (mnt_had_events(p))
|
||||
res |= POLLERR | POLLPRI;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static int mounts_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return mounts_open_common(inode, file, &mounts_op);
|
||||
}
|
||||
|
||||
static const struct file_operations proc_mounts_operations = {
|
||||
.open = mounts_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = mounts_release,
|
||||
.poll = mounts_poll,
|
||||
};
|
||||
|
||||
static int mountinfo_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return mounts_open_common(inode, file, &mountinfo_op);
|
||||
}
|
||||
|
||||
static const struct file_operations proc_mountinfo_operations = {
|
||||
.open = mountinfo_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = mounts_release,
|
||||
.poll = mounts_poll,
|
||||
};
|
||||
|
||||
static int mountstats_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
return mounts_open_common(inode, file, &mountstats_op);
|
||||
}
|
||||
|
||||
static const struct file_operations proc_mountstats_operations = {
|
||||
.open = mountstats_open,
|
||||
.read = seq_read,
|
||||
.llseek = seq_lseek,
|
||||
.release = mounts_release,
|
||||
};
|
||||
|
||||
#define PROC_BLOCK_SIZE (3*1024) /* 4K page size but our output routines use some slack for overruns */
|
||||
|
||||
static ssize_t proc_info_read(struct file * file, char __user * buf,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue