From: "Serge E. Hallyn" <serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org>
To: Chen Hanxiao <chenhanxiao-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
Cc: Richard Weinberger
<richard.weinberger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
Serge Hallyn
<serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Oleg Nesterov <oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
"Eric W. Biederman"
<ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>,
Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
Subject: Re: [RFC PATCH 1/3] procfs: check uniq proc_dir_entry subdir name
Date: Wed, 10 Sep 2014 01:17:15 +0200 [thread overview]
Message-ID: <20140909231715.GA25668@mail.hallyn.com> (raw)
In-Reply-To: <1409740200-26461-2-git-send-email-chenhanxiao-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
Quoting Chen Hanxiao (chenhanxiao-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org):
> Check whether a proc dir has a subdir
> with a specific name.
> Will be used in a later patch.
>
> Signed-off-by: Chen Hanxiao <chenhanxiao-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
> ---
> fs/proc/generic.c | 15 +++++++++++++++
> include/linux/proc_fs.h | 3 +++
> 2 files changed, 18 insertions(+)
>
> diff --git a/fs/proc/generic.c b/fs/proc/generic.c
> index b7f268e..4d576c2 100644
> --- a/fs/proc/generic.c
> +++ b/fs/proc/generic.c
> @@ -173,6 +173,21 @@ static const struct inode_operations proc_link_inode_operations = {
> .follow_link = proc_follow_link,
> };
>
> +/* check whether dir has @name member */
> +struct proc_dir_entry *proc_uniq_dir(struct proc_dir_entry *de, char *name)
> +{
> + spin_lock(&proc_subdir_lock);
> + for (de = de->subdir; de ; de = de->next) {
> + if (!strcmp(de->name, name)) {
Should you pde_get(de) here?
> + spin_unlock(&proc_subdir_lock);
> + return de;
> + }
> + }
> + spin_unlock(&proc_subdir_lock);
> + return NULL;
> +}
> +EXPORT_SYMBOL(proc_uniq_dir);
> +
> /*
> * Don't create negative dentries here, return -ENOENT by hand
> * instead.
> diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
> index 9d117f6..38e87aa 100644
> --- a/include/linux/proc_fs.h
> +++ b/include/linux/proc_fs.h
> @@ -41,6 +41,7 @@ extern void *proc_get_parent_data(const struct inode *);
> extern void proc_remove(struct proc_dir_entry *);
> extern void remove_proc_entry(const char *, struct proc_dir_entry *);
> extern int remove_proc_subtree(const char *, struct proc_dir_entry *);
> +extern struct proc_dir_entry *proc_uniq_dir(struct proc_dir_entry *, char *);
>
> #else /* CONFIG_PROC_FS */
>
> @@ -71,6 +72,8 @@ static inline void *proc_get_parent_data(const struct inode *inode) { BUG(); ret
> static inline void proc_remove(struct proc_dir_entry *de) {}
> #define remove_proc_entry(name, parent) do {} while (0)
> static inline int remove_proc_subtree(const char *name, struct proc_dir_entry *parent) { return 0; }
> +static inline struct proc_dir_entry *proc_uniq_dir(struct proc_dir_entry *,
> + char *) {return 0; }
>
> #endif /* CONFIG_PROC_FS */
>
> --
> 1.9.0
>
> _______________________________________________
> Containers mailing list
> Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
> https://lists.linuxfoundation.org/mailman/listinfo/containers
next prev parent reply other threads:[~2014-09-09 23:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-03 10:29 [RFC PATCH 0/3] ns, procfs: pid conversion between ns and showing pidns hierarchy Chen Hanxiao
[not found] ` <1409740200-26461-1-git-send-email-chenhanxiao-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2014-09-03 10:29 ` [RFC PATCH 1/3] procfs: check uniq proc_dir_entry subdir name Chen Hanxiao
[not found] ` <1409740200-26461-2-git-send-email-chenhanxiao-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2014-09-09 23:17 ` Serge E. Hallyn [this message]
2014-09-03 10:29 ` [RFC PATCH 2/3] procfs: show hierarchy of pid namespace Chen Hanxiao
[not found] ` <1409740200-26461-3-git-send-email-chenhanxiao-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2014-09-03 12:46 ` Vasiliy Kulikov
2014-09-10 16:23 ` Serge E. Hallyn
[not found] ` <20140910162315.GB7748-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2014-09-11 9:48 ` Chen, Hanxiao
2014-09-03 10:30 ` [PATCH 3/3] /proc/pid/status: show all sets of pid according to ns Chen Hanxiao
2014-09-05 5:21 ` [RFC PATCH 0/3] ns, procfs: pid conversion between ns and showing pidns hierarchy Chen, Hanxiao
2014-09-12 22:18 ` Serge E. Hallyn
[not found] ` <20140912221852.GA18234-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2014-09-16 9:06 ` Chen, Hanxiao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140909231715.GA25668@mail.hallyn.com \
--to=serge-a9i7lubdfnhqt0dzr+alfa@public.gmane.org \
--cc=chenhanxiao-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=richard.weinberger-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox