All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
To: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Felipe Balbi <balbi@ti.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Joel Becker <jlbec@evilplan.org>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>
Subject: [RFC 1/2] fs: configfs: add check_rmdir operation
Date: Thu, 21 Jun 2012 12:55:28 +0200	[thread overview]
Message-ID: <1340276129-20023-2-git-send-email-andrzej.p@samsung.com> (raw)
In-Reply-To: <1340276129-20023-1-git-send-email-andrzej.p@samsung.com>

The logic behind a subsystem which uses configfs might be that it is not
desired to allow removing the pseudo directories (items or groups) in a
mounted configfs while some criterion is not met, e.g. while some
actions are in progress. This patch adds a check_rmdir operation to
configfs_item_operations and to configfs_group_operations. The operation,
if provided, is called before actual remove takes place and if the result
is nonzero, the remove is not done and the error it returns is reported.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 fs/configfs/dir.c        |   20 ++++++++++++++++++++
 include/linux/configfs.h |    2 ++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 7e6c52d..de2680f 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -1408,12 +1408,32 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
 		dead_item_owner = item->ci_type->ct_owner;
 
 	if (sd->s_type & CONFIGFS_USET_DIR) {
+		if (item->ci_type && item->ci_type->ct_group_ops &&
+		    item->ci_type->ct_group_ops->check_rmdir) {
+		    	ret = item->ci_type->ct_group_ops->check_rmdir(
+				to_config_group(parent_item), item);
+			if (ret) {
+				config_item_put(item);
+				configfs_detach_rollback(dentry);
+				return ret;
+			}
+		}
 		configfs_detach_group(item);
 
 		mutex_lock(&subsys->su_mutex);
 		client_disconnect_notify(parent_item, item);
 		unlink_group(to_config_group(item));
 	} else {
+		if (item->ci_type && item->ci_type->ct_item_ops &&
+		    item->ci_type->ct_item_ops->check_rmdir) {
+		    	ret = item->ci_type->ct_item_ops->check_rmdir(
+				to_config_group(parent_item), item);
+			if (ret) {
+				config_item_put(item);
+				configfs_detach_rollback(dentry);
+				return ret;
+			}
+		}
 		configfs_detach_item(item);
 
 		mutex_lock(&subsys->su_mutex);
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 34025df..f356a55 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -225,6 +225,7 @@ struct configfs_item_operations {
 	void (*release)(struct config_item *);
 	ssize_t	(*show_attribute)(struct config_item *, struct configfs_attribute *,char *);
 	ssize_t	(*store_attribute)(struct config_item *,struct configfs_attribute *,const char *, size_t);
+	int (*check_rmdir)(struct config_group *group, struct config_item *item);
 	int (*allow_link)(struct config_item *src, struct config_item *target);
 	int (*drop_link)(struct config_item *src, struct config_item *target);
 };
@@ -233,6 +234,7 @@ struct configfs_group_operations {
 	struct config_item *(*make_item)(struct config_group *group, const char *name);
 	struct config_group *(*make_group)(struct config_group *group, const char *name);
 	int (*commit_item)(struct config_item *item);
+	int (*check_rmdir)(struct config_group *group, struct config_item *item);
 	void (*disconnect_notify)(struct config_group *group, struct config_item *item);
 	void (*drop_item)(struct config_group *group, struct config_item *item);
 };
-- 
1.7.0.4


  reply	other threads:[~2012-06-21 10:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-21 10:55 [RFC 0/2] USB gadget - configfs Andrzej Pietrasiewicz
2012-06-21 10:55 ` Andrzej Pietrasiewicz [this message]
2012-07-02  8:49   ` [RFC 1/2] fs: configfs: add check_rmdir operation Joel Becker
2012-06-21 10:55 ` [RFC 2/2] usb: gadget: Add USB Functions Gadget Andrzej Pietrasiewicz
2012-06-21 11:34 ` [RFC 0/2] USB gadget - configfs Sebastian Andrzej Siewior
2012-06-24 19:50 ` Sebastian Andrzej Siewior
2012-06-25 14:11   ` Alan Stern
2012-07-03 16:15     ` Felipe Balbi
2012-07-02  9:09 ` Joel Becker
2012-07-10  8:54   ` Andrzej Pietrasiewicz
2012-08-15  8:13     ` Joel Becker
2012-08-16 13:17       ` Andrzej Pietrasiewicz
2012-08-16 13:47         ` Sebastian Andrzej Siewior
2012-08-17  1:46           ` Joel Becker
2012-08-17  9:22             ` Sebastian Andrzej Siewior
2012-08-17 10:30               ` Andrzej Pietrasiewicz
2012-08-17 10:34                 ` Sebastian Andrzej Siewior
2012-08-20  5:59                   ` Joel Becker
2012-08-20  8:53                     ` Andrzej Pietrasiewicz
2012-08-20 11:17                       ` Joel Becker
2012-08-20 11:01                     ` Sebastian Andrzej Siewior
2012-08-20 11:19                       ` Joel Becker
2012-08-21  8:19                       ` Andrzej Pietrasiewicz
2012-08-29 19:52                         ` Sebastian Andrzej Siewior
2012-08-29 13:17                     ` Andrzej Pietrasiewicz

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=1340276129-20023-2-git-send-email-andrzej.p@samsung.com \
    --to=andrzej.p@samsung.com \
    --cc=balbi@ti.com \
    --cc=bigeasy@linutronix.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jlbec@evilplan.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    /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.