diff options
author | Tejun Heo <tj@kernel.org> | 2013-09-11 22:29:06 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-26 18:30:22 -0400 |
commit | 4b30ee58ee64c64f59fd876e4afa6ed82caef3a4 (patch) | |
tree | 52d26225aec86ae39ed559882a30bec10fdb2031 /drivers/base/core.c | |
parent | e34ff4906199d2ebd248ae897ae34f52bea151c9 (diff) |
sysfs: remove ktype->namespace() invocations in symlink code
There's no reason for sysfs to be calling ktype->namespace(). It is
backwards, obfuscates what's going on and unnecessarily tangles two
separate layers.
There are two places where symlink code calls ktype->namespace().
* sysfs_do_create_link_sd() calls it to find out the namespace tag of
the target directory. Unless symlinking races with cross-namespace
renaming, this equals @target_sd->s_ns.
* sysfs_rename_link() uses it to find out the new namespace to rename
to and the new namespace can be different from the existing one.
The function is renamed to sysfs_rename_link_ns() with an explicit
@ns argument and the ktype->namespace() invocation is shifted to the
device layer.
While this patch replaces ktype->namespace() invocation with the
recorded result in @target_sd, this shouldn't result in any behvior
difference.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Kay Sievers <kay@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index c7cfadcf6752..3335000be2dc 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -1881,6 +1881,7 @@ EXPORT_SYMBOL_GPL(device_destroy); | |||
1881 | */ | 1881 | */ |
1882 | int device_rename(struct device *dev, const char *new_name) | 1882 | int device_rename(struct device *dev, const char *new_name) |
1883 | { | 1883 | { |
1884 | struct kobject *kobj = &dev->kobj; | ||
1884 | char *old_device_name = NULL; | 1885 | char *old_device_name = NULL; |
1885 | int error; | 1886 | int error; |
1886 | 1887 | ||
@@ -1898,13 +1899,14 @@ int device_rename(struct device *dev, const char *new_name) | |||
1898 | } | 1899 | } |
1899 | 1900 | ||
1900 | if (dev->class) { | 1901 | if (dev->class) { |
1901 | error = sysfs_rename_link(&dev->class->p->subsys.kobj, | 1902 | error = sysfs_rename_link_ns(&dev->class->p->subsys.kobj, |
1902 | &dev->kobj, old_device_name, new_name); | 1903 | kobj, old_device_name, |
1904 | new_name, kobject_namespace(kobj)); | ||
1903 | if (error) | 1905 | if (error) |
1904 | goto out; | 1906 | goto out; |
1905 | } | 1907 | } |
1906 | 1908 | ||
1907 | error = kobject_rename(&dev->kobj, new_name); | 1909 | error = kobject_rename(kobj, new_name); |
1908 | if (error) | 1910 | if (error) |
1909 | goto out; | 1911 | goto out; |
1910 | 1912 | ||