Merge tag 'nfs-for-5.7-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
[linux-block.git] / fs / sysfs / group.c
index 5afe0e7ff7cd1c486078caa7d2660491456b184d..64e6a6698935e9254bf789bb570e8e0559a4cfce 100644 (file)
@@ -416,15 +416,18 @@ void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name,
 EXPORT_SYMBOL_GPL(sysfs_remove_link_from_group);
 
 /**
- * __compat_only_sysfs_link_entry_to_kobj - add a symlink to a kobject pointing
+ * compat_only_sysfs_link_entry_to_kobj - add a symlink to a kobject pointing
  * to a group or an attribute
  * @kobj:              The kobject containing the group.
  * @target_kobj:       The target kobject.
  * @target_name:       The name of the target group or attribute.
+ * @symlink_name:      The name of the symlink file (target_name will be
+ *                     considered if symlink_name is NULL).
  */
-int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
-                                     struct kobject *target_kobj,
-                                     const char *target_name)
+int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
+                                        struct kobject *target_kobj,
+                                        const char *target_name,
+                                        const char *symlink_name)
 {
        struct kernfs_node *target;
        struct kernfs_node *entry;
@@ -449,15 +452,18 @@ int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
                return -ENOENT;
        }
 
-       link = kernfs_create_link(kobj->sd, target_name, entry);
+       if (!symlink_name)
+               symlink_name = target_name;
+
+       link = kernfs_create_link(kobj->sd, symlink_name, entry);
        if (PTR_ERR(link) == -EEXIST)
-               sysfs_warn_dup(kobj->sd, target_name);
+               sysfs_warn_dup(kobj->sd, symlink_name);
 
        kernfs_put(entry);
        kernfs_put(target);
        return PTR_ERR_OR_ZERO(link);
 }
-EXPORT_SYMBOL_GPL(__compat_only_sysfs_link_entry_to_kobj);
+EXPORT_SYMBOL_GPL(compat_only_sysfs_link_entry_to_kobj);
 
 static int sysfs_group_attrs_change_owner(struct kernfs_node *grp_kn,
                                          const struct attribute_group *grp,