Home » Mailing lists » Devel » [PATCH 0/25] Sysfs cleanups & tagged directory support
[PATCH 17/25] sysfs: Rewrite rename in terms of sysfs dirents [message #19579 is a reply to message #19578] |
Tue, 07 August 2007 21:27 |
ebiederm
Messages: 1354 Registered: February 2006
|
Senior Member |
|
|
This patch rewrites sysfs_rename_dir to perform it's checks
as much as possible on the underlying sysfs_dirents instead
of the contents of the dcache. It turns out that this version
is a little simpler, and a little more like the rest of
the sysfs directory modification code.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
fs/sysfs/dir.c | 36 ++++++++++++++++--------------------
1 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 1d53c2a..3228f5a 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -855,7 +855,7 @@ struct dentry *sysfs_get_dentry(struct sysfs_dirent *sd)
int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
{
- struct sysfs_dirent *sd;
+ struct sysfs_dirent *sd = kobj->sd;
struct dentry *parent = NULL;
struct dentry *old_dentry = NULL, *new_dentry = NULL;
const char *dup_name = NULL;
@@ -863,42 +863,41 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
mutex_lock(&sysfs_rename_mutex);
+ error = 0;
+ if (strcmp(sd->s_name, new_name) == 0)
+ goto out; /* nothing to rename */
+
/* get the original dentry */
- sd = kobj->sd;
old_dentry = sysfs_get_dentry(sd);
if (IS_ERR(old_dentry)) {
error = PTR_ERR(old_dentry);
- goto out_dput;
+ goto out;
}
parent = old_dentry->d_parent;
/* lock parent and get dentry for new name */
mutex_lock(&parent->d_inode->i_mutex);
+ mutex_lock(&sysfs_mutex);
- new_dentry = lookup_one_len(new_name, parent, strlen(new_name));
- if (IS_ERR(new_dentry)) {
- error = PTR_ERR(new_dentry);
- goto out_unlock;
- }
-
- error = -EINVAL;
- if (old_dentry == new_dentry)
+ error = -EEXIST;
+ if (sysfs_find_dirent(sd->s_parent, new_name))
goto out_unlock;
- error = -EEXIST;
- if (new_dentry->d_inode)
+ error = -ENOMEM;
+ new_dentry = d_alloc_name(parent, new_name);
+ if (!new_dentry)
goto out_unlock;
/* rename kobject and sysfs_dirent */
error = -ENOMEM;
new_name = dup_name = kstrdup(new_name, GFP_KERNEL);
if (!new_name)
- goto out_drop;
+ goto out_unlock;
error = kobject_set_name(kobj, "%s", new_name);
if (error)
- goto out_drop;
+ goto out_unlock;
mutex_lock(&sysfs_mutex);
dup_name = sd->s_name;
@@ -910,16 +909,13 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
d_move(old_dentry, new_dentry);
error = 0;
- goto out_unlock;
-
- out_drop:
- d_drop(new_dentry);
out_unlock:
+ mutex_unlock(&sysfs_mutex);
mutex_unlock(&parent->d_inode->i_mutex);
- out_dput:
kfree(dup_name);
dput(old_dentry);
dput(new_dentry);
+ out:
mutex_unlock(&sysfs_rename_mutex);
return error;
}
--
1.5.1.1.181.g2de0
_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
|
|
|
|
|
[PATCH 0/25] Sysfs cleanups & tagged directory support
By: ebiederm on Tue, 07 August 2007 21:06
|
|
|
[PATCH 01/25] sysfs: Move all of inode initialization into sysfs_init_inode
By: ebiederm on Tue, 07 August 2007 21:08
|
|
|
[PATCH 02/25] sysfs: Remove sysfs_instantiate
By: ebiederm on Tue, 07 August 2007 21:08
|
|
|
[PATCH 03/25] sysfs: Use kill_anon_super
By: ebiederm on Tue, 07 August 2007 21:10
|
|
|
[PATCH 04/25] sysfs: Make sysfs_mount static
By: ebiederm on Tue, 07 August 2007 21:11
|
|
|
[PATCH 05/25] sysfs: In sysfs_lookup don't open code sysfs_find_dirent
By: ebiederm on Tue, 07 August 2007 21:12
|
|
|
[PATCH 06/25] sysfs: Simplify readdir.
By: ebiederm on Tue, 07 August 2007 21:13
|
|
|
[PATCH 07/25] sysfs: Rewrite sysfs_drop_dentry.
By: ebiederm on Tue, 07 August 2007 21:14
|
|
|
[PATCH 08/25] sysfs: Implement __sysfs_get_dentry
By: ebiederm on Tue, 07 August 2007 21:16
|
|
|
[PATCH 09/25] sysfs: Move sysfs_get_dentry below __sysfs_get_dentry
By: ebiederm on Tue, 07 August 2007 21:17
|
|
|
[PATCH 10/25] sysfs: Rewrite sysfs_get_dentry in terms of __sysfs_get_dentry
By: ebiederm on Tue, 07 August 2007 21:18
|
|
|
[PATCH 11/25] sysfs: Remove s_dentry
By: ebiederm on Tue, 07 August 2007 21:19
|
|
|
[PATCH 12/25] sysfs: Introduce sysfs_rename_mutex
By: ebiederm on Tue, 07 August 2007 21:21
|
|
|
[PATCH 13/25] sysfs: Simply sysfs_get_dentry
By: ebiederm on Tue, 07 August 2007 21:22
|
|
|
[PATCH 14/25] sysfs: Don't use lookup_one_len_kern
By: ebiederm on Tue, 07 August 2007 21:23
|
|
|
[PATCH 15/25] vfs: Remove lookup_one_len_kern
By: ebiederm on Tue, 07 August 2007 21:25
|
|
|
[PATCH 16/25] sysfs: Support for preventing unmounts.
By: ebiederm on Tue, 07 August 2007 21:26
|
|
|
[PATCH 17/25] sysfs: Rewrite rename in terms of sysfs dirents
By: ebiederm on Tue, 07 August 2007 21:27
|
|
|
[PATCH 18/25] sysfs: Rewrite sysfs_move_dir in terms of sysfs dirents
By: ebiederm on Tue, 07 August 2007 21:28
|
|
|
[PATCH 19/25] sysfs: sysfs_get_dentry add a sb parameter
By: ebiederm on Tue, 07 August 2007 21:29
|
|
|
[PATCH 20/25] sysfs: Rename Support multiple superblocks
By: ebiederm on Tue, 07 August 2007 21:31
|
|
|
[PATCH 21/25] sysfs: sysfs_chmod_file handle multiple superblocks
By: ebiederm on Tue, 07 August 2007 21:32
|
|
|
[PATCH 22/25] sysfs: sysfs_uptdate_file handle multiple superblocks
By: ebiederm on Tue, 07 August 2007 21:34
|
|
|
[PATCH 23/25] sysfs: Implement sysfs tagged directory support.
By: ebiederm on Tue, 07 August 2007 21:35
|
|
|
[PATCH 24/25] sysfs: Implement sysfs_delete_link and sysfs_rename_link
By: ebiederm on Tue, 07 August 2007 21:36
|
|
|
[PATCH 25/25] driver core: Implement tagged directory support for device classes.
By: ebiederm on Tue, 07 August 2007 21:36
|
|
|
Re: alternative approached at tagged nodes
|
|
|
Re: [PATCH 22/25] sysfs: sysfs_uptdate_file handle multiple superblocks
|
|
|
Re: [PATCH 21/25] sysfs: sysfs_chmod_file handle multiple superblocks
|
|
|
Re: [PATCH 20/25] sysfs: Rename Support multiple superblocks
By: ebiederm on Wed, 08 August 2007 15:45
|
|
|
Re: [PATCH 20/25] sysfs: Rename Support multiple superblocks
|
|
|
Re: [PATCH 20/25] sysfs: Rename Support multiple superblocks
By: ebiederm on Wed, 08 August 2007 16:35
|
|
|
Re: [PATCH 20/25] sysfs: Rename Support multiple superblocks
|
|
|
Re: [PATCH 20/25] sysfs: Rename Support multiple superblocks
By: ebiederm on Wed, 08 August 2007 16:55
|
|
|
Re: [PATCH 20/25] sysfs: Rename Support multiple superblocks
|
|
|
Re: [PATCH 19/25] sysfs: sysfs_get_dentry add a sb parameter
By: ebiederm on Wed, 08 August 2007 15:34
|
|
|
Re: [PATCH 19/25] sysfs: sysfs_get_dentry add a sb parameter
|
|
|
Re: [PATCH 18/25] sysfs: Rewrite sysfs_move_dir in terms of sysfs dirents
|
|
|
Re: [PATCH 17/25] sysfs: Rewrite rename in terms of sysfs dirents
By: ebiederm on Wed, 08 August 2007 15:32
|
|
|
Re: [PATCH 17/25] sysfs: Rewrite rename in terms of sysfs dirents
|
|
|
Re: [PATCH 15/25] vfs: Remove lookup_one_len_kern
|
|
|
Re: [PATCH 14/25] sysfs: Don't use lookup_one_len_kern
By: ebiederm on Wed, 08 August 2007 15:26
|
|
|
Re: [PATCH 14/25] sysfs: Don't use lookup_one_len_kern
|
|
|
Re: [PATCH 14/25] sysfs: Don't use lookup_one_len_kern
|
|
|
Re: [PATCH 13/25] sysfs: Simply sysfs_get_dentry
|
|
|
Re: [PATCH 12/25] sysfs: Introduce sysfs_rename_mutex
By: ebiederm on Wed, 08 August 2007 08:28
|
|
|
Re: [PATCH 12/25] sysfs: Introduce sysfs_rename_mutex
|
|
|
Re: [PATCH 12/25] sysfs: Introduce sysfs_rename_mutex
|
|
|
Re: [PATCH 11/25] sysfs: Remove s_dentry
|
|
|
Re: [PATCH 10/25] sysfs: Rewrite sysfs_get_dentry in terms of __sysfs_get_dentry
|
|
|
Re: [PATCH 09/25] sysfs: Move sysfs_get_dentry below __sysfs_get_dentry
|
|
|
Re: [PATCH 08/25] sysfs: Implement __sysfs_get_dentry
|
|
|
Re: [PATCH 07/25] sysfs: Rewrite sysfs_drop_dentry.
|
|
|
Re: [PATCH 06/25] sysfs: Simplify readdir.
|
|
|
Re: [PATCH 05/25] sysfs: In sysfs_lookup don't open code sysfs_find_dirent
|
|
|
Re: [PATCH 04/25] sysfs: Make sysfs_mount static
|
|
|
Re: [PATCH 03/25] sysfs: Use kill_anon_super
|
|
|
Re: [PATCH 02/25] sysfs: Remove sysfs_instantiate
|
|
|
Re: [PATCH 01/25] sysfs: Move all of inode initialization into sysfs_init_inode
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
By: ebiederm on Wed, 08 August 2007 07:47
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
By: ebiederm on Wed, 08 August 2007 07:57
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
By: ebiederm on Wed, 08 August 2007 15:08
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
By: ebiederm on Wed, 08 August 2007 15:53
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
By: ebiederm on Wed, 08 August 2007 16:37
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
|
|
Re: [PATCH 0/25] Sysfs cleanups & tagged directory support
|
Goto Forum:
Current Time: Tue Oct 15 13:26:53 GMT 2024
Total time taken to generate the page: 0.08747 seconds
|