[PATCH 04/15] sysfs: Implement __sysfs_get_dentry

Subsystems: driver core, kobjects, debugfs and sysfs, filesystems (vfs and infrastructure), the rest · Maintainers: Greg Kroah-Hartman, "Rafael J. Wysocki", Danilo Krummrich, Johan Hovold, Alexander Viro, Christian Brauner, Linus Torvalds

STALE6641d REVIEWED: 1 (1M)

Status: Reviewed.

1 review trailer.

2 messages, 2 authors, 2008-08-20 · open the first message on its own page

[PATCH 04/15] sysfs: Implement __sysfs_get_dentry

From: Eric W. Biederman <hidden>
Date: 2008-07-04 01:12:04

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 <redacted>
Signed-off-by: Benjamin Thery <redacted>
Signed-off-by: Daniel Lezcano <redacted>
Acked-by: Tejun Heo <tj@kernel.org>
---
 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

patch sysfs-implement-__sysfs_get_dentry.patch added to gregkh-2.6 tree

From: gregkh@suse.de
Date: 2008-08-20 02:20:55

This is a note to let you know that I've just added the patch titled

    Subject: sysfs: Implement __sysfs_get_dentry

to my gregkh-2.6 tree.  Its filename is

    sysfs-implement-__sysfs_get_dentry.patch

This tree can be found at 
    http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/

From ebiederm@xmission.com Thu Jul  3 18:11:48 2008
From: <redacted> (Eric W. Biederman)
Date: Thu, 03 Jul 2008 18:09:04 -0700
Subject: sysfs: Implement __sysfs_get_dentry
To: Greg Kroah-Hartman <gregkh@suse.de>, Andrew Morton <akpm@linux-foundation.org>
Cc: Tejun Heo <redacted>, Daniel Lezcano <redacted>, <redacted>, Al Viro <redacted>, Linux Containers <redacted>, Benjamin Thery <redacted>, <redacted>
Message-ID: [off-list ref]

From: Eric W. Biederman <redacted>


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 <redacted>
Signed-off-by: Benjamin Thery <redacted>
Signed-off-by: Daniel Lezcano <redacted>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 fs/sysfs/dir.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -795,6 +795,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;

Patches currently in gregkh-2.6 which might be from gregkh@suse.de are

.git/logs/refs/heads/master
.git/logs/refs/heads/origin
.git/logs/refs/remotes/aria/master
.git/logs/refs/remotes/aria/origin
.git/logs/HEAD
bad/pci-domain/pci-device-ensure-sysdata-initialised.patch
bad/pci-domain/pci-fix-the-x86-pci-domain-support-fix.patch
bad/pci-domain/x86-pci-domain-support-struct-pci_sysdata.patch
bad/pci-domain/x86-pci-domain-support-a-humble-fix.patch
bad/pci-domain/x86-pci-domain-support-the-meat.patch
bad/relayfs/relay-consolidate-relayfs-core-into-kernel-relay.c.patch
bad/relayfs/relay-relay-header-cleanup.patch
bad/relayfs/sysfs-add-__attr_relay-helper-for-relay-attributes.patch
bad/relayfs/sysfs-relay-channel-buffers-as-sysfs-attributes.patch
bad/usbip/usb-usbip-more-dead-code-fix.patch
bad/usbip/usb-usbip-build-fix.patch
bad/usbip/usb-usbip-warning-fixes.patch
bad/ndevfs.patch
bad/driver-sample.sh.patch
bad/driver-model-convert-driver-model-to-mutexes.patch
bad/gpl_future-test.patch
bad/gregkh-debugfs_example.patch
bad/i2c-device-id-lm75.patch
bad/speakup-kconfig-fix.patch
bad/speakup-build-fix.patch
bad/pci-test-that-drivers-properly-call-pci_set_master.patch
bad/pci-use-new-multi-phase-suspend-infrastructure.patch
bad/speakup-core.patch
bad/uio.patch
bad/usbfs2.patch
bad/no-more-non-gpl-modules.patch
bad/usb-serial-serqt_usb.patch
bad/spi-device.patch
bad/ata_piix-multithread.patch
bad/uio-irq.patch
bad/sysfs-crash-debugging.patch
bad/pci-dynamic-id-cleanup.patch
bad/pci-piggy-bus.patch

115 more lines

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help