From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754849Ab0H3JUm (ORCPT ); Mon, 30 Aug 2010 05:20:42 -0400 Received: from smtp101.sbc.mail.gq1.yahoo.com ([67.195.15.60]:41693 "HELO smtp101.sbc.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754768Ab0H3JU2 (ORCPT ); Mon, 30 Aug 2010 05:20:28 -0400 X-Yahoo-SMTP: fzDSGlOswBCWnIOrNw7KwwK1j9PqyNbe5PtLKiS4dDU.UNl_t6bdEZu9tTLW X-YMail-OSG: 5fXWZsgVM1m9VPVkDHiVbcTVZFZJRsmlcnVn1Ef.CkjeA5U 8EMGj3CaRFCqo_Lulha0.ZCgwCoDiSLrXJhq1R2Bywly.5Y6zLRkTXV0peAR 8Dq6MTBP43uKOMd5S0osvmZYH8UXjqWP1WP6gJ34M8rSsWqVM6LDjheDDXlj tW3L8hGoGH3PdxWF_BFXGgBZDwiKA6FQympbZwUIBRJxszEPWseRW5K5DcvV yhdLM_6M2.vZkIWyf..tsn4qu6JV_U56TgQqzR.gPVEJXVEdWHQBqcWLMxjk EuuKPYwF5GlMImmheY9w1h6lX.rqNdWS5JauX.9bASWcTRG61_E47s5o4kCW pjaHVjHJduvow2oANJw-- X-Yahoo-Newman-Property: ymail-3 From: "Nicholas A. Bellinger" To: linux-scsi , linux-kernel Cc: FUJITA Tomonori , Mike Christie , Christoph Hellwig , Hannes Reinecke , James Bottomley , Jens Axboe , Boaz Harrosh , Nicholas Bellinger Subject: [RFC 02/22] configfs: Add struct configfs_item_operations->check_link() in configfs_unlink() Date: Mon, 30 Aug 2010 02:20:25 -0700 Message-Id: <1283160025-6598-1-git-send-email-nab@linux-iscsi.org> X-Mailer: git-send-email 1.5.6.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicholas Bellinger This patch adds a optional struct configfs_item_operations->check_link() check called in fs/configfs/symlink.c:configfs_unlink() that can be used by configfs consumers to check for an explict struct config_group dependence with active symlink and fail with -EPERM before the unlink(2) syscall is allowed to occur. Currently without this patch, there is not a method that a consumer can tell configfs_unlink() that it needs to fail for this particular case. Allowing ->check_link() to propigate up the errno to VFS is also another option for the call, but currently for TCM using the existing -EPERM in configfs_unlink() is fine here. Note this patch is used by TCM v4 generic configfs fabric module infrastructure to allow explict Initiator Port MappedLUNs symlinks to create a dependency for the fabric TPG Port LUNs living in a configfs group that is not a direct struct config_group parent. Signed-off-by: Nicholas A. Bellinger --- fs/configfs/symlink.c | 13 +++++++++++++ include/linux/configfs.h | 1 + 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c index 0f3eb41..b8010de 100644 --- a/fs/configfs/symlink.c +++ b/fs/configfs/symlink.c @@ -205,6 +205,19 @@ int configfs_unlink(struct inode *dir, struct dentry *dentry) parent_item = configfs_get_config_item(dentry->d_parent); type = parent_item->ci_type; + /* + * See if the underlying struct config_item has dependent + * symlinks, and should return -EPERM here. + */ + if (type && type->ct_item_ops && + type->ct_item_ops->check_link) { + if (type->ct_item_ops->check_link(parent_item, + sl->sl_target) != 0) { + config_item_put(parent_item); + goto out; + } + } + spin_lock(&configfs_dirent_lock); list_del_init(&sd->s_sibling); spin_unlock(&configfs_dirent_lock); diff --git a/include/linux/configfs.h b/include/linux/configfs.h index ddb7a97..7c01d86 100644 --- a/include/linux/configfs.h +++ b/include/linux/configfs.h @@ -226,6 +226,7 @@ struct configfs_item_operations { 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 (*allow_link)(struct config_item *src, struct config_item *target); + int (*check_link)(struct config_item *src, struct config_item *target); int (*drop_link)(struct config_item *src, struct config_item *target); }; -- 1.7.2.2