kthread: use kthread_create_on_node()
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / x25 / x25_proc.c
blob7ff373792324f69b0937a5e3ce5f9fb273771f63
1 /*
2 * X.25 Packet Layer release 002
4 * This is ALPHA test software. This code may break your machine,
5 * randomly fail to work with new releases, misbehave and/or generally
6 * screw up. It might even work.
8 * This code REQUIRES 2.4 with seq_file support
10 * This module:
11 * This module is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
16 * History
17 * 2002/10/06 Arnaldo Carvalho de Melo seq_file support
20 #include <linux/init.h>
21 #include <linux/proc_fs.h>
22 #include <linux/seq_file.h>
23 #include <net/net_namespace.h>
24 #include <net/sock.h>
25 #include <net/x25.h>
27 #ifdef CONFIG_PROC_FS
29 static void *x25_seq_route_start(struct seq_file *seq, loff_t *pos)
30 __acquires(x25_route_list_lock)
32 read_lock_bh(&x25_route_list_lock);
33 return seq_list_start_head(&x25_route_list, *pos);
36 static void *x25_seq_route_next(struct seq_file *seq, void *v, loff_t *pos)
38 return seq_list_next(v, &x25_route_list, pos);
41 static void x25_seq_route_stop(struct seq_file *seq, void *v)
42 __releases(x25_route_list_lock)
44 read_unlock_bh(&x25_route_list_lock);
47 static int x25_seq_route_show(struct seq_file *seq, void *v)
49 struct x25_route *rt = list_entry(v, struct x25_route, node);
51 if (v == &x25_route_list) {
52 seq_puts(seq, "Address Digits Device\n");
53 goto out;
56 rt = v;
57 seq_printf(seq, "%-15s %-6d %-5s\n",
58 rt->address.x25_addr, rt->sigdigits,
59 rt->dev ? rt->dev->name : "???");
60 out:
61 return 0;
64 static void *x25_seq_socket_start(struct seq_file *seq, loff_t *pos)
65 __acquires(x25_list_lock)
67 read_lock_bh(&x25_list_lock);
68 return seq_hlist_start_head(&x25_list, *pos);
71 static void *x25_seq_socket_next(struct seq_file *seq, void *v, loff_t *pos)
73 return seq_hlist_next(v, &x25_list, pos);
76 static void x25_seq_socket_stop(struct seq_file *seq, void *v)
77 __releases(x25_list_lock)
79 read_unlock_bh(&x25_list_lock);
82 static int x25_seq_socket_show(struct seq_file *seq, void *v)
84 struct sock *s;
85 struct x25_sock *x25;
86 struct net_device *dev;
87 const char *devname;
89 if (v == SEQ_START_TOKEN) {
90 seq_printf(seq, "dest_addr src_addr dev lci st vs vr "
91 "va t t2 t21 t22 t23 Snd-Q Rcv-Q inode\n");
92 goto out;
95 s = sk_entry(v);
96 x25 = x25_sk(s);
98 if (!x25->neighbour || (dev = x25->neighbour->dev) == NULL)
99 devname = "???";
100 else
101 devname = x25->neighbour->dev->name;
103 seq_printf(seq, "%-10s %-10s %-5s %3.3X %d %d %d %d %3lu %3lu "
104 "%3lu %3lu %3lu %5d %5d %ld\n",
105 !x25->dest_addr.x25_addr[0] ? "*" : x25->dest_addr.x25_addr,
106 !x25->source_addr.x25_addr[0] ? "*" : x25->source_addr.x25_addr,
107 devname, x25->lci & 0x0FFF, x25->state, x25->vs, x25->vr,
108 x25->va, x25_display_timer(s) / HZ, x25->t2 / HZ,
109 x25->t21 / HZ, x25->t22 / HZ, x25->t23 / HZ,
110 sk_wmem_alloc_get(s),
111 sk_rmem_alloc_get(s),
112 s->sk_socket ? SOCK_INODE(s->sk_socket)->i_ino : 0L);
113 out:
114 return 0;
117 static void *x25_seq_forward_start(struct seq_file *seq, loff_t *pos)
118 __acquires(x25_forward_list_lock)
120 read_lock_bh(&x25_forward_list_lock);
121 return seq_list_start_head(&x25_forward_list, *pos);
124 static void *x25_seq_forward_next(struct seq_file *seq, void *v, loff_t *pos)
126 return seq_list_next(v, &x25_forward_list, pos);
129 static void x25_seq_forward_stop(struct seq_file *seq, void *v)
130 __releases(x25_forward_list_lock)
132 read_unlock_bh(&x25_forward_list_lock);
135 static int x25_seq_forward_show(struct seq_file *seq, void *v)
137 struct x25_forward *f = list_entry(v, struct x25_forward, node);
139 if (v == &x25_forward_list) {
140 seq_printf(seq, "lci dev1 dev2\n");
141 goto out;
144 f = v;
146 seq_printf(seq, "%d %-10s %-10s\n",
147 f->lci, f->dev1->name, f->dev2->name);
148 out:
149 return 0;
152 static const struct seq_operations x25_seq_route_ops = {
153 .start = x25_seq_route_start,
154 .next = x25_seq_route_next,
155 .stop = x25_seq_route_stop,
156 .show = x25_seq_route_show,
159 static const struct seq_operations x25_seq_socket_ops = {
160 .start = x25_seq_socket_start,
161 .next = x25_seq_socket_next,
162 .stop = x25_seq_socket_stop,
163 .show = x25_seq_socket_show,
166 static const struct seq_operations x25_seq_forward_ops = {
167 .start = x25_seq_forward_start,
168 .next = x25_seq_forward_next,
169 .stop = x25_seq_forward_stop,
170 .show = x25_seq_forward_show,
173 static int x25_seq_socket_open(struct inode *inode, struct file *file)
175 return seq_open(file, &x25_seq_socket_ops);
178 static int x25_seq_route_open(struct inode *inode, struct file *file)
180 return seq_open(file, &x25_seq_route_ops);
183 static int x25_seq_forward_open(struct inode *inode, struct file *file)
185 return seq_open(file, &x25_seq_forward_ops);
188 static const struct file_operations x25_seq_socket_fops = {
189 .owner = THIS_MODULE,
190 .open = x25_seq_socket_open,
191 .read = seq_read,
192 .llseek = seq_lseek,
193 .release = seq_release,
196 static const struct file_operations x25_seq_route_fops = {
197 .owner = THIS_MODULE,
198 .open = x25_seq_route_open,
199 .read = seq_read,
200 .llseek = seq_lseek,
201 .release = seq_release,
204 static const struct file_operations x25_seq_forward_fops = {
205 .owner = THIS_MODULE,
206 .open = x25_seq_forward_open,
207 .read = seq_read,
208 .llseek = seq_lseek,
209 .release = seq_release,
212 static struct proc_dir_entry *x25_proc_dir;
214 int __init x25_proc_init(void)
216 struct proc_dir_entry *p;
217 int rc = -ENOMEM;
219 x25_proc_dir = proc_mkdir("x25", init_net.proc_net);
220 if (!x25_proc_dir)
221 goto out;
223 p = proc_create("route", S_IRUGO, x25_proc_dir, &x25_seq_route_fops);
224 if (!p)
225 goto out_route;
227 p = proc_create("socket", S_IRUGO, x25_proc_dir, &x25_seq_socket_fops);
228 if (!p)
229 goto out_socket;
231 p = proc_create("forward", S_IRUGO, x25_proc_dir,
232 &x25_seq_forward_fops);
233 if (!p)
234 goto out_forward;
235 rc = 0;
237 out:
238 return rc;
239 out_forward:
240 remove_proc_entry("socket", x25_proc_dir);
241 out_socket:
242 remove_proc_entry("route", x25_proc_dir);
243 out_route:
244 remove_proc_entry("x25", init_net.proc_net);
245 goto out;
248 void __exit x25_proc_exit(void)
250 remove_proc_entry("forward", x25_proc_dir);
251 remove_proc_entry("route", x25_proc_dir);
252 remove_proc_entry("socket", x25_proc_dir);
253 remove_proc_entry("x25", init_net.proc_net);
256 #else /* CONFIG_PROC_FS */
258 int __init x25_proc_init(void)
260 return 0;
263 void __exit x25_proc_exit(void)
266 #endif /* CONFIG_PROC_FS */