blob: d82f4a8b4b80c1209a80bb150d2e81d8299b78fc [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>
Nick Piggin34286d62011-01-07 17:49:57 +11009#include <linux/namei.h>
Eric W. Biederman77b14db2007-02-14 00:34:12 -080010#include "internal.h"
11
Al Virod72f71e2009-02-20 05:58:47 +000012static const struct dentry_operations proc_sys_dentry_operations;
Eric W. Biederman77b14db2007-02-14 00:34:12 -080013static const struct file_operations proc_sys_file_operations;
Jan Engelhardt03a44822008-02-08 04:21:19 -080014static const struct inode_operations proc_sys_inode_operations;
Al Viro90434762008-07-15 08:54:06 -040015static const struct file_operations proc_sys_dir_file_operations;
16static const struct inode_operations proc_sys_dir_operations;
Eric W. Biederman77b14db2007-02-14 00:34:12 -080017
Lucas De Marchif1ecf062011-11-02 13:39:22 -070018void proc_sys_poll_notify(struct ctl_table_poll *poll)
19{
20 if (!poll)
21 return;
22
23 atomic_inc(&poll->event);
24 wake_up_interruptible(&poll->wait);
25}
26
Al Viro90434762008-07-15 08:54:06 -040027static struct inode *proc_sys_make_inode(struct super_block *sb,
28 struct ctl_table_header *head, struct ctl_table *table)
Eric W. Biederman77b14db2007-02-14 00:34:12 -080029{
30 struct inode *inode;
Al Viro90434762008-07-15 08:54:06 -040031 struct proc_inode *ei;
Eric W. Biederman77b14db2007-02-14 00:34:12 -080032
Al Viro90434762008-07-15 08:54:06 -040033 inode = new_inode(sb);
Eric W. Biederman77b14db2007-02-14 00:34:12 -080034 if (!inode)
35 goto out;
36
Christoph Hellwig85fe4022010-10-23 11:19:54 -040037 inode->i_ino = get_next_ino();
38
Al Viro90434762008-07-15 08:54:06 -040039 sysctl_head_get(head);
Eric W. Biederman77b14db2007-02-14 00:34:12 -080040 ei = PROC_I(inode);
Al Viro90434762008-07-15 08:54:06 -040041 ei->sysctl = head;
42 ei->sysctl_entry = table;
43
Eric W. Biederman77b14db2007-02-14 00:34:12 -080044 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
Al Viro90434762008-07-15 08:54:06 -040045 inode->i_mode = table->mode;
46 if (!table->child) {
47 inode->i_mode |= S_IFREG;
48 inode->i_op = &proc_sys_inode_operations;
49 inode->i_fop = &proc_sys_file_operations;
50 } else {
51 inode->i_mode |= S_IFDIR;
Miklos Szeredi6d6b77f2011-10-28 14:13:28 +020052 clear_nlink(inode);
Al Viro90434762008-07-15 08:54:06 -040053 inode->i_op = &proc_sys_dir_operations;
54 inode->i_fop = &proc_sys_dir_file_operations;
55 }
Eric W. Biederman77b14db2007-02-14 00:34:12 -080056out:
57 return inode;
58}
59
Al Viro90434762008-07-15 08:54:06 -040060static struct ctl_table *find_in_table(struct ctl_table *p, struct qstr *name)
Eric W. Biederman77b14db2007-02-14 00:34:12 -080061{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -070062 for ( ; p->procname; p++) {
Lucas De Marchi36885d72011-06-10 02:36:05 -030063 if (strlen(p->procname) != name->len)
Eric W. Biederman77b14db2007-02-14 00:34:12 -080064 continue;
65
Lucas De Marchi36885d72011-06-10 02:36:05 -030066 if (memcmp(p->procname, name->name, name->len) != 0)
Eric W. Biederman77b14db2007-02-14 00:34:12 -080067 continue;
68
69 /* I have a match */
Al Viro90434762008-07-15 08:54:06 -040070 return p;
Eric W. Biederman77b14db2007-02-14 00:34:12 -080071 }
72 return NULL;
73}
74
Adrian Bunk81324362008-10-03 00:33:54 +040075static struct ctl_table_header *grab_header(struct inode *inode)
Eric W. Biederman77b14db2007-02-14 00:34:12 -080076{
Al Viro90434762008-07-15 08:54:06 -040077 if (PROC_I(inode)->sysctl)
78 return sysctl_head_grab(PROC_I(inode)->sysctl);
79 else
80 return sysctl_head_next(NULL);
Eric W. Biederman77b14db2007-02-14 00:34:12 -080081}
82
83static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
84 struct nameidata *nd)
85{
Al Viro90434762008-07-15 08:54:06 -040086 struct ctl_table_header *head = grab_header(dir);
87 struct ctl_table *table = PROC_I(dir)->sysctl_entry;
88 struct ctl_table_header *h = NULL;
89 struct qstr *name = &dentry->d_name;
90 struct ctl_table *p;
Eric W. Biederman77b14db2007-02-14 00:34:12 -080091 struct inode *inode;
Al Viro90434762008-07-15 08:54:06 -040092 struct dentry *err = ERR_PTR(-ENOENT);
Eric W. Biederman77b14db2007-02-14 00:34:12 -080093
Al Viro90434762008-07-15 08:54:06 -040094 if (IS_ERR(head))
95 return ERR_CAST(head);
96
97 if (table && !table->child) {
98 WARN_ON(1);
99 goto out;
100 }
101
102 table = table ? table->child : head->ctl_table;
103
104 p = find_in_table(table, name);
105 if (!p) {
106 for (h = sysctl_head_next(NULL); h; h = sysctl_head_next(h)) {
107 if (h->attached_to != table)
108 continue;
109 p = find_in_table(h->attached_by, name);
110 if (p)
111 break;
112 }
113 }
114
115 if (!p)
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800116 goto out;
117
118 err = ERR_PTR(-ENOMEM);
Al Viro90434762008-07-15 08:54:06 -0400119 inode = proc_sys_make_inode(dir->i_sb, h ? h : head, p);
120 if (h)
121 sysctl_head_finish(h);
122
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800123 if (!inode)
124 goto out;
125
126 err = NULL;
Nick Pigginfb045ad2011-01-07 17:49:55 +1100127 d_set_d_op(dentry, &proc_sys_dentry_operations);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800128 d_add(dentry, inode);
129
130out:
131 sysctl_head_finish(head);
132 return err;
133}
134
Pavel Emelyanov7708bfb2008-04-29 01:02:40 -0700135static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
136 size_t count, loff_t *ppos, int write)
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800137{
Al Viro90434762008-07-15 08:54:06 -0400138 struct inode *inode = filp->f_path.dentry->d_inode;
139 struct ctl_table_header *head = grab_header(inode);
140 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
David Howells2a2da532007-10-25 15:27:40 +0100141 ssize_t error;
142 size_t res;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800143
Al Viro90434762008-07-15 08:54:06 -0400144 if (IS_ERR(head))
145 return PTR_ERR(head);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800146
147 /*
148 * At this point we know that the sysctl was not unregistered
149 * and won't be until we finish.
150 */
151 error = -EPERM;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -0700152 if (sysctl_perm(head->root, table, write ? MAY_WRITE : MAY_READ))
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800153 goto out;
154
Al Viro90434762008-07-15 08:54:06 -0400155 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
156 error = -EINVAL;
157 if (!table->proc_handler)
158 goto out;
159
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800160 /* careful: calling conventions are nasty here */
161 res = count;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700162 error = table->proc_handler(table, write, buf, &res, ppos);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800163 if (!error)
164 error = res;
165out:
166 sysctl_head_finish(head);
167
168 return error;
169}
170
Pavel Emelyanov7708bfb2008-04-29 01:02:40 -0700171static ssize_t proc_sys_read(struct file *filp, char __user *buf,
172 size_t count, loff_t *ppos)
173{
174 return proc_sys_call_handler(filp, (void __user *)buf, count, ppos, 0);
175}
176
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800177static ssize_t proc_sys_write(struct file *filp, const char __user *buf,
178 size_t count, loff_t *ppos)
179{
Pavel Emelyanov7708bfb2008-04-29 01:02:40 -0700180 return proc_sys_call_handler(filp, (void __user *)buf, count, ppos, 1);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800181}
182
Lucas De Marchif1ecf062011-11-02 13:39:22 -0700183static int proc_sys_open(struct inode *inode, struct file *filp)
184{
185 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
186
187 if (table->poll)
188 filp->private_data = proc_sys_poll_event(table->poll);
189
190 return 0;
191}
192
193static unsigned int proc_sys_poll(struct file *filp, poll_table *wait)
194{
195 struct inode *inode = filp->f_path.dentry->d_inode;
196 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
197 unsigned long event = (unsigned long)filp->private_data;
198 unsigned int ret = DEFAULT_POLLMASK;
199
200 if (!table->proc_handler)
201 goto out;
202
203 if (!table->poll)
204 goto out;
205
206 poll_wait(filp, &table->poll->wait, wait);
207
208 if (event != atomic_read(&table->poll->event)) {
209 filp->private_data = proc_sys_poll_event(table->poll);
210 ret = POLLIN | POLLRDNORM | POLLERR | POLLPRI;
211 }
212
213out:
214 return ret;
215}
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800216
217static int proc_sys_fill_cache(struct file *filp, void *dirent,
Al Viro90434762008-07-15 08:54:06 -0400218 filldir_t filldir,
219 struct ctl_table_header *head,
220 struct ctl_table *table)
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800221{
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800222 struct dentry *child, *dir = filp->f_path.dentry;
223 struct inode *inode;
224 struct qstr qname;
225 ino_t ino = 0;
226 unsigned type = DT_UNKNOWN;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800227
228 qname.name = table->procname;
229 qname.len = strlen(table->procname);
230 qname.hash = full_name_hash(qname.name, qname.len);
231
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800232 child = d_lookup(dir, &qname);
233 if (!child) {
Al Viro90434762008-07-15 08:54:06 -0400234 child = d_alloc(dir, &qname);
235 if (child) {
236 inode = proc_sys_make_inode(dir->d_sb, head, table);
237 if (!inode) {
238 dput(child);
239 return -ENOMEM;
240 } else {
Nick Pigginfb045ad2011-01-07 17:49:55 +1100241 d_set_d_op(child, &proc_sys_dentry_operations);
Al Viro90434762008-07-15 08:54:06 -0400242 d_add(child, inode);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800243 }
Al Viro90434762008-07-15 08:54:06 -0400244 } else {
245 return -ENOMEM;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800246 }
247 }
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800248 inode = child->d_inode;
Al Viro90434762008-07-15 08:54:06 -0400249 ino = inode->i_ino;
250 type = inode->i_mode >> 12;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800251 dput(child);
Al Viro90434762008-07-15 08:54:06 -0400252 return !!filldir(dirent, qname.name, qname.len, filp->f_pos, ino, type);
253}
254
255static int scan(struct ctl_table_header *head, ctl_table *table,
256 unsigned long *pos, struct file *file,
257 void *dirent, filldir_t filldir)
258{
259
Eric W. Biederman2315ffa2009-04-03 03:18:02 -0700260 for (; table->procname; table++, (*pos)++) {
Al Viro90434762008-07-15 08:54:06 -0400261 int res;
262
Al Viro90434762008-07-15 08:54:06 -0400263 if (*pos < file->f_pos)
264 continue;
265
266 res = proc_sys_fill_cache(file, dirent, filldir, head, table);
267 if (res)
268 return res;
269
270 file->f_pos = *pos + 1;
271 }
272 return 0;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800273}
274
275static int proc_sys_readdir(struct file *filp, void *dirent, filldir_t filldir)
276{
Al Viro90434762008-07-15 08:54:06 -0400277 struct dentry *dentry = filp->f_path.dentry;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800278 struct inode *inode = dentry->d_inode;
Al Viro90434762008-07-15 08:54:06 -0400279 struct ctl_table_header *head = grab_header(inode);
280 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
281 struct ctl_table_header *h = NULL;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800282 unsigned long pos;
Al Viro90434762008-07-15 08:54:06 -0400283 int ret = -EINVAL;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800284
Al Viro90434762008-07-15 08:54:06 -0400285 if (IS_ERR(head))
286 return PTR_ERR(head);
287
288 if (table && !table->child) {
289 WARN_ON(1);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800290 goto out;
Al Viro90434762008-07-15 08:54:06 -0400291 }
292
293 table = table ? table->child : head->ctl_table;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800294
295 ret = 0;
296 /* Avoid a switch here: arm builds fail with missing __cmpdi2 */
297 if (filp->f_pos == 0) {
298 if (filldir(dirent, ".", 1, filp->f_pos,
299 inode->i_ino, DT_DIR) < 0)
300 goto out;
301 filp->f_pos++;
302 }
303 if (filp->f_pos == 1) {
304 if (filldir(dirent, "..", 2, filp->f_pos,
305 parent_ino(dentry), DT_DIR) < 0)
306 goto out;
307 filp->f_pos++;
308 }
309 pos = 2;
310
Al Viro90434762008-07-15 08:54:06 -0400311 ret = scan(head, table, &pos, filp, dirent, filldir);
312 if (ret)
313 goto out;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800314
Al Viro90434762008-07-15 08:54:06 -0400315 for (h = sysctl_head_next(NULL); h; h = sysctl_head_next(h)) {
316 if (h->attached_to != table)
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800317 continue;
Al Viro90434762008-07-15 08:54:06 -0400318 ret = scan(h, h->attached_by, &pos, filp, dirent, filldir);
319 if (ret) {
320 sysctl_head_finish(h);
321 break;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800322 }
323 }
324 ret = 1;
325out:
326 sysctl_head_finish(head);
327 return ret;
328}
329
Al Viro10556cb2011-06-20 19:28:19 -0400330static int proc_sys_permission(struct inode *inode, int mask)
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800331{
332 /*
333 * sysctl entries that are not writeable,
334 * are _NOT_ writeable, capabilities or not.
335 */
Miklos Szeredif696a362008-07-31 13:41:58 +0200336 struct ctl_table_header *head;
337 struct ctl_table *table;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800338 int error;
339
Miklos Szeredif696a362008-07-31 13:41:58 +0200340 /* Executable files are not allowed under /proc/sys/ */
341 if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))
342 return -EACCES;
343
344 head = grab_header(inode);
Al Viro90434762008-07-15 08:54:06 -0400345 if (IS_ERR(head))
346 return PTR_ERR(head);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800347
Miklos Szeredif696a362008-07-31 13:41:58 +0200348 table = PROC_I(inode)->sysctl_entry;
Al Viro90434762008-07-15 08:54:06 -0400349 if (!table) /* global root - r-xr-xr-x */
350 error = mask & MAY_WRITE ? -EACCES : 0;
351 else /* Use the permissions on the sysctl table entry */
Al Viro1fc0f782011-06-20 18:59:02 -0400352 error = sysctl_perm(head->root, table, mask & ~MAY_NOT_BLOCK);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800353
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800354 sysctl_head_finish(head);
355 return error;
356}
357
358static int proc_sys_setattr(struct dentry *dentry, struct iattr *attr)
359{
360 struct inode *inode = dentry->d_inode;
361 int error;
362
363 if (attr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID))
364 return -EPERM;
365
366 error = inode_change_ok(inode, attr);
Christoph Hellwig10257742010-06-04 11:30:02 +0200367 if (error)
368 return error;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800369
Christoph Hellwig10257742010-06-04 11:30:02 +0200370 if ((attr->ia_valid & ATTR_SIZE) &&
371 attr->ia_size != i_size_read(inode)) {
372 error = vmtruncate(inode, attr->ia_size);
373 if (error)
374 return error;
375 }
376
377 setattr_copy(inode, attr);
378 mark_inode_dirty(inode);
379 return 0;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800380}
381
Al Viro90434762008-07-15 08:54:06 -0400382static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
383{
384 struct inode *inode = dentry->d_inode;
385 struct ctl_table_header *head = grab_header(inode);
386 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
387
388 if (IS_ERR(head))
389 return PTR_ERR(head);
390
391 generic_fillattr(inode, stat);
392 if (table)
393 stat->mode = (stat->mode & S_IFMT) | table->mode;
394
395 sysctl_head_finish(head);
396 return 0;
397}
398
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800399static const struct file_operations proc_sys_file_operations = {
Lucas De Marchif1ecf062011-11-02 13:39:22 -0700400 .open = proc_sys_open,
401 .poll = proc_sys_poll,
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800402 .read = proc_sys_read,
403 .write = proc_sys_write,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200404 .llseek = default_llseek,
Al Viro90434762008-07-15 08:54:06 -0400405};
406
407static const struct file_operations proc_sys_dir_file_operations = {
Pavel Emelyanov887df072011-11-02 13:38:42 -0700408 .read = generic_read_dir,
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800409 .readdir = proc_sys_readdir,
Christoph Hellwig3222a3e2008-09-03 21:53:01 +0200410 .llseek = generic_file_llseek,
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800411};
412
Jan Engelhardt03a44822008-02-08 04:21:19 -0800413static const struct inode_operations proc_sys_inode_operations = {
Al Viro90434762008-07-15 08:54:06 -0400414 .permission = proc_sys_permission,
415 .setattr = proc_sys_setattr,
416 .getattr = proc_sys_getattr,
417};
418
419static const struct inode_operations proc_sys_dir_operations = {
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800420 .lookup = proc_sys_lookup,
421 .permission = proc_sys_permission,
422 .setattr = proc_sys_setattr,
Al Viro90434762008-07-15 08:54:06 -0400423 .getattr = proc_sys_getattr,
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800424};
425
426static int proc_sys_revalidate(struct dentry *dentry, struct nameidata *nd)
427{
Nick Piggin34286d62011-01-07 17:49:57 +1100428 if (nd->flags & LOOKUP_RCU)
429 return -ECHILD;
Al Viro90434762008-07-15 08:54:06 -0400430 return !PROC_I(dentry->d_inode)->sysctl->unregistering;
431}
432
Nick Pigginfe15ce42011-01-07 17:49:23 +1100433static int proc_sys_delete(const struct dentry *dentry)
Al Viro90434762008-07-15 08:54:06 -0400434{
435 return !!PROC_I(dentry->d_inode)->sysctl->unregistering;
436}
437
Nick Piggin621e1552011-01-07 17:49:27 +1100438static int proc_sys_compare(const struct dentry *parent,
439 const struct inode *pinode,
440 const struct dentry *dentry, const struct inode *inode,
441 unsigned int len, const char *str, const struct qstr *name)
Al Viro90434762008-07-15 08:54:06 -0400442{
Al Virodfef6dc2011-03-08 01:25:28 -0500443 struct ctl_table_header *head;
Nick Piggin31e6b012011-01-07 17:49:52 +1100444 /* Although proc doesn't have negative dentries, rcu-walk means
445 * that inode here can be NULL */
Al Virodfef6dc2011-03-08 01:25:28 -0500446 /* AV: can it, indeed? */
Nick Piggin31e6b012011-01-07 17:49:52 +1100447 if (!inode)
Al Virodfef6dc2011-03-08 01:25:28 -0500448 return 1;
Nick Piggin621e1552011-01-07 17:49:27 +1100449 if (name->len != len)
Al Viro90434762008-07-15 08:54:06 -0400450 return 1;
Nick Piggin621e1552011-01-07 17:49:27 +1100451 if (memcmp(name->name, str, len))
Al Viro90434762008-07-15 08:54:06 -0400452 return 1;
Al Virodfef6dc2011-03-08 01:25:28 -0500453 head = rcu_dereference(PROC_I(inode)->sysctl);
454 return !head || !sysctl_is_seen(head);
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800455}
456
Al Virod72f71e2009-02-20 05:58:47 +0000457static const struct dentry_operations proc_sys_dentry_operations = {
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800458 .d_revalidate = proc_sys_revalidate,
Al Viro90434762008-07-15 08:54:06 -0400459 .d_delete = proc_sys_delete,
460 .d_compare = proc_sys_compare,
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800461};
462
Alexey Dobriyan1e0edd32008-10-17 05:07:44 +0400463int __init proc_sys_init(void)
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800464{
Alexey Dobriyane1675232008-10-03 00:23:32 +0400465 struct proc_dir_entry *proc_sys_root;
466
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800467 proc_sys_root = proc_mkdir("sys", NULL);
Al Viro90434762008-07-15 08:54:06 -0400468 proc_sys_root->proc_iops = &proc_sys_dir_operations;
469 proc_sys_root->proc_fops = &proc_sys_dir_file_operations;
Eric W. Biederman77b14db2007-02-14 00:34:12 -0800470 proc_sys_root->nlink = 0;
471 return 0;
472}