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>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
e34ff49061
commit
4b30ee58ee
@@ -213,8 +213,9 @@ int __must_check sysfs_create_link_nowarn(struct kobject *kobj,
|
||||
const char *name);
|
||||
void sysfs_remove_link(struct kobject *kobj, const char *name);
|
||||
|
||||
int sysfs_rename_link(struct kobject *kobj, struct kobject *target,
|
||||
const char *old_name, const char *new_name);
|
||||
int sysfs_rename_link_ns(struct kobject *kobj, struct kobject *target,
|
||||
const char *old_name, const char *new_name,
|
||||
const void *new_ns);
|
||||
|
||||
void sysfs_delete_link(struct kobject *dir, struct kobject *targ,
|
||||
const char *name);
|
||||
@@ -340,8 +341,9 @@ static inline void sysfs_remove_link(struct kobject *kobj, const char *name)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int sysfs_rename_link(struct kobject *k, struct kobject *t,
|
||||
const char *old_name, const char *new_name)
|
||||
static inline int sysfs_rename_link_ns(struct kobject *k, struct kobject *t,
|
||||
const char *old_name,
|
||||
const char *new_name, const void *ns)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -454,4 +456,10 @@ static inline void sysfs_remove_file(struct kobject *kobj,
|
||||
return sysfs_remove_file_ns(kobj, attr, NULL);
|
||||
}
|
||||
|
||||
static inline int sysfs_rename_link(struct kobject *kobj, struct kobject *target,
|
||||
const char *old_name, const char *new_name)
|
||||
{
|
||||
return sysfs_rename_link_ns(kobj, target, old_name, new_name, NULL);
|
||||
}
|
||||
|
||||
#endif /* _SYSFS_H_ */
|
||||
|
Reference in New Issue
Block a user