Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754806AbYGDBME (ORCPT ); Thu, 3 Jul 2008 21:12:04 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754104AbYGDBLk (ORCPT ); Thu, 3 Jul 2008 21:11:40 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:37097 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753053AbYGDBLj (ORCPT ); Thu, 3 Jul 2008 21:11:39 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Greg Kroah-Hartman , Andrew Morton Cc: Tejun Heo , Daniel Lezcano , linux-kernel@vger.kernel.org, Al Viro , Linux Containers , Benjamin Thery , References: <20080618170729.808539948@theryb.frec.bull.fr> <486706C9.9040303@gmail.com> <4869D314.5030403@gmail.com> <486A0751.9080602@gmail.com> <486AF4FA.8020805@gmail.com> <486B060C.7030607@gmail.com> <486C4515.1070007@gmail.com> <486CB051.5000507@fr.ibm.com> <486CF71F.5090405@gmail.com> Date: Thu, 03 Jul 2008 18:09:04 -0700 In-Reply-To: (Eric W. Biederman's message of "Thu, 03 Jul 2008 18:08:02 -0700") Message-ID: User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SA-Exim-Connect-IP: 24.130.11.59 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-DCC: XMission; sa03 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Greg Kroah-Hartman , Andrew Morton X-Spam-Relay-Country: X-Spam-Report: * -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP * -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% * [score: 0.0000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa03 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 XM_SPF_Neutral SPF-Neutral Subject: [PATCH 04/15] sysfs: Implement __sysfs_get_dentry X-SA-Exim-Version: 4.2 (built Thu, 03 Mar 2005 10:44:12 +0100) X-SA-Exim-Scanned: Yes (on mgr1.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2002 Lines: 70 This function is similar but much simpler to sysfs_get_dentry returns a sysfs dentry if one curently exists. Signed-off-by: Eric W. Biederman Signed-off-by: Benjamin Thery Signed-off-by: Daniel Lezcano Acked-by: Tejun Heo --- fs/sysfs/dir.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 69c40ed..df9934a 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -764,6 +764,45 @@ void sysfs_remove_dir(struct kobject * kobj) __sysfs_remove_dir(sd); } +/** + * __sysfs_get_dentry - get dentry for the given sysfs_dirent + * @sb: superblock of the dentry to return + * @sd: sysfs_dirent of interest + * + * Get dentry for @sd. Only return a dentry if one currently + * exists. + * + * LOCKING: + * Kernel thread context (may sleep) + * + * RETURNS: + * Pointer to found dentry on success, NULL on failure. + */ +static struct dentry *__sysfs_get_dentry(struct super_block *sb, + struct sysfs_dirent *sd) +{ + struct inode *inode; + struct dentry *dentry = NULL; + + inode = ilookup5_nowait(sysfs_sb, sd->s_ino, sysfs_ilookup_test, sd); + if (inode && !(inode->i_state & I_NEW)) { + struct dentry *alias; + spin_lock(&dcache_lock); + list_for_each_entry(alias, &inode->i_dentry, d_alias) { + if (!IS_ROOT(alias) && d_unhashed(alias)) + continue; + if (alias->d_sb != sb) + continue; + dentry = alias; + dget_locked(dentry); + break; + } + spin_unlock(&dcache_lock); + } + iput(inode); + return dentry; +} + int sysfs_rename_dir(struct kobject * kobj, const char *new_name) { struct sysfs_dirent *sd = kobj->sd; -- 1.5.3.rc6.17.g1911 -- 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/