This source file includes following definitions.
- proc_readnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 #include <linux/autoconf.h>
28
29 #include <asm/segment.h>
30
31 #include <linux/errno.h>
32 #include <linux/sched.h>
33 #include <linux/proc_fs.h>
34 #include <linux/stat.h>
35 #include <linux/fcntl.h>
36 #include <linux/config.h>
37 #include <linux/mm.h>
38
39 static struct file_operations proc_netdir_operations = {
40 NULL,
41 NULL,
42 NULL,
43 proc_readdir,
44 NULL,
45 NULL,
46 NULL,
47 NULL,
48 NULL,
49 NULL
50 };
51
52
53
54
55 static struct inode_operations proc_netdir_inode_operations = {
56 &proc_netdir_operations,
57 NULL,
58 proc_lookup,
59 NULL,
60 NULL,
61 NULL,
62 NULL,
63 NULL,
64 NULL,
65 NULL,
66 NULL,
67 NULL,
68 NULL,
69 NULL,
70 NULL
71 };
72
73 struct proc_dir_entry proc_net = {
74 PROC_NET, 3, "net",
75 S_IFDIR | S_IRUGO | S_IXUGO, 2, 0, 0,
76 0, &proc_netdir_inode_operations,
77 NULL, NULL,
78 NULL,
79 NULL, NULL
80 };
81
82 #define PROC_BLOCK_SIZE (3*1024)
83
84 static int proc_readnet(struct inode * inode, struct file * file,
85 char * buf, int count)
86 {
87 char * page;
88 int bytes=count;
89 int copied=0;
90 char *start;
91 struct proc_dir_entry * dp;
92
93 if (count < 0)
94 return -EINVAL;
95 dp = (struct proc_dir_entry *) inode->u.generic_ip;
96 if (!(page = (char*) __get_free_page(GFP_KERNEL)))
97 return -ENOMEM;
98
99 while (bytes>0)
100 {
101 int length, thistime=bytes;
102 if (bytes > PROC_BLOCK_SIZE)
103 thistime=PROC_BLOCK_SIZE;
104
105 length = dp->get_info(page, &start,
106 file->f_pos,
107 thistime,
108 (file->f_flags & O_ACCMODE) == O_RDWR);
109
110
111
112
113
114
115
116 if (length <= 0)
117 break;
118
119
120
121 memcpy_tofs(buf+copied, start, length);
122 file->f_pos += length;
123 bytes -= length;
124 copied += length;
125 if (length<thistime)
126 break;
127 }
128 free_page((unsigned long) page);
129 return copied;
130 }
131
132 static struct file_operations proc_net_operations = {
133 NULL,
134 proc_readnet,
135 NULL,
136 NULL,
137 NULL,
138 NULL,
139 NULL,
140 NULL,
141 NULL,
142 NULL
143 };
144
145
146
147
148 struct inode_operations proc_net_inode_operations = {
149 &proc_net_operations,
150 NULL,
151 NULL,
152 NULL,
153 NULL,
154 NULL,
155 NULL,
156 NULL,
157 NULL,
158 NULL,
159 NULL,
160 NULL,
161 NULL,
162 NULL,
163 NULL
164 };