blob: 67bbf6e4e197b208b5fbc743fb2d315702db4981 [file] [log] [blame]
Eric W. Biederman77b14db2007-02-14 00:34:12 -08001/*
2 * /proc/sys support
3 */
Alexey Dobriyan1e0edd32008-10-17 05:07:44 +04004#include <linux/init.h>
Eric W. Biederman77b14db2007-02-14 00:34:12 -08005#include <linux/sysctl.h>
Lucas De Marchif1ecf062011-11-02 13:39:22 -07006#include <linux/poll.h>
Eric W. Biederman77b14db2007-02-14 00:34:12 -08007#include <linux/proc_fs.h>
8#include <linux/security.h>
Al Viro40401532012-02-13 03:58:52 +00009#include <linux/sched.h>
Nick Piggin34286d62011-01-07 17:49:57 +110010#include <linux/namei.h>
Al Viro40401532012-02-13 03:58:52 +000011#include <linux/mm.h>
Eric W. Biederman77b14db2007-02-14 00:34:12 -080012#include "internal.h"
13
Al Virod72f71e2009-02-20 05:58:47 +000014static const struct dentry_operations proc_sys_dentry_operations;
Eric W. Biederman77b14db2007-02-14 00:34:12 -080015static const struct file_operations proc_sys_file_operations;
Jan Engelhardt03a44822008-02-08 04:21:19 -080016static const struct inode_operations proc_sys_inode_operations;
Al Viro90434762008-07-15 08:54:06 -040017static const struct file_operations proc_sys_dir_file_operations;
18static const struct inode_operations proc_sys_dir_operations;
Eric W. Biederman77b14db2007-02-14 00:34:12 -080019
Lucas De Marchif1ecf062011-11-02 13:39:22 -070020void proc_sys_poll_notify(struct ctl_table_poll *poll)
21{
22 if (!poll)
23 return;
24
25 atomic_inc(&poll->event);
26 wake_up_interruptible(&poll->wait);
27}
28
Al Viro90434762008-07-15 08:54:06 -040029static struct inode *proc_sys_make_inode(struct super_block *sb,
30 struct ctl_table_header *head, struct ctl_table *table)
Eric W. Biederman77b14db2007-02-14 00:34:12 -080031{
32 struct inode *inode;
Al Viro90434762008-07-15 08:54:06 -040033 struct proc_inode *ei;
Eric W. Biederman77b14db2007-02-14 00:34:12 -080034
Al Viro90434762008-07-15 08:54:06 -040035 inode = new_inode(sb);
Eric W. Biederman77b14db2007-02-14 00:34:12 -080036 if (!inode)
37 goto out;
38
Christoph Hellwig85fe4022010-10-23 11:19:54 -040039 inode->i_ino = get_next_ino();
40
Al Viro90434762008-07-15 08:54:06 -040041 sysctl_head_get(head);
Eric W. Biederman77b14db2007-02-14 00:34:12 -080042 ei = PROC_I(inode);
Al Viro90434762008-07-15 08:54:06 -040043 ei->sysctl = head;
44 ei->sysctl_entry = table;
45
Eric W. Biederman77b14db2007-02-14 00:34:12 -080046 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
Al Viro90434762008-07-15 08:54:06 -040047 inode->i_mode = table->mode;
48 if (!table->child) {
49 inode->i_mode |= S_IFREG;
50 inode->i_op = &proc_sys_inode_operations;
51 inode->i_fop = &proc_sys_file_operations;
52 } else {
53 inode->i_mode |= S_IFDIR;
Miklos Szeredi6d6b77f2011-10-28 14:13:28 +020054 clear_nlink(inode);
Al Viro90434762008-07-15 08:54:06 -040055 inode->i_op = &proc_sys_dir_operations;
56 inode->i_fop = &proc_sys_dir_file_operations;
57 }
Eric W. Biederman77b14db2007-02-14 00:34:12 -080058out:
59 return inode;
60}
61
Al Viro90434762008-07-15 08:54:06 -040062static struct ctl_table *find_in_table(struct ctl_table *p, struct qstr *name)
Eric W. Biederman77b14db2007-02-14 00:34:12 -080063{
64 int len;
Eric W. Biederman2315ffa2009-04-03 03:18:02 -070065 for ( ; p->procname; p++) {
Eric W. Biederman77b14db2007-02-14 00:34:12 -080066
Al Viro90434762008-07-15 08:54:06 -040067 if (!p->procname)
Eric W. Biederman77b14db2007-02-14 00:34:12 -080068 continue;
69
Al Viro90434762008-07-15 08:54:06 -040070 len = strlen(p->procname);
Eric W. Biederman77b14db2007-02-14 00:34:12 -080071 if (len != name->len)
72 continue;
73
Al Viro90434762008-07-15 08:54:06 -040074 if (memcmp(p->procname, name->name, len) != 0)
Eric W. Biederman77b14db2007-02-14 00:34:12 -080075 continue;
76
77 /* I have a match */
Al Viro90434762008-07-15 08:54:06 -040078 return p;
Eric W. Biederman77b14db2007-02-14 00:34:12 -080079 }
80 return NULL;
81}
82
Adrian Bunk81324362008-10-03 00:33:54 +040083static struct ctl_table_header *grab_header(struct inode *inode)
Eric W. Biederman77b14db2007-02-14 00:34:12 -080084{
Al Viro90434762008-07-15 08:54:06 -040085 if (PROC_I(inode)->sysctl)
86 return sysctl_head_grab(PROC_I(inode)->sysctl);
87 else
88 return sysctl_head_next(NULL);
Eric W. Biederman77b14db2007-02-14 00:34:12 -080089}
90
91static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
92 struct nameidata *nd)
93{
Al Viro90434762008-07-15 08:54:06 -040094 struct ctl_table_header *head = grab_header(dir);
95 struct ctl_table *table = PROC_I(dir)->sysctl_entry;
96 struct ctl_table_header *h = NULL;
97 struct qstr *name = &dentry->d_name;
98 struct ctl_table *p;
Eric W. Biederman77b14db2007-02-14 00:34:12 -080099 struct inode *inode;
Al Viro90434762008-07-15 08:54:06 -0400100 struct dentry *err = ERR_PTR(-ENOENT);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800101
Al Viro90434762008-07-15 08:54:06 -0400102 if (IS_ERR(head))
103 return ERR_CAST(head);
104
105 if (table && !table->child) {
106 WARN_ON(1);
107 goto out;
108 }
109
110 table = table ? table->child : head->ctl_table;
111
112 p = find_in_table(table, name);
113 if (!p) {
114 for (h = sysctl_head_next(NULL); h; h = sysctl_head_next(h)) {
115 if (h->attached_to != table)
116 continue;
117 p = find_in_table(h->attached_by, name);
118 if (p)
119 break;
120 }
121 }
122
123 if (!p)
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800124 goto out;
125
126 err = ERR_PTR(-ENOMEM);
Al Viro90434762008-07-15 08:54:06 -0400127 inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
128 if (h)
129 sysctl_head_finish(h);
130
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800131 if (!inode)
132 goto out;
133
134 err = NULL;
Nick Pigginfb045ad2011-01-07 17:49:55 +1100135 d_set_d_op(dentry, &proc_sys_dentry_operations);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800136 d_add(dentry, inode);
137
138out:
139 sysctl_head_finish(head);
140 return err;
141}
142
Pavel Emelyanov7708bfb2008-04-29 01:02:40 -0700143static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
144 size_t count, loff_t *ppos, int write)
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800145{
Al Viro90434762008-07-15 08:54:06 -0400146 struct inode *inode = filp->f_path.dentry->d_inode;
147 struct ctl_table_header *head = grab_header(inode);
148 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
David Howells2a2da532007-10-25 15:27:40 +0100149 ssize_t error;
150 size_t res;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800151
Al Viro90434762008-07-15 08:54:06 -0400152 if (IS_ERR(head))
153 return PTR_ERR(head);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800154
155 /*
156 * At this point we know that the sysctl was not unregistered
157 * and won't be until we finish.
158 */
159 error = -EPERM;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -0700160 if (sysctl_perm(head->root, table, write ? MAY_WRITE : MAY_READ))
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800161 goto out;
162
Al Viro90434762008-07-15 08:54:06 -0400163 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
164 error = -EINVAL;
165 if (!table->proc_handler)
166 goto out;
167
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800168 /* careful: calling conventions are nasty here */
169 res = count;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700170 error = table->proc_handler(table, write, buf, &res, ppos);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800171 if (!error)
172 error = res;
173out:
174 sysctl_head_finish(head);
175
176 return error;
177}
178
Pavel Emelyanov7708bfb2008-04-29 01:02:40 -0700179static ssize_t proc_sys_read(struct file *filp, char __user *buf,
180 size_t count, loff_t *ppos)
181{
182 return proc_sys_call_handler(filp, (void __user *)buf, count, ppos, 0);
183}
184
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800185static ssize_t proc_sys_write(struct file *filp, const char __user *buf,
186 size_t count, loff_t *ppos)
187{
Pavel Emelyanov7708bfb2008-04-29 01:02:40 -0700188 return proc_sys_call_handler(filp, (void __user *)buf, count, ppos, 1);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800189}
190
Lucas De Marchif1ecf062011-11-02 13:39:22 -0700191static int proc_sys_open(struct inode *inode, struct file *filp)
192{
193 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
194
195 if (table->poll)
196 filp->private_data = proc_sys_poll_event(table->poll);
197
198 return 0;
199}
200
201static unsigned int proc_sys_poll(struct file *filp, poll_table *wait)
202{
203 struct inode *inode = filp->f_path.dentry->d_inode;
204 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
205 unsigned long event = (unsigned long)filp->private_data;
206 unsigned int ret = DEFAULT_POLLMASK;
207
208 if (!table->proc_handler)
209 goto out;
210
211 if (!table->poll)
212 goto out;
213
214 poll_wait(filp, &table->poll->wait, wait);
215
216 if (event != atomic_read(&table->poll->event)) {
217 filp->private_data = proc_sys_poll_event(table->poll);
218 ret = POLLIN | POLLRDNORM | POLLERR | POLLPRI;
219 }
220
221out:
222 return ret;
223}
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800224
225static int proc_sys_fill_cache(struct file *filp, void *dirent,
Al Viro90434762008-07-15 08:54:06 -0400226 filldir_t filldir,
227 struct ctl_table_header *head,
228 struct ctl_table *table)
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800229{
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800230 struct dentry *child, *dir = filp->f_path.dentry;
231 struct inode *inode;
232 struct qstr qname;
233 ino_t ino = 0;
234 unsigned type = DT_UNKNOWN;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800235
236 qname.name = table->procname;
237 qname.len = strlen(table->procname);
238 qname.hash = full_name_hash(qname.name, qname.len);
239
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800240 child = d_lookup(dir, &qname);
241 if (!child) {
Al Viro90434762008-07-15 08:54:06 -0400242 child = d_alloc(dir, &qname);
243 if (child) {
244 inode = proc_sys_make_inode(dir->d_sb, head, table);
245 if (!inode) {
246 dput(child);
247 return -ENOMEM;
248 } else {
Nick Pigginfb045ad2011-01-07 17:49:55 +1100249 d_set_d_op(child, &proc_sys_dentry_operations);
Al Viro90434762008-07-15 08:54:06 -0400250 d_add(child, inode);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800251 }
Al Viro90434762008-07-15 08:54:06 -0400252 } else {
253 return -ENOMEM;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800254 }
255 }
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800256 inode = child->d_inode;
Al Viro90434762008-07-15 08:54:06 -0400257 ino = inode->i_ino;
258 type = inode->i_mode >> 12;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800259 dput(child);
Al Viro90434762008-07-15 08:54:06 -0400260 return !!filldir(dirent, qname.name, qname.len, filp->f_pos, ino, type);
261}
262
263static int scan(struct ctl_table_header *head, ctl_table *table,
264 unsigned long *pos, struct file *file,
265 void *dirent, filldir_t filldir)
266{
267
Eric W. Biederman2315ffa2009-04-03 03:18:02 -0700268 for (; table->procname; table++, (*pos)++) {
Al Viro90434762008-07-15 08:54:06 -0400269 int res;
270
271 /* Can't do anything without a proc name */
272 if (!table->procname)
273 continue;
274
275 if (*pos < file->f_pos)
276 continue;
277
278 res = proc_sys_fill_cache(file, dirent, filldir, head, table);
279 if (res)
280 return res;
281
282 file->f_pos = *pos + 1;
283 }
284 return 0;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800285}
286
287static int proc_sys_readdir(struct file *filp, void *dirent, filldir_t filldir)
288{
Al Viro90434762008-07-15 08:54:06 -0400289 struct dentry *dentry = filp->f_path.dentry;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800290 struct inode *inode = dentry->d_inode;
Al Viro90434762008-07-15 08:54:06 -0400291 struct ctl_table_header *head = grab_header(inode);
292 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
293 struct ctl_table_header *h = NULL;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800294 unsigned long pos;
Al Viro90434762008-07-15 08:54:06 -0400295 int ret = -EINVAL;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800296
Al Viro90434762008-07-15 08:54:06 -0400297 if (IS_ERR(head))
298 return PTR_ERR(head);
299
300 if (table && !table->child) {
301 WARN_ON(1);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800302 goto out;
Al Viro90434762008-07-15 08:54:06 -0400303 }
304
305 table = table ? table->child : head->ctl_table;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800306
307 ret = 0;
308 /* Avoid a switch here: arm builds fail with missing __cmpdi2 */
309 if (filp->f_pos == 0) {
310 if (filldir(dirent, ".", 1, filp->f_pos,
311 inode->i_ino, DT_DIR) < 0)
312 goto out;
313 filp->f_pos++;
314 }
315 if (filp->f_pos == 1) {
316 if (filldir(dirent, "..", 2, filp->f_pos,
317 parent_ino(dentry), DT_DIR) < 0)
318 goto out;
319 filp->f_pos++;
320 }
321 pos = 2;
322
Al Viro90434762008-07-15 08:54:06 -0400323 ret = scan(head, table, &pos, filp, dirent, filldir);
324 if (ret)
325 goto out;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800326
Al Viro90434762008-07-15 08:54:06 -0400327 for (h = sysctl_head_next(NULL); h; h = sysctl_head_next(h)) {
328 if (h->attached_to != table)
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800329 continue;
Al Viro90434762008-07-15 08:54:06 -0400330 ret = scan(h, h->attached_by, &pos, filp, dirent, filldir);
331 if (ret) {
332 sysctl_head_finish(h);
333 break;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800334 }
335 }
336 ret = 1;
337out:
338 sysctl_head_finish(head);
339 return ret;
340}
341
Al Viro10556cb2011-06-20 19:28:19 -0400342static int proc_sys_permission(struct inode *inode, int mask)
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800343{
344 /*
345 * sysctl entries that are not writeable,
346 * are _NOT_ writeable, capabilities or not.
347 */
Miklos Szeredif696a362008-07-31 13:41:58 +0200348 struct ctl_table_header *head;
349 struct ctl_table *table;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800350 int error;
351
Miklos Szeredif696a362008-07-31 13:41:58 +0200352 /* Executable files are not allowed under /proc/sys/ */
353 if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))
354 return -EACCES;
355
356 head = grab_header(inode);
Al Viro90434762008-07-15 08:54:06 -0400357 if (IS_ERR(head))
358 return PTR_ERR(head);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800359
Miklos Szeredif696a362008-07-31 13:41:58 +0200360 table = PROC_I(inode)->sysctl_entry;
Al Viro90434762008-07-15 08:54:06 -0400361 if (!table) /* global root - r-xr-xr-x */
362 error = mask & MAY_WRITE ? -EACCES : 0;
363 else /* Use the permissions on the sysctl table entry */
Al Viro1fc0f782011-06-20 18:59:02 -0400364 error = sysctl_perm(head->root, table, mask & ~MAY_NOT_BLOCK);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800365
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800366 sysctl_head_finish(head);
367 return error;
368}
369
370static int proc_sys_setattr(struct dentry *dentry, struct iattr *attr)
371{
372 struct inode *inode = dentry->d_inode;
373 int error;
374
375 if (attr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID))
376 return -EPERM;
377
378 error = inode_change_ok(inode, attr);
Christoph Hellwig10257742010-06-04 11:30:02 +0200379 if (error)
380 return error;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800381
Christoph Hellwig10257742010-06-04 11:30:02 +0200382 if ((attr->ia_valid & ATTR_SIZE) &&
383 attr->ia_size != i_size_read(inode)) {
384 error = vmtruncate(inode, attr->ia_size);
385 if (error)
386 return error;
387 }
388
389 setattr_copy(inode, attr);
390 mark_inode_dirty(inode);
391 return 0;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800392}
393
Al Viro90434762008-07-15 08:54:06 -0400394static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
395{
396 struct inode *inode = dentry->d_inode;
397 struct ctl_table_header *head = grab_header(inode);
398 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
399
400 if (IS_ERR(head))
401 return PTR_ERR(head);
402
403 generic_fillattr(inode, stat);
404 if (table)
405 stat->mode = (stat->mode & S_IFMT) | table->mode;
406
407 sysctl_head_finish(head);
408 return 0;
409}
410
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800411static const struct file_operations proc_sys_file_operations = {
Lucas De Marchif1ecf062011-11-02 13:39:22 -0700412 .open = proc_sys_open,
413 .poll = proc_sys_poll,
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800414 .read = proc_sys_read,
415 .write = proc_sys_write,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200416 .llseek = default_llseek,
Al Viro90434762008-07-15 08:54:06 -0400417};
418
419static const struct file_operations proc_sys_dir_file_operations = {
Pavel Emelyanov887df072011-11-02 13:38:42 -0700420 .read = generic_read_dir,
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800421 .readdir = proc_sys_readdir,
Christoph Hellwig3222a3e2008-09-03 21:53:01 +0200422 .llseek = generic_file_llseek,
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800423};
424
Jan Engelhardt03a44822008-02-08 04:21:19 -0800425static const struct inode_operations proc_sys_inode_operations = {
Al Viro90434762008-07-15 08:54:06 -0400426 .permission = proc_sys_permission,
427 .setattr = proc_sys_setattr,
428 .getattr = proc_sys_getattr,
429};
430
431static const struct inode_operations proc_sys_dir_operations = {
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800432 .lookup = proc_sys_lookup,
433 .permission = proc_sys_permission,
434 .setattr = proc_sys_setattr,
Al Viro90434762008-07-15 08:54:06 -0400435 .getattr = proc_sys_getattr,
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800436};
437
438static int proc_sys_revalidate(struct dentry *dentry, struct nameidata *nd)
439{
Nick Piggin34286d62011-01-07 17:49:57 +1100440 if (nd->flags & LOOKUP_RCU)
441 return -ECHILD;
Al Viro90434762008-07-15 08:54:06 -0400442 return !PROC_I(dentry->d_inode)->sysctl->unregistering;
443}
444
Nick Pigginfe15ce42011-01-07 17:49:23 +1100445static int proc_sys_delete(const struct dentry *dentry)
Al Viro90434762008-07-15 08:54:06 -0400446{
447 return !!PROC_I(dentry->d_inode)->sysctl->unregistering;
448}
449
Nick Piggin621e1552011-01-07 17:49:27 +1100450static int proc_sys_compare(const struct dentry *parent,
451 const struct inode *pinode,
452 const struct dentry *dentry, const struct inode *inode,
453 unsigned int len, const char *str, const struct qstr *name)
Al Viro90434762008-07-15 08:54:06 -0400454{
Al Virodfef6dc2011-03-08 01:25:28 -0500455 struct ctl_table_header *head;
Nick Piggin31e6b012011-01-07 17:49:52 +1100456 /* Although proc doesn't have negative dentries, rcu-walk means
457 * that inode here can be NULL */
Al Virodfef6dc2011-03-08 01:25:28 -0500458 /* AV: can it, indeed? */
Nick Piggin31e6b012011-01-07 17:49:52 +1100459 if (!inode)
Al Virodfef6dc2011-03-08 01:25:28 -0500460 return 1;
Nick Piggin621e1552011-01-07 17:49:27 +1100461 if (name->len != len)
Al Viro90434762008-07-15 08:54:06 -0400462 return 1;
Nick Piggin621e1552011-01-07 17:49:27 +1100463 if (memcmp(name->name, str, len))
Al Viro90434762008-07-15 08:54:06 -0400464 return 1;
Al Virodfef6dc2011-03-08 01:25:28 -0500465 head = rcu_dereference(PROC_I(inode)->sysctl);
466 return !head || !sysctl_is_seen(head);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800467}
468
Al Virod72f71e2009-02-20 05:58:47 +0000469static const struct dentry_operations proc_sys_dentry_operations = {
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800470 .d_revalidate = proc_sys_revalidate,
Al Viro90434762008-07-15 08:54:06 -0400471 .d_delete = proc_sys_delete,
472 .d_compare = proc_sys_compare,
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800473};
474
Alexey Dobriyan1e0edd32008-10-17 05:07:44 +0400475int __init proc_sys_init(void)
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800476{
Alexey Dobriyane1675232008-10-03 00:23:32 +0400477 struct proc_dir_entry *proc_sys_root;
478
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800479 proc_sys_root = proc_mkdir("sys", NULL);
Al Viro90434762008-07-15 08:54:06 -0400480 proc_sys_root->proc_iops = &proc_sys_dir_operations;
481 proc_sys_root->proc_fops = &proc_sys_dir_file_operations;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800482 proc_sys_root->nlink = 0;
483 return 0;
484}