From mboxrd@z Thu Jan 1 00:00:00 1970 From: Subject: patch sysfs-implement-sysfs_rename_link.patch added to gregkh-2.6 tree Date: Tue, 02 Jun 2009 15:57:26 -0700 Message-ID: <12439834462266@kroah.org> References: <1243628376-22905-1-git-send-email-ebiederm@xmission.com> To: ebiederm@xmission.com, akpm@linux-foundation.org, benjamin.thery@bull.net, cornelia.huck@de.ibm.com, dlezcano@fr.ibm.com, ebiederm@aristanetworks.com, gregkh@suse.de, greg@kroah.com, Return-path: Received: from kroah.org ([198.145.64.141]:57082 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753812AbZFBXB5 (ORCPT ); Tue, 2 Jun 2009 19:01:57 -0400 In-Reply-To: <1243628376-22905-1-git-send-email-ebiederm@xmission.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled Subject: sysfs: Implement sysfs_rename_link to my gregkh-2.6 tree. Its filename is sysfs-implement-sysfs_rename_link.patch This tree can be found at http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/ >>From ebiederm@xmission.com Tue Jun 2 15:34:06 2009 From: "Eric W. Biederman" Date: Fri, 29 May 2009 13:19:11 -0700 Subject: sysfs: Implement sysfs_rename_link To: Andrew Morton , Greg Kroah-Hartman Cc: Tejun Heo , Cornelia Huck , , Kay Sievers , Greg KH , "Eric W. Biederman" , Benjamin Thery , Daniel Lezcano , "Eric W. Biederman" Message-ID: <1243628376-22905-1-git-send-email-ebiederm@xmission.com> From: Eric W. Biederman Because of rename ordering problems we occassionally give false warnings about invalid sysfs operations, so implement a helper function for this common sysfs idiom. This is a stripped down version of an earlier patch that also added sysfs_delete_link. Cc: Benjamin Thery Cc: Daniel Lezcano Cc: Tejun Heo Signed-off-by: Eric W. Biederman Signed-off-by: Greg Kroah-Hartman --- fs/sysfs/symlink.c | 16 ++++++++++++++++ include/linux/sysfs.h | 9 +++++++++ 2 files changed, 25 insertions(+) --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c @@ -122,6 +122,22 @@ void sysfs_remove_link(struct kobject * sysfs_hash_and_remove(parent_sd, name); } +/** + * sysfs_rename_link - rename symlink in object's directory. + * @kobj: object we're acting for. + * @targ: object we're pointing to. + * @old: previous name of the symlink. + * @new: new name of the symlink. + * + * A helper function for the common rename symlink idiom. + */ +int sysfs_rename_link(struct kobject *kobj, struct kobject *targ, + const char *old, const char *new) +{ + sysfs_remove_link(kobj, old); + return sysfs_create_link(kobj, targ, new); +} + static int sysfs_get_target_path(struct sysfs_dirent *parent_sd, struct sysfs_dirent *target_sd, char *path) { --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -109,6 +109,9 @@ int __must_check sysfs_create_link_nowar 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 __must_check sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp); int sysfs_update_group(struct kobject *kobj, @@ -202,6 +205,12 @@ static inline void sysfs_remove_link(str { } +static inline int sysfs_rename_link(struct kobject *k, struct kobject *t, + const char *old_name, const char *new_name) +{ + return 0; +} + static inline int sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp) {