]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - fs/proc/generic.c
UBUNTU: SAUCE: (namespace) fs: Allow superblock owner to change ownership of inodes
[mirror_ubuntu-zesty-kernel.git] / fs / proc / generic.c
CommitLineData
1da177e4
LT
1/*
2 * proc/fs/generic.c --- generic routines for the proc-fs
3 *
4 * This file contains generic proc-fs routines for handling
5 * directories and files.
6 *
7 * Copyright (C) 1991, 1992 Linus Torvalds.
8 * Copyright (C) 1997 Theodore Ts'o
9 */
10
11#include <linux/errno.h>
12#include <linux/time.h>
13#include <linux/proc_fs.h>
14#include <linux/stat.h>
1025774c 15#include <linux/mm.h>
1da177e4 16#include <linux/module.h>
5a0e3ad6 17#include <linux/slab.h>
87ebdc00 18#include <linux/printk.h>
1da177e4 19#include <linux/mount.h>
1da177e4
LT
20#include <linux/init.h>
21#include <linux/idr.h>
1da177e4 22#include <linux/bitops.h>
64a07bd8 23#include <linux/spinlock.h>
786d7e16 24#include <linux/completion.h>
7c0f6ba6 25#include <linux/uaccess.h>
1da177e4 26
fee781e6
AB
27#include "internal.h"
28
ecf1a3df 29static DEFINE_RWLOCK(proc_subdir_lock);
64a07bd8 30
312ec7e5 31static int proc_match(unsigned int len, const char *name, struct proc_dir_entry *de)
1da177e4 32{
710585d4
ND
33 if (len < de->namelen)
34 return -1;
35 if (len > de->namelen)
36 return 1;
37
38 return memcmp(name, de->name, len);
39}
40
41static struct proc_dir_entry *pde_subdir_first(struct proc_dir_entry *dir)
42{
2fc1e948
ND
43 return rb_entry_safe(rb_first(&dir->subdir), struct proc_dir_entry,
44 subdir_node);
710585d4
ND
45}
46
47static struct proc_dir_entry *pde_subdir_next(struct proc_dir_entry *dir)
48{
2fc1e948
ND
49 return rb_entry_safe(rb_next(&dir->subdir_node), struct proc_dir_entry,
50 subdir_node);
710585d4
ND
51}
52
53static struct proc_dir_entry *pde_subdir_find(struct proc_dir_entry *dir,
54 const char *name,
55 unsigned int len)
56{
57 struct rb_node *node = dir->subdir.rb_node;
58
59 while (node) {
60 struct proc_dir_entry *de = container_of(node,
61 struct proc_dir_entry,
62 subdir_node);
63 int result = proc_match(len, name, de);
64
65 if (result < 0)
66 node = node->rb_left;
67 else if (result > 0)
68 node = node->rb_right;
69 else
70 return de;
71 }
72 return NULL;
73}
74
75static bool pde_subdir_insert(struct proc_dir_entry *dir,
76 struct proc_dir_entry *de)
77{
78 struct rb_root *root = &dir->subdir;
79 struct rb_node **new = &root->rb_node, *parent = NULL;
80
81 /* Figure out where to put new node */
82 while (*new) {
83 struct proc_dir_entry *this =
84 container_of(*new, struct proc_dir_entry, subdir_node);
85 int result = proc_match(de->namelen, de->name, this);
86
87 parent = *new;
88 if (result < 0)
89 new = &(*new)->rb_left;
90 else if (result > 0)
91 new = &(*new)->rb_right;
92 else
93 return false;
94 }
95
96 /* Add new node and rebalance tree. */
97 rb_link_node(&de->subdir_node, parent, new);
98 rb_insert_color(&de->subdir_node, root);
99 return true;
1da177e4
LT
100}
101
1da177e4
LT
102static int proc_notify_change(struct dentry *dentry, struct iattr *iattr)
103{
2b0143b5 104 struct inode *inode = d_inode(dentry);
1da177e4 105 struct proc_dir_entry *de = PDE(inode);
a6071d80 106 struct user_namespace *s_user_ns;
1da177e4
LT
107 int error;
108
a6071d80
EB
109 /* Don't let anyone mess with weird proc files */
110 s_user_ns = inode->i_sb->s_user_ns;
111 if (!kuid_has_mapping(s_user_ns, inode->i_uid) ||
112 !kgid_has_mapping(s_user_ns, inode->i_gid))
113 return -EPERM;
114
31051c85 115 error = setattr_prepare(dentry, iattr);
1da177e4 116 if (error)
1025774c 117 return error;
1da177e4 118
1025774c
CH
119 setattr_copy(inode, iattr);
120 mark_inode_dirty(inode);
46f69557 121
cdf7e8dd 122 proc_set_user(de, inode->i_uid, inode->i_gid);
1da177e4 123 de->mode = inode->i_mode;
1025774c 124 return 0;
1da177e4
LT
125}
126
2b579bee
MS
127static int proc_getattr(struct vfsmount *mnt, struct dentry *dentry,
128 struct kstat *stat)
129{
2b0143b5 130 struct inode *inode = d_inode(dentry);
6bee55f9 131 struct proc_dir_entry *de = PDE(inode);
2b579bee 132 if (de && de->nlink)
bfe86848 133 set_nlink(inode, de->nlink);
2b579bee
MS
134
135 generic_fillattr(inode, stat);
136 return 0;
137}
138
c5ef1c42 139static const struct inode_operations proc_file_inode_operations = {
1da177e4
LT
140 .setattr = proc_notify_change,
141};
142
143/*
144 * This function parses a name such as "tty/driver/serial", and
145 * returns the struct proc_dir_entry for "/proc/tty/driver", and
146 * returns "serial" in residual.
147 */
e17a5765
AD
148static int __xlate_proc_name(const char *name, struct proc_dir_entry **ret,
149 const char **residual)
1da177e4
LT
150{
151 const char *cp = name, *next;
152 struct proc_dir_entry *de;
312ec7e5 153 unsigned int len;
1da177e4 154
7cee4e00
AD
155 de = *ret;
156 if (!de)
157 de = &proc_root;
158
1da177e4
LT
159 while (1) {
160 next = strchr(cp, '/');
161 if (!next)
162 break;
163
164 len = next - cp;
710585d4 165 de = pde_subdir_find(de, cp, len);
12bac0d9
AD
166 if (!de) {
167 WARN(1, "name '%s'\n", name);
e17a5765 168 return -ENOENT;
12bac0d9 169 }
1da177e4
LT
170 cp += len + 1;
171 }
172 *residual = cp;
173 *ret = de;
e17a5765
AD
174 return 0;
175}
176
177static int xlate_proc_name(const char *name, struct proc_dir_entry **ret,
178 const char **residual)
179{
180 int rv;
181
ecf1a3df 182 read_lock(&proc_subdir_lock);
e17a5765 183 rv = __xlate_proc_name(name, ret, residual);
ecf1a3df 184 read_unlock(&proc_subdir_lock);
e17a5765 185 return rv;
1da177e4
LT
186}
187
9a185409 188static DEFINE_IDA(proc_inum_ida);
1da177e4
LT
189static DEFINE_SPINLOCK(proc_inum_lock); /* protects the above */
190
67935df4 191#define PROC_DYNAMIC_FIRST 0xF0000000U
1da177e4
LT
192
193/*
194 * Return an inode number between PROC_DYNAMIC_FIRST and
195 * 0xffffffff, or zero on failure.
196 */
33d6dce6 197int proc_alloc_inum(unsigned int *inum)
1da177e4 198{
67935df4 199 unsigned int i;
1da177e4
LT
200 int error;
201
202retry:
33d6dce6
EB
203 if (!ida_pre_get(&proc_inum_ida, GFP_KERNEL))
204 return -ENOMEM;
1da177e4 205
dfb2ea45 206 spin_lock_irq(&proc_inum_lock);
9a185409 207 error = ida_get_new(&proc_inum_ida, &i);
dfb2ea45 208 spin_unlock_irq(&proc_inum_lock);
1da177e4
LT
209 if (error == -EAGAIN)
210 goto retry;
211 else if (error)
33d6dce6 212 return error;
1da177e4 213
67935df4 214 if (i > UINT_MAX - PROC_DYNAMIC_FIRST) {
dfb2ea45 215 spin_lock_irq(&proc_inum_lock);
9a185409 216 ida_remove(&proc_inum_ida, i);
dfb2ea45 217 spin_unlock_irq(&proc_inum_lock);
33d6dce6 218 return -ENOSPC;
67935df4 219 }
33d6dce6
EB
220 *inum = PROC_DYNAMIC_FIRST + i;
221 return 0;
1da177e4
LT
222}
223
33d6dce6 224void proc_free_inum(unsigned int inum)
1da177e4 225{
dfb2ea45
EB
226 unsigned long flags;
227 spin_lock_irqsave(&proc_inum_lock, flags);
9a185409 228 ida_remove(&proc_inum_ida, inum - PROC_DYNAMIC_FIRST);
dfb2ea45 229 spin_unlock_irqrestore(&proc_inum_lock, flags);
1da177e4
LT
230}
231
1da177e4
LT
232/*
233 * Don't create negative dentries here, return -ENOENT by hand
234 * instead.
235 */
e9720acd
PE
236struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
237 struct dentry *dentry)
1da177e4 238{
d3d009cb 239 struct inode *inode;
1da177e4 240
ecf1a3df 241 read_lock(&proc_subdir_lock);
710585d4
ND
242 de = pde_subdir_find(de, dentry->d_name.name, dentry->d_name.len);
243 if (de) {
244 pde_get(de);
ecf1a3df 245 read_unlock(&proc_subdir_lock);
710585d4
ND
246 inode = proc_get_inode(dir->i_sb, de);
247 if (!inode)
248 return ERR_PTR(-ENOMEM);
249 d_set_d_op(dentry, &simple_dentry_operations);
250 d_add(dentry, inode);
251 return NULL;
1da177e4 252 }
ecf1a3df 253 read_unlock(&proc_subdir_lock);
d3d009cb 254 return ERR_PTR(-ENOENT);
1da177e4
LT
255}
256
e9720acd 257struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
00cd8dd3 258 unsigned int flags)
e9720acd
PE
259{
260 return proc_lookup_de(PDE(dir), dir, dentry);
261}
262
1da177e4
LT
263/*
264 * This returns non-zero if at EOF, so that the /proc
265 * root directory can use this and check if it should
266 * continue with the <pid> entries..
267 *
268 * Note that the VFS-layer doesn't care about the return
269 * value of the readdir() call, as long as it's non-negative
270 * for success..
271 */
f0c3b509
AV
272int proc_readdir_de(struct proc_dir_entry *de, struct file *file,
273 struct dir_context *ctx)
1da177e4 274{
1da177e4 275 int i;
f0c3b509
AV
276
277 if (!dir_emit_dots(file, ctx))
278 return 0;
279
ecf1a3df 280 read_lock(&proc_subdir_lock);
710585d4 281 de = pde_subdir_first(de);
f0c3b509
AV
282 i = ctx->pos - 2;
283 for (;;) {
284 if (!de) {
ecf1a3df 285 read_unlock(&proc_subdir_lock);
f0c3b509
AV
286 return 0;
287 }
288 if (!i)
289 break;
710585d4 290 de = pde_subdir_next(de);
f0c3b509 291 i--;
1da177e4 292 }
f0c3b509
AV
293
294 do {
295 struct proc_dir_entry *next;
296 pde_get(de);
ecf1a3df 297 read_unlock(&proc_subdir_lock);
f0c3b509
AV
298 if (!dir_emit(ctx, de->name, de->namelen,
299 de->low_ino, de->mode >> 12)) {
300 pde_put(de);
301 return 0;
302 }
ecf1a3df 303 read_lock(&proc_subdir_lock);
f0c3b509 304 ctx->pos++;
710585d4 305 next = pde_subdir_next(de);
f0c3b509
AV
306 pde_put(de);
307 de = next;
308 } while (de);
ecf1a3df 309 read_unlock(&proc_subdir_lock);
fd3930f7 310 return 1;
1da177e4
LT
311}
312
f0c3b509 313int proc_readdir(struct file *file, struct dir_context *ctx)
e9720acd 314{
f0c3b509 315 struct inode *inode = file_inode(file);
e9720acd 316
f0c3b509 317 return proc_readdir_de(PDE(inode), file, ctx);
e9720acd
PE
318}
319
1da177e4
LT
320/*
321 * These are the generic /proc directory operations. They
322 * use the in-memory "struct proc_dir_entry" tree to parse
323 * the /proc directory.
324 */
00977a59 325static const struct file_operations proc_dir_operations = {
b4df2b92 326 .llseek = generic_file_llseek,
1da177e4 327 .read = generic_read_dir,
f50752ea 328 .iterate_shared = proc_readdir,
1da177e4
LT
329};
330
331/*
332 * proc directories can do almost nothing..
333 */
c5ef1c42 334static const struct inode_operations proc_dir_inode_operations = {
1da177e4 335 .lookup = proc_lookup,
2b579bee 336 .getattr = proc_getattr,
1da177e4
LT
337 .setattr = proc_notify_change,
338};
339
340static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp)
341{
33d6dce6 342 int ret;
710585d4 343
33d6dce6
EB
344 ret = proc_alloc_inum(&dp->low_ino);
345 if (ret)
346 return ret;
64a07bd8 347
ecf1a3df 348 write_lock(&proc_subdir_lock);
99fc06df 349 dp->parent = dir;
b208d54b 350 if (pde_subdir_insert(dir, dp) == false) {
710585d4
ND
351 WARN(1, "proc_dir_entry '%s/%s' already registered\n",
352 dir->name, dp->name);
ecf1a3df 353 write_unlock(&proc_subdir_lock);
b208d54b
DB
354 proc_free_inum(dp->low_ino);
355 return -EEXIST;
356 }
ecf1a3df 357 write_unlock(&proc_subdir_lock);
99fc06df 358
1da177e4
LT
359 return 0;
360}
361
2d3a4e36 362static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
1da177e4 363 const char *name,
d161a13f 364 umode_t mode,
1da177e4
LT
365 nlink_t nlink)
366{
367 struct proc_dir_entry *ent = NULL;
dbcdb504
AD
368 const char *fn;
369 struct qstr qstr;
1da177e4 370
7cee4e00 371 if (xlate_proc_name(name, parent, &fn) != 0)
1da177e4 372 goto out;
dbcdb504
AD
373 qstr.name = fn;
374 qstr.len = strlen(fn);
375 if (qstr.len == 0 || qstr.len >= 256) {
376 WARN(1, "name len %u\n", qstr.len);
377 return NULL;
378 }
379 if (*parent == &proc_root && name_to_int(&qstr) != ~0U) {
380 WARN(1, "create '/proc/%s' by hand\n", qstr.name);
381 return NULL;
382 }
eb6d38d5
EB
383 if (is_empty_pde(*parent)) {
384 WARN(1, "attempt to add to permanently empty directory");
385 return NULL;
386 }
1da177e4 387
dbcdb504 388 ent = kzalloc(sizeof(struct proc_dir_entry) + qstr.len + 1, GFP_KERNEL);
17baa2a2 389 if (!ent)
390 goto out;
1da177e4 391
dbcdb504
AD
392 memcpy(ent->name, fn, qstr.len + 1);
393 ent->namelen = qstr.len;
1da177e4
LT
394 ent->mode = mode;
395 ent->nlink = nlink;
710585d4 396 ent->subdir = RB_ROOT;
5a622f2d 397 atomic_set(&ent->count, 1);
786d7e16 398 spin_lock_init(&ent->pde_unload_lock);
881adb85 399 INIT_LIST_HEAD(&ent->pde_openers);
c110486f
DT
400 proc_set_user(ent, (*parent)->uid, (*parent)->gid);
401
17baa2a2 402out:
1da177e4
LT
403 return ent;
404}
405
406struct proc_dir_entry *proc_symlink(const char *name,
407 struct proc_dir_entry *parent, const char *dest)
408{
409 struct proc_dir_entry *ent;
410
2d3a4e36 411 ent = __proc_create(&parent, name,
1da177e4
LT
412 (S_IFLNK | S_IRUGO | S_IWUGO | S_IXUGO),1);
413
414 if (ent) {
415 ent->data = kmalloc((ent->size=strlen(dest))+1, GFP_KERNEL);
416 if (ent->data) {
417 strcpy((char*)ent->data,dest);
d443b9fd 418 ent->proc_iops = &proc_link_inode_operations;
1da177e4
LT
419 if (proc_register(parent, ent) < 0) {
420 kfree(ent->data);
421 kfree(ent);
422 ent = NULL;
423 }
424 } else {
425 kfree(ent);
426 ent = NULL;
427 }
428 }
429 return ent;
430}
587d4a17 431EXPORT_SYMBOL(proc_symlink);
1da177e4 432
270b5ac2
DH
433struct proc_dir_entry *proc_mkdir_data(const char *name, umode_t mode,
434 struct proc_dir_entry *parent, void *data)
1da177e4
LT
435{
436 struct proc_dir_entry *ent;
437
270b5ac2
DH
438 if (mode == 0)
439 mode = S_IRUGO | S_IXUGO;
440
2d3a4e36 441 ent = __proc_create(&parent, name, S_IFDIR | mode, 2);
1da177e4 442 if (ent) {
270b5ac2 443 ent->data = data;
d443b9fd
AV
444 ent->proc_fops = &proc_dir_operations;
445 ent->proc_iops = &proc_dir_inode_operations;
446 parent->nlink++;
1da177e4
LT
447 if (proc_register(parent, ent) < 0) {
448 kfree(ent);
d443b9fd 449 parent->nlink--;
1da177e4
LT
450 ent = NULL;
451 }
452 }
453 return ent;
454}
270b5ac2 455EXPORT_SYMBOL_GPL(proc_mkdir_data);
1da177e4 456
270b5ac2
DH
457struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
458 struct proc_dir_entry *parent)
78e92b99 459{
270b5ac2 460 return proc_mkdir_data(name, mode, parent, NULL);
78e92b99 461}
270b5ac2 462EXPORT_SYMBOL(proc_mkdir_mode);
78e92b99 463
1da177e4
LT
464struct proc_dir_entry *proc_mkdir(const char *name,
465 struct proc_dir_entry *parent)
466{
270b5ac2 467 return proc_mkdir_data(name, 0, parent, NULL);
1da177e4 468}
587d4a17 469EXPORT_SYMBOL(proc_mkdir);
1da177e4 470
eb6d38d5
EB
471struct proc_dir_entry *proc_create_mount_point(const char *name)
472{
473 umode_t mode = S_IFDIR | S_IRUGO | S_IXUGO;
474 struct proc_dir_entry *ent, *parent = NULL;
475
476 ent = __proc_create(&parent, name, mode, 2);
477 if (ent) {
478 ent->data = NULL;
479 ent->proc_fops = NULL;
480 ent->proc_iops = NULL;
481 if (proc_register(parent, ent) < 0) {
482 kfree(ent);
483 parent->nlink--;
484 ent = NULL;
485 }
486 }
487 return ent;
488}
f97df70b 489EXPORT_SYMBOL(proc_create_mount_point);
eb6d38d5 490
d161a13f 491struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
59b74351
DL
492 struct proc_dir_entry *parent,
493 const struct file_operations *proc_fops,
494 void *data)
2d3a4e36
AD
495{
496 struct proc_dir_entry *pde;
b6cdc731
AV
497 if ((mode & S_IFMT) == 0)
498 mode |= S_IFREG;
2d3a4e36 499
b6cdc731
AV
500 if (!S_ISREG(mode)) {
501 WARN_ON(1); /* use proc_mkdir() */
502 return NULL;
2d3a4e36
AD
503 }
504
d443b9fd
AV
505 BUG_ON(proc_fops == NULL);
506
b6cdc731
AV
507 if ((mode & S_IALLUGO) == 0)
508 mode |= S_IRUGO;
509 pde = __proc_create(&parent, name, mode, 1);
2d3a4e36
AD
510 if (!pde)
511 goto out;
512 pde->proc_fops = proc_fops;
59b74351 513 pde->data = data;
d443b9fd 514 pde->proc_iops = &proc_file_inode_operations;
2d3a4e36
AD
515 if (proc_register(parent, pde) < 0)
516 goto out_free;
517 return pde;
518out_free:
519 kfree(pde);
520out:
521 return NULL;
522}
587d4a17 523EXPORT_SYMBOL(proc_create_data);
271a15ea
DH
524
525void proc_set_size(struct proc_dir_entry *de, loff_t size)
526{
527 de->size = size;
528}
529EXPORT_SYMBOL(proc_set_size);
530
531void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid)
532{
533 de->uid = uid;
534 de->gid = gid;
535}
536EXPORT_SYMBOL(proc_set_user);
2d3a4e36 537
135d5655 538static void free_proc_entry(struct proc_dir_entry *de)
1da177e4 539{
33d6dce6 540 proc_free_inum(de->low_ino);
1da177e4 541
fd2cbe48 542 if (S_ISLNK(de->mode))
1da177e4
LT
543 kfree(de->data);
544 kfree(de);
545}
546
135d5655
AD
547void pde_put(struct proc_dir_entry *pde)
548{
549 if (atomic_dec_and_test(&pde->count))
550 free_proc_entry(pde);
551}
552
8ce584c7
AV
553/*
554 * Remove a /proc entry and free it if it's not currently in use.
555 */
556void remove_proc_entry(const char *name, struct proc_dir_entry *parent)
557{
8ce584c7
AV
558 struct proc_dir_entry *de = NULL;
559 const char *fn = name;
560 unsigned int len;
561
ecf1a3df 562 write_lock(&proc_subdir_lock);
8ce584c7 563 if (__xlate_proc_name(name, &parent, &fn) != 0) {
ecf1a3df 564 write_unlock(&proc_subdir_lock);
8ce584c7
AV
565 return;
566 }
567 len = strlen(fn);
568
710585d4
ND
569 de = pde_subdir_find(parent, fn, len);
570 if (de)
571 rb_erase(&de->subdir_node, &parent->subdir);
ecf1a3df 572 write_unlock(&proc_subdir_lock);
8ce584c7
AV
573 if (!de) {
574 WARN(1, "name '%s'\n", name);
575 return;
576 }
577
866ad9a7 578 proc_entry_rundown(de);
881adb85 579
f649d6d3
AD
580 if (S_ISDIR(de->mode))
581 parent->nlink--;
582 de->nlink = 0;
710585d4
ND
583 WARN(pde_subdir_first(de),
584 "%s: removing non-empty directory '%s/%s', leaking at least '%s'\n",
585 __func__, de->parent->name, de->name, pde_subdir_first(de)->name);
135d5655 586 pde_put(de);
1da177e4 587}
587d4a17 588EXPORT_SYMBOL(remove_proc_entry);
8ce584c7
AV
589
590int remove_proc_subtree(const char *name, struct proc_dir_entry *parent)
591{
8ce584c7
AV
592 struct proc_dir_entry *root = NULL, *de, *next;
593 const char *fn = name;
594 unsigned int len;
595
ecf1a3df 596 write_lock(&proc_subdir_lock);
8ce584c7 597 if (__xlate_proc_name(name, &parent, &fn) != 0) {
ecf1a3df 598 write_unlock(&proc_subdir_lock);
8ce584c7
AV
599 return -ENOENT;
600 }
601 len = strlen(fn);
602
710585d4 603 root = pde_subdir_find(parent, fn, len);
8ce584c7 604 if (!root) {
ecf1a3df 605 write_unlock(&proc_subdir_lock);
8ce584c7
AV
606 return -ENOENT;
607 }
710585d4
ND
608 rb_erase(&root->subdir_node, &parent->subdir);
609
8ce584c7
AV
610 de = root;
611 while (1) {
710585d4 612 next = pde_subdir_first(de);
8ce584c7 613 if (next) {
710585d4 614 rb_erase(&next->subdir_node, &de->subdir);
8ce584c7
AV
615 de = next;
616 continue;
617 }
ecf1a3df 618 write_unlock(&proc_subdir_lock);
8ce584c7 619
866ad9a7 620 proc_entry_rundown(de);
8ce584c7
AV
621 next = de->parent;
622 if (S_ISDIR(de->mode))
623 next->nlink--;
624 de->nlink = 0;
625 if (de == root)
626 break;
627 pde_put(de);
628
ecf1a3df 629 write_lock(&proc_subdir_lock);
8ce584c7
AV
630 de = next;
631 }
632 pde_put(root);
633 return 0;
634}
635EXPORT_SYMBOL(remove_proc_subtree);
4a520d27
DH
636
637void *proc_get_parent_data(const struct inode *inode)
638{
639 struct proc_dir_entry *de = PDE(inode);
640 return de->parent->data;
641}
642EXPORT_SYMBOL_GPL(proc_get_parent_data);
a8ca16ea
DH
643
644void proc_remove(struct proc_dir_entry *de)
645{
646 if (de)
647 remove_proc_subtree(de->name, de->parent);
648}
649EXPORT_SYMBOL(proc_remove);
c30480b9
DH
650
651void *PDE_DATA(const struct inode *inode)
652{
653 return __PDE_DATA(inode);
654}
655EXPORT_SYMBOL(PDE_DATA);