From: Michael Ellerman <mpe@ellerman.id.au>
To: Sourabh Jain <sourabhjain@linux.ibm.com>
Cc: 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,
gregkh@linuxfoundation.org,
Sourabh Jain <sourabhjain@linux.ibm.com>
Subject: Re: [PATCH v6 2/6] sysfs: wrap __compat_only_sysfs_link_entry_to_kobj function to change the symlink name
Date: Mon, 10 Feb 2020 15:44:42 +1100 [thread overview]
Message-ID: <878slb126d.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <20191211160910.21656-3-sourabhjain@linux.ibm.com>
Sourabh Jain <sourabhjain@linux.ibm.com> writes:
> 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 compat_only_sysfs_link_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 <sourabhjain@linux.ibm.com>
> ---
> fs/sysfs/group.c | 28 +++++++++++++++++++++++++---
> include/linux/sysfs.h | 12 ++++++++++++
> 2 files changed, 37 insertions(+), 3 deletions(-)
I'll assume no one has any objections to this and merge it via the
powerpc tree with the rest of the series.
cheers
> diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
> index d41c21fef138..0993645f0b59 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 compat_only_sysfs_link_entry_to_kobj(kobj, target_kobj,
> + target_name, NULL);
> +}
> +EXPORT_SYMBOL_GPL(__compat_only_sysfs_link_entry_to_kobj);
> +
> +/**
> + * 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,
> + 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(compat_only_sysfs_link_entry_to_kobj);
> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
> index 5420817ed317..15b195a4529d 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 compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
> + struct kobject *target_kobj,
> + const char *target_name,
> + const char *symlink_name);
>
> void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
>
> @@ -508,6 +512,14 @@ static inline int __compat_only_sysfs_link_entry_to_kobj(
> return 0;
> }
>
> +static int compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
> + struct kobject *target_kobj,
> + const char *target_name,
> + const char *symlink_name)
> +{
> + return 0;
> +}
> +
> static inline void sysfs_notify(struct kobject *kobj, const char *dir,
> const char *attr)
> {
> --
> 2.17.2
next prev parent reply other threads:[~2020-02-10 4:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-11 16:09 [PATCH v6 0/6] reorganize and add FADump sysfs files Sourabh Jain
2019-12-11 16:09 ` [PATCH v6 1/6] Documentation/ABI: add ABI documentation for /sys/kernel/fadump_* Sourabh Jain
2020-01-07 20:06 ` Hari Bathini
2020-03-06 0:27 ` Michael Ellerman
2019-12-11 16:09 ` [PATCH v6 2/6] sysfs: wrap __compat_only_sysfs_link_entry_to_kobj function to change the symlink name Sourabh Jain
2020-02-10 4:44 ` Michael Ellerman [this message]
2019-12-11 16:09 ` [PATCH v6 3/6] powerpc/fadump: reorganize /sys/kernel/fadump_* sysfs files Sourabh Jain
2020-01-08 11:11 ` Michal Suchánek
2019-12-11 16:09 ` [PATCH v6 4/6] powerpc/powernv: move core and fadump_release_opalcore under new kobject Sourabh Jain
2019-12-11 16:09 ` [PATCH v6 5/6] Documentation/ABI: mark /sys/kernel/fadump_* sysfs files deprecated Sourabh Jain
2019-12-11 16:09 ` [PATCH v6 6/6] powerpc/fadump: sysfs for fadump memory reservation Sourabh Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878slb126d.fsf@mpe.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=hbathini@linux.ibm.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mahesh@linux.vnet.ibm.com \
--cc=sourabhjain@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).