[Blackfin] arch: print out list of modules if kernel is crashing and tell people...
[wrt350n-kernel.git] / fs / proc / proc_net.c
blob0afe21ee0607e6b5fe883ad5a3c93a8742d8b585
1 /*
2 * linux/fs/proc/net.c
4 * Copyright (C) 2007
6 * Author: Eric Biederman <ebiederm@xmission.com>
8 * proc net directory handling functions
9 */
11 #include <asm/uaccess.h>
13 #include <linux/errno.h>
14 #include <linux/time.h>
15 #include <linux/proc_fs.h>
16 #include <linux/stat.h>
17 #include <linux/init.h>
18 #include <linux/sched.h>
19 #include <linux/module.h>
20 #include <linux/bitops.h>
21 #include <linux/smp_lock.h>
22 #include <linux/mount.h>
23 #include <linux/nsproxy.h>
24 #include <net/net_namespace.h>
26 #include "internal.h"
29 struct proc_dir_entry *proc_net_fops_create(struct net *net,
30 const char *name, mode_t mode, const struct file_operations *fops)
32 struct proc_dir_entry *res;
34 res = create_proc_entry(name, mode, net->proc_net);
35 if (res)
36 res->proc_fops = fops;
37 return res;
39 EXPORT_SYMBOL_GPL(proc_net_fops_create);
41 void proc_net_remove(struct net *net, const char *name)
43 remove_proc_entry(name, net->proc_net);
45 EXPORT_SYMBOL_GPL(proc_net_remove);
47 struct net *get_proc_net(const struct inode *inode)
49 return maybe_get_net(PDE_NET(PDE(inode)));
51 EXPORT_SYMBOL_GPL(get_proc_net);
53 static struct proc_dir_entry *shadow_pde;
55 static struct proc_dir_entry *proc_net_shadow(struct task_struct *task,
56 struct proc_dir_entry *de)
58 return task->nsproxy->net_ns->proc_net;
61 static __net_init int proc_net_ns_init(struct net *net)
63 struct proc_dir_entry *root, *netd, *net_statd;
64 int err;
66 err = -ENOMEM;
67 root = kzalloc(sizeof(*root), GFP_KERNEL);
68 if (!root)
69 goto out;
71 err = -EEXIST;
72 netd = proc_mkdir("net", root);
73 if (!netd)
74 goto free_root;
76 err = -EEXIST;
77 net_statd = proc_mkdir("stat", netd);
78 if (!net_statd)
79 goto free_net;
81 root->data = net;
82 netd->data = net;
83 net_statd->data = net;
85 net->proc_net_root = root;
86 net->proc_net = netd;
87 net->proc_net_stat = net_statd;
88 err = 0;
90 out:
91 return err;
92 free_net:
93 remove_proc_entry("net", root);
94 free_root:
95 kfree(root);
96 goto out;
99 static __net_exit void proc_net_ns_exit(struct net *net)
101 remove_proc_entry("stat", net->proc_net);
102 remove_proc_entry("net", net->proc_net_root);
103 kfree(net->proc_net_root);
106 static struct pernet_operations __net_initdata proc_net_ns_ops = {
107 .init = proc_net_ns_init,
108 .exit = proc_net_ns_exit,
111 int __init proc_net_init(void)
113 shadow_pde = proc_mkdir("net", NULL);
114 shadow_pde->shadow_proc = proc_net_shadow;
116 return register_pernet_subsys(&proc_net_ns_ops);