From ca92ebb99ebdc603bce8d23b68d260f6495f2b2f Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Thu, 9 May 2013 19:45:28 +0800 Subject: [PATCH 1/4] proc: add a child pde search helper Lustre needs to lookup pde when knowning parents. And now that proc_dir_entry is internal, add a helper to export this functionality. Cc: David Howells Signed-off-by: Peng Tao --- fs/proc/generic.c | 19 +++++++++++++++++++ include/linux/proc_fs.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/fs/proc/generic.c b/fs/proc/generic.c index a2596af..ba7ce8e 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c @@ -224,6 +224,25 @@ struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry, return proc_lookup_de(PDE(dir), dir, dentry); } +struct proc_dir_entry *proc_lookup_child_pde(struct proc_dir_entry *de, + const char *name, u8 len) +{ + struct proc_dir_entry *child = NULL; + + spin_lock(&proc_subdir_lock); + for (de = de->subdir; de; de = de->next) { + if (de->namelen == len && + !memcmp(de->name, name, len)) { + child = de; + break; + } + } + spin_unlock(&proc_subdir_lock); + + return child; +} +EXPORT_SYMBOL(proc_lookup_child_pde); + /* * This returns non-zero if at EOF, so that the /proc * root directory can use this and check if it should diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 608e60a..ca79742 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -14,6 +14,8 @@ struct proc_dir_entry; extern void proc_root_init(void); extern void proc_flush_task(struct task_struct *); +extern struct proc_dir_entry *proc_lookup_child_pde(struct proc_dir_entry *, + const char *, u8); extern struct proc_dir_entry *proc_symlink(const char *, struct proc_dir_entry *, const char *); extern struct proc_dir_entry *proc_mkdir(const char *, struct proc_dir_entry *); -- 1.7.9.5