[PATCH 03/15] sysfs: sysfs_get_dentry add a sb parameter

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Greg Kroah-Hartman <gregkh@...>, Andrew Morton <akpm@...>
Cc: Tejun Heo <htejun@...>, Daniel Lezcano <dlezcano@...>, <linux-kernel@...>, Al Viro <viro@...>, Linux Containers <containers@...>, Benjamin Thery <benjamin.thery@...>, <netdev@...>
Date: Thursday, July 3, 2008 - 9:08 pm

In preparation for multiple mounts of sysfs add a superblock parameter to
sysfs_get_dentry.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Acked-by: Tejun Heo <tj@kernel.org>
---
 fs/sysfs/dir.c   |   12 +++++++-----
 fs/sysfs/file.c  |    2 +-
 fs/sysfs/sysfs.h |    3 ++-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 146b86a..69c40ed 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -85,6 +85,7 @@ static void sysfs_unlink_sibling(struct sysfs_dirent *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.  Dentry is looked up if currently not
@@ -97,9 +98,10 @@ static void sysfs_unlink_sibling(struct sysfs_dirent *sd)
  *	RETURNS:
  *	Pointer to found dentry on success, ERR_PTR() value on error.
  */
-struct dentry *sysfs_get_dentry(struct sysfs_dirent *sd)
+struct dentry *sysfs_get_dentry(struct super_block *sb,
+				struct sysfs_dirent *sd)
 {
-	struct dentry *dentry = dget(sysfs_sb->s_root);
+	struct dentry *dentry = dget(sb->s_root);
 
 	while (dentry->d_fsdata != sd) {
 		struct sysfs_dirent *cur;
@@ -777,7 +779,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
 		goto out;	/* nothing to rename */
 
 	/* get the original dentry */
-	old_dentry = sysfs_get_dentry(sd);
+	old_dentry = sysfs_get_dentry(sysfs_sb, sd);
 	if (IS_ERR(old_dentry)) {
 		error = PTR_ERR(old_dentry);
 		old_dentry = NULL;
@@ -841,7 +843,7 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)
 		goto out;	/* nothing to move */
 
 	/* get dentries */
-	old_dentry = sysfs_get_dentry(sd);
+	old_dentry = sysfs_get_dentry(sysfs_sb, sd);
 	if (IS_ERR(old_dentry)) {
 		error = PTR_ERR(old_dentry);
 		old_dentry = NULL;
@@ -849,7 +851,7 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)
 	}
 	old_parent = old_dentry->d_parent;
 
-	new_parent = sysfs_get_dentry(new_parent_sd);
+	new_parent = sysfs_get_dentry(sysfs_sb, new_parent_sd);
 	if (IS_ERR(new_parent)) {
 		error = PTR_ERR(new_parent);
 		new_parent = NULL;
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 15ff679..cb5dd3f 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -585,7 +585,7 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
 		goto out;
 
 	mutex_lock(&sysfs_rename_mutex);
-	victim = sysfs_get_dentry(victim_sd);
+	victim = sysfs_get_dentry(sysfs_sb, victim_sd);
 	mutex_unlock(&sysfs_rename_mutex);
 	if (IS_ERR(victim)) {
 		rc = PTR_ERR(victim);
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 0fdc3de..b1bdc6e 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -113,7 +113,8 @@ extern spinlock_t sysfs_assoc_lock;
 extern const struct file_operations sysfs_dir_operations;
 extern const struct inode_operations sysfs_dir_inode_operations;
 
-struct dentry *sysfs_get_dentry(struct sysfs_dirent *sd);
+struct dentry *sysfs_get_dentry(struct super_block *sb,
+				struct sysfs_dirent *sd);
 struct sysfs_dirent *sysfs_get_active_two(struct sysfs_dirent *sd);
 void sysfs_put_active_two(struct sysfs_dirent *sd);
 void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
-- 
1.5.3.rc6.17.g1911

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 06/11] sysfs: Implement sysfs tagged directory su..., Eric W. Biederman, (Thu Jun 26, 4:21 pm)
Re: [PATCH 06/11] sysfs: Implement sysfs tagged directory su..., Eric W. Biederman, (Mon Jun 30, 2:56 pm)
Re: [PATCH 06/11] sysfs: Implement sysfs tagged directory su..., Eric W. Biederman, (Tue Jul 1, 11:53 pm)
Re: [PATCH 06/11] sysfs: Implement sysfs tagged directory su..., Eric W. Biederman, (Wed Jul 2, 12:49 pm)
[PATCH 00/15] sysfs support for namespaces, Eric W. Biederman, (Thu Jul 3, 8:48 pm)
Re: [PATCH 00/15] sysfs support for namespaces, Eric W. Biederman, (Sun Jul 6, 12:42 am)
Re: [PATCH 00/15] sysfs support for namespaces, Cornelia Huck, (Mon Jul 7, 7:41 am)
Re: [PATCH 00/15] sysfs support for namespaces, Eric W. Biederman, (Mon Jul 7, 8:22 am)
Re: [PATCH 00/15] sysfs support for namespaces, Eric W. Biederman, (Thu Jul 3, 9:27 pm)
[PATCH 02/15] sysfs: Support for preventing unmounts., Eric W. Biederman, (Thu Jul 3, 9:07 pm)
[PATCH 03/15] sysfs: sysfs_get_dentry add a sb parameter, Eric W. Biederman, (Thu Jul 3, 9:08 pm)
[PATCH 04/15] sysfs: Implement __sysfs_get_dentry, Eric W. Biederman, (Thu Jul 3, 9:09 pm)
[PATCH 05/15] sysfs: Rename Support multiple superblocks, Eric W. Biederman, (Thu Jul 3, 9:10 pm)
[PATCH 06/15] Introduce sysfs_sd_setattr and fix sysfs_chmod, Eric W. Biederman, (Thu Jul 3, 9:11 pm)
[PATCH 08/15] sysfs: Make sysfs_mount static once again., Eric W. Biederman, (Thu Jul 3, 9:14 pm)
[PATCH 0/8] sysfs namespace support, Eric W. Biederman, (Thu Aug 21, 2:31 am)
[PATCH 1/8] sysfs: Implement sysfs tagged directory support., Eric W. Biederman, (Thu Aug 21, 2:33 am)
Re: [PATCH 1/8] sysfs: Implement sysfs tagged directory supp..., Eric W. Biederman, (Mon Oct 13, 11:20 pm)
[PATCH 2/8] sysfs: Merge sysfs_rename_dir and sysfs_move_dir, Eric W. Biederman, (Thu Aug 21, 2:34 am)
[PATCH 3/8] sysfs: Implement sysfs_delete_link and sysfs_ren..., Eric W. Biederman, (Thu Aug 21, 2:35 am)
[PATCH 4/8] driver core: Implement tagged directory support ..., Eric W. Biederman, (Thu Aug 21, 2:37 am)
[PATCH 5/8] sysfs: Remove sysfs_create_link_nowarn, Eric W. Biederman, (Thu Aug 21, 2:36 am)
[PATCH 6/8] Revert "netns: Fix device renaming for sysfs", Eric W. Biederman, (Thu Aug 21, 2:38 am)
[PATCH 7/8] netns: Enable tagging for net_class directories ..., Eric W. Biederman, (Thu Aug 21, 2:39 am)
[PATCH 8/8] sysfs: user namespaces: fix bug with clone(CLONE..., Eric W. Biederman, (Thu Aug 21, 2:40 am)
Re: [PATCH 0/8] sysfs namespace support, David Miller, (Thu Aug 21, 2:37 am)
Re: [PATCH 09/15] sysfs: Implement sysfs tagged directory su..., Eric W. Biederman, (Wed Aug 20, 2:58 am)
Re: [PATCH 12/15] driver core: Implement tagged directory su..., Eric W. Biederman, (Sun Jul 13, 9:54 pm)
Re: [PATCH 12/15] driver core: Implement tagged directory su..., Eric W. Biederman, (Fri Jul 18, 4:19 pm)
Re: [PATCH 12/15] driver core: Implement tagged directory su..., Eric W. Biederman, (Wed Jul 16, 1:41 am)
Re: [PATCH 12/15] driver core: Implement tagged directory su..., Eric W. Biederman, (Wed Jul 16, 2:32 am)
Re: [PATCH 12/15] driver core: Implement tagged directory su..., Eric W. Biederman, (Wed Jul 16, 5:09 pm)
Re: [PATCH 12/15] driver core: Implement tagged directory su..., Eric W. Biederman, (Wed Jul 16, 3:07 pm)
[PATCH 13/15] Revert "netns: Fix device renaming for sysfs", Eric W. Biederman, (Thu Jul 3, 9:21 pm)