From: Joel Becker <jlbec@evilplan.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org, andrzej.p@samsung.com,
linux-usb@vger.kernel.org
Subject: Re: [PATCH] fs/configfs: allow to create groups on demand
Date: Fri, 7 Dec 2012 15:20:01 -0800 [thread overview]
Message-ID: <20121207232000.GN22789@localhost> (raw)
In-Reply-To: <20121129164123.GA8551@linutronix.de>
On Thu, Nov 29, 2012 at 05:41:23PM +0100, Sebastian Andrzej Siewior wrote:
> This patch adds a function add a group to an existing one and its
> counterart. The newly created group behaves as it would be created via
> default_groups[] which means the user can't rmdir it.
> This should be used by the upcomming USB gadget interface in order to
> add the currently available UDCs as a child of the UDC node. The UDC
> itself will appear once the hardware driver is loaded and can appear
> later.
I've now responded to the original thread. Sorry I didn't notice last
week. Please see my thoughts there and comment.
Joel
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> fs/configfs/dir.c | 63 ++++++++++++++++++++++++++++++++++------------
> include/linux/configfs.h | 4 +++
> 2 files changed, 51 insertions(+), 16 deletions(-)
>
> diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
> index 7414ae2..50ee2bd 100644
> --- a/fs/configfs/dir.c
> +++ b/fs/configfs/dir.c
> @@ -1663,19 +1663,13 @@ const struct file_operations configfs_dir_operations = {
> .readdir = configfs_readdir,
> };
>
> -int configfs_register_subsystem(struct configfs_subsystem *subsys)
> +static int __create_group(struct config_group *group, struct dentry *root)
> {
> int err;
> - struct config_group *group = &subsys->su_group;
> struct qstr name;
> struct dentry *dentry;
> - struct dentry *root;
> struct configfs_dirent *sd;
>
> - root = configfs_pin_fs();
> - if (IS_ERR(root))
> - return PTR_ERR(root);
> -
> if (!group->cg_item.ci_name)
> group->cg_item.ci_name = group->cg_item.ci_namebuf;
>
> @@ -1708,25 +1702,48 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
>
> mutex_unlock(&root->d_inode->i_mutex);
>
> - if (err) {
> + if (err)
> unlink_group(group);
> - configfs_release_fs();
> +
> + return err;
> +}
> +
> +int configfs_create_group(struct config_group *parent, struct config_group *new)
> +{
> + int ret;
> +
> + ret = __create_group(new, parent->cg_item.ci_dentry);
> + if (!ret) {
> + struct configfs_dirent *sd = new->cg_item.ci_dentry->d_fsdata;
> +
> + sd->s_type |= CONFIGFS_USET_DEFAULT;
> }
>
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(configfs_create_group);
> +
> +int configfs_register_subsystem(struct configfs_subsystem *subsys)
> +{
> + int err;
> + struct dentry *root;
> +
> + root = configfs_pin_fs();
> + if (IS_ERR(root))
> + return PTR_ERR(root);
> +
> + err = __create_group(&subsys->su_group, root);
> + if (err)
> + configfs_release_fs();
> +
> return err;
> }
>
> -void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
> +void configfs_remove_group(struct config_group *group)
> {
> - struct config_group *group = &subsys->su_group;
> struct dentry *dentry = group->cg_item.ci_dentry;
> struct dentry *root = dentry->d_sb->s_root;
>
> - if (dentry->d_parent != root) {
> - printk(KERN_ERR "configfs: Tried to unregister non-subsystem!\n");
> - return;
> - }
> -
> mutex_lock_nested(&root->d_inode->i_mutex,
> I_MUTEX_PARENT);
> mutex_lock_nested(&dentry->d_inode->i_mutex, I_MUTEX_CHILD);
> @@ -1749,6 +1766,20 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
> dput(dentry);
>
> unlink_group(group);
> +}
> +EXPORT_SYMBOL_GPL(configfs_remove_group);
> +
> +void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
> +{
> + struct config_group *group = &subsys->su_group;
> + struct dentry *dentry = group->cg_item.ci_dentry;
> + struct dentry *root = dentry->d_sb->s_root;
> +
> + if (dentry->d_parent != root) {
> + pr_err("configfs: Tried to unregister non-subsystem!\n");
> + return;
> + }
> + configfs_remove_group(group);
> configfs_release_fs();
> }
>
> diff --git a/include/linux/configfs.h b/include/linux/configfs.h
> index 34025df..660c25d 100644
> --- a/include/linux/configfs.h
> +++ b/include/linux/configfs.h
> @@ -249,6 +249,10 @@ static inline struct configfs_subsystem *to_configfs_subsystem(struct config_gro
> NULL;
> }
>
> +int configfs_create_group(struct config_group *parent,
> + struct config_group *new);
> +void configfs_remove_group(struct config_group *group);
> +
> int configfs_register_subsystem(struct configfs_subsystem *subsys);
> void configfs_unregister_subsystem(struct configfs_subsystem *subsys);
>
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
"Friends may come and go, but enemies accumulate."
- Thomas Jones
http://www.jlbec.org/
jlbec@evilplan.org
prev parent reply other threads:[~2012-12-07 23:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-29 16:41 [PATCH] fs/configfs: allow to create groups on demand Sebastian Andrzej Siewior
2012-11-30 8:34 ` Andrzej Pietrasiewicz
2012-12-07 23:20 ` Joel Becker [this message]
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=20121207232000.GN22789@localhost \
--to=jlbec@evilplan.org \
--cc=andrzej.p@samsung.com \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.