aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/base.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r--fs/proc/base.c116
1 files changed, 1 insertions, 115 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 851ba3dcdc29..a1dddda999f2 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -101,7 +101,7 @@
101struct pid_entry { 101struct pid_entry {
102 char *name; 102 char *name;
103 int len; 103 int len;
104 mode_t mode; 104 umode_t mode;
105 const struct inode_operations *iop; 105 const struct inode_operations *iop;
106 const struct file_operations *fop; 106 const struct file_operations *fop;
107 union proc_op op; 107 union proc_op op;
@@ -631,120 +631,6 @@ static const struct inode_operations proc_def_inode_operations = {
631 .setattr = proc_setattr, 631 .setattr = proc_setattr,
632}; 632};
633 633
634static int mounts_open_common(struct inode *inode, struct file *file,
635 const struct seq_operations *op)
636{
637 struct task_struct *task = get_proc_task(inode);
638 struct nsproxy *nsp;
639 struct mnt_namespace *ns = NULL;
640 struct path root;
641 struct proc_mounts *p;
642 int ret = -EINVAL;
643
644 if (task) {
645 rcu_read_lock();
646 nsp = task_nsproxy(task);
647 if (nsp) {
648 ns = nsp->mnt_ns;
649 if (ns)
650 get_mnt_ns(ns);
651 }
652 rcu_read_unlock();
653 if (ns && get_task_root(task, &root) == 0)
654 ret = 0;
655 put_task_struct(task);
656 }
657
658 if (!ns)
659 goto err;
660 if (ret)
661 goto err_put_ns;
662
663 ret = -ENOMEM;
664 p = kmalloc(sizeof(struct proc_mounts), GFP_KERNEL);
665 if (!p)
666 goto err_put_path;
667
668 file->private_data = &p->m;
669 ret = seq_open(file, op);
670 if (ret)
671 goto err_free;
672
673 p->m.private = p;
674 p->ns = ns;
675 p->root = root;
676 p->m.poll_event = ns->event;
677
678 return 0;
679
680 err_free:
681 kfree(p);
682 err_put_path:
683 path_put(&root);
684 err_put_ns:
685 put_mnt_ns(ns);
686 err:
687 return ret;
688}
689
690static int mounts_release(struct inode *inode, struct file *file)
691{
692 struct proc_mounts *p = file->private_data;
693 path_put(&p->root);
694 put_mnt_ns(p->ns);
695 return seq_release(inode, file);
696}
697
698static unsigned mounts_poll(struct file *file, poll_table *wait)
699{
700 struct proc_mounts *p = file->private_data;
701 unsigned res = POLLIN | POLLRDNORM;
702
703 poll_wait(file, &p->ns->poll, wait);
704 if (mnt_had_events(p))
705 res |= POLLERR | POLLPRI;
706
707 return res;
708}
709
710static int mounts_open(struct inode *inode, struct file *file)
711{
712 return mounts_open_common(inode, file, &mounts_op);
713}
714
715static const struct file_operations proc_mounts_operations = {
716 .open = mounts_open,
717 .read = seq_read,
718 .llseek = seq_lseek,
719 .release = mounts_release,
720 .poll = mounts_poll,
721};
722
723static int mountinfo_open(struct inode *inode, struct file *file)
724{
725 return mounts_open_common(inode, file, &mountinfo_op);
726}
727
728static const struct file_operations proc_mountinfo_operations = {
729 .open = mountinfo_open,
730 .read = seq_read,
731 .llseek = seq_lseek,
732 .release = mounts_release,
733 .poll = mounts_poll,
734};
735
736static int mountstats_open(struct inode *inode, struct file *file)
737{
738 return mounts_open_common(inode, file, &mountstats_op);
739}
740
741static const struct file_operations proc_mountstats_operations = {
742 .open = mountstats_open,
743 .read = seq_read,
744 .llseek = seq_lseek,
745 .release = mounts_release,
746};
747
748#define PROC_BLOCK_SIZE (3*1024) /* 4K page size but our output routines use some slack for overruns */ 634#define PROC_BLOCK_SIZE (3*1024) /* 4K page size but our output routines use some slack for overruns */
749 635
750static ssize_t proc_info_read(struct file * file, char __user * buf, 636static ssize_t proc_info_read(struct file * file, char __user * buf,