Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757058AbYFBNqr (ORCPT ); Mon, 2 Jun 2008 09:46:47 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1761291AbYFBNqE (ORCPT ); Mon, 2 Jun 2008 09:46:04 -0400 Received: from ecfrec.frec.bull.fr ([129.183.4.8]:49050 "EHLO ecfrec.frec.bull.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753698AbYFBNqD (ORCPT ); Mon, 2 Jun 2008 09:46:03 -0400 Message-Id: <20080602134438.769492306@theryb.frec.bull.fr> References: <20080602134438.224352910@theryb.frec.bull.fr> User-Agent: quilt/0.46-1 Date: Mon, 02 Jun 2008 15:45:08 +0200 From: Benjamin Thery To: Andrew Morton Cc: Greg Kroah-Hartman , Eric Biederman , Serge Hallyn , linux-kernel@vger.kernel.org, Tejun Heo , Al Viro , Daniel Lezcano , Benjamin Thery Subject: [PATCH 03/10] sysfs: Implement __sysfs_get_dentry Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1953 Lines: 68 sysfs: Implement __sysfs_get_dentry 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 --- fs/sysfs/dir.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) Index: linux-mm/fs/sysfs/dir.c =================================================================== --- linux-mm.orig/fs/sysfs/dir.c +++ linux-mm/fs/sysfs/dir.c @@ -777,6 +777,45 @@ void sysfs_remove_dir(struct kobject * k __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; -- -- 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/