Re: [PATCH 1/2] sysfs: add sysfs_add_bin_file_to_group()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 20, 2021 at 07:47:29AM +0100, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@xxxxxxxxxx>
> 
> There already is sysfs_add_file_to_group() for adding "attribute" to a
> group. This new function allows adding "bin_attribute" as well.
> 
> Signed-off-by: Rafał Miłecki <rafal@xxxxxxxxxx>
> ---
>  fs/sysfs/file.c       | 31 +++++++++++++++++++++++++++----
>  include/linux/sysfs.h |  3 +++
>  2 files changed, 30 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
> index 42dcf96881b6..30c798c38d89 100644
> --- a/fs/sysfs/file.c
> +++ b/fs/sysfs/file.c
> @@ -376,14 +376,19 @@ EXPORT_SYMBOL_GPL(sysfs_create_files);
>   * @attr: attribute descriptor.
>   * @group: group name.
>   */
> -int sysfs_add_file_to_group(struct kobject *kobj,
> -		const struct attribute *attr, const char *group)
> +int __sysfs_add_file_to_group(struct kobject *kobj,
> +			      const struct attribute *attr,
> +			      const struct bin_attribute *battr,
> +			      const char *group)
>  {
>  	struct kernfs_node *parent;
>  	kuid_t uid;
>  	kgid_t gid;
>  	int error;
>  
> +	if (WARN_ON((attr && battr) || (!attr && !battr)))
> +		return -EINVAL;

How can this ever happen?




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux