Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp690144ybl; Fri, 6 Dec 2019 04:47:35 -0800 (PST) X-Google-Smtp-Source: APXvYqyXAMxFqbR2SAouXyCKtByOMT4hJtGYXzMtjTkYAtinhQ8pdYyN8xqTzZer0rUj8xSmxD2+ X-Received: by 2002:a9d:6e12:: with SMTP id e18mr10022842otr.47.1575636455760; Fri, 06 Dec 2019 04:47:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575636455; cv=none; d=google.com; s=arc-20160816; b=H2Hc+TjUjEvcekC2ZoHnHSX5tl4udFvfCquJ8IONPQ+AxSwai75aWwrq5zfSXvF6Dv 0sPI6gR+lB7stHGhIg1jKo1OFpv26mruFQME/LmkKbSa164lPE1G0m/+cfFB9/b176So ocBQtlTvz40I8aMKwuGyi91yBgvvuUSHgZn48tx4v3lwMfFf4/2w+2yTNMpWkadobFj0 cU0tRaEJ9NOpiMCC+ZVBRjxrwFdAjkERBeMLXDyPwNc+fBWXgIZ9COnK0cJ4obK0Agkv hYayuF3Pm6M8OoRzHx0jWldVP5QFCJCygbMaI8oo9DURk/XsPDJVIwX8kuUA7Py+Qm1+ 9YkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=6uhLDZ6/rw7rcCpz1GgAp1ZhuVlOkK9jLUr6HChgDcI=; b=abm2gAyHJZzxq6hKHfluIwNTuppV4SgKiTaN/WbcWt8mWHS2FicgaNSfNGkSz1qcji dYzSEUr8FPrZ/ydtQvTogtkRz+Yvqj0uNbd7XJ81XDcSvG73q2Ww9l4QbXgVrCv2g4hp VIjZfq1MhrCVlRqk0TpVHPvlz9eToELhlOjWiG9HFbP8+1TWJCKFiLf64ntXGV61HDVR 7OsUpAYu7BYlIkctj61BoUf95m1ycuZLRVvTBmwdcEyDNyL/ESSz/NQIRN3SU4uigzjW Oh+H+mVLNdfSvmIUn7iFraY8hDaedp0vIghSkE/OIiWjTj7glRRQxqX5AwbEHKh0FUR8 iIYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bvhYDo2l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v15si6885753otn.100.2019.12.06.04.47.23; Fri, 06 Dec 2019 04:47:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bvhYDo2l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726314AbfLFMqq (ORCPT + 99 others); Fri, 6 Dec 2019 07:46:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:50700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726124AbfLFMqq (ORCPT ); Fri, 6 Dec 2019 07:46:46 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A2891205F4; Fri, 6 Dec 2019 12:46:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575636405; bh=SiHbrHvdA3rQHB7384b21HC7KlecqzAg0pEqLEmEU+k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bvhYDo2l759TzwwMNJLmF2Upiy+Z2dSlP5KZtcVmlnmshB0fLqoxbBswp4UckLaGT vTPUiOopAy4WPsaIpb7t5X32xmR8tMNG0qF2AaRpTQ0acMimrlD6kB14SwXO/O10SA lESz9K0w2rqU90/c66FvdbnAaj9KbNvXrb2s2lvk= Date: Fri, 6 Dec 2019 13:46:42 +0100 From: Greg KH To: Sourabh Jain Cc: mpe@ellerman.id.au, mahesh@linux.vnet.ibm.com, hbathini@linux.ibm.com, linux-kernel@vger.kernel.org, linuxppc-dev@ozlabs.org, corbet@lwn.net, linux-doc@vger.kernel.org Subject: Re: [PATCH v4 2/6] sysfs: wrap __compat_only_sysfs_link_entry_to_kobj function to change the symlink name Message-ID: <20191206124642.GB1360047@kroah.com> References: <20191206122434.29587-1-sourabhjain@linux.ibm.com> <20191206122434.29587-3-sourabhjain@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191206122434.29587-3-sourabhjain@linux.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 06, 2019 at 05:54:30PM +0530, Sourabh Jain wrote: > The __compat_only_sysfs_link_entry_to_kobj function creates a symlink to a > kobject but doesn't provide an option to change the symlink file name. > > This patch adds a wrapper function create_sysfs_symlink_entry_to_kobj that > extends the __compat_only_sysfs_link_entry_to_kobj functionality which > allows function caller to customize the symlink name. > > Signed-off-by: Sourabh Jain > --- > fs/sysfs/group.c | 28 +++++++++++++++++++++++++--- > include/linux/sysfs.h | 12 ++++++++++++ > 2 files changed, 37 insertions(+), 3 deletions(-) > > diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c > index d41c21fef138..5eb38145b957 100644 > --- a/fs/sysfs/group.c > +++ b/fs/sysfs/group.c > @@ -424,6 +424,25 @@ EXPORT_SYMBOL_GPL(sysfs_remove_link_from_group); > int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj, > struct kobject *target_kobj, > const char *target_name) > +{ > + return create_sysfs_symlink_entry_to_kobj(kobj, target_kobj, > + target_name, NULL); > +} > +EXPORT_SYMBOL_GPL(__compat_only_sysfs_link_entry_to_kobj); > + > +/** > + * create_sysfs_symlink_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 create_sysfs_symlink_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; > @@ -448,12 +467,15 @@ 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 (IS_ERR(link) && 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(create_sysfs_symlink_entry_to_kobj); > diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h > index 5420817ed317..123c6f10333a 100644 > --- a/include/linux/sysfs.h > +++ b/include/linux/sysfs.h > @@ -300,6 +300,10 @@ void sysfs_remove_link_from_group(struct kobject *kobj, const char *group_name, > int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj, > struct kobject *target_kobj, > const char *target_name); > +int create_sysfs_symlink_entry_to_kobj(struct kobject *kobj, > + struct kobject *target_kobj, > + const char *target_name, > + const char *symlink_name); sysfs_create_symlink_entry_to_kobj()? I can't remember why we put __compat_only there, perhaps because we do not want people to really use this unless you really really have to? So then keep compat_only here as well? What breaks if you remove those undocumented sysfs files? What userspace tool do you have that will even notice? thanks, greg k-h