>>>>  DEFINE_SHOW_ATTRIBUTE(fadump_region);
>>>>  
>>>>  static void fadump_init_files(void)
>>>> @@ -1435,6 +1448,11 @@ static void fadump_init_files(void)
>>>>    struct dentry *debugfs_file;
>>>>    int rc = 0;
>>>>  
>>>> +  fadump_kobj = kobject_create_and_add("fadump", kernel_kobj);
>>>> +  if (!fadump_kobj) {
>>>> +          pr_err("failed to create fadump kobject\n");
>>>> +          return;
>>>> +  }
>>>>    rc = sysfs_create_file(kernel_kobj, &fadump_attr.attr);
>>>>    if (rc)
>>>>            printk(KERN_ERR "fadump: unable to create sysfs file"
>>>> @@ -1458,6 +1476,26 @@ static void fadump_init_files(void)
>>>>                    printk(KERN_ERR "fadump: unable to create sysfs file"
>>>>                            " fadump_release_mem (%d)\n", rc);
>>>>    }
>>>> +  /* Replicating the following sysfs attributes under FADump kobject.
>>>> +   *
>>>> +   *      - fadump_enabled -> enabled
>>>> +   *      - fadump_registered -> registered
>>>> +   *      - fadump_release_mem -> release_mem
>>>> +   */
>>>> +  rc = sysfs_create_file(fadump_kobj, &enable_attr.attr);
>>>> +  if (rc)
>>>> +          pr_err("unable to create enabled sysfs file (%d)\n",
>>>> +                 rc);
>>>> +  rc = sysfs_create_file(fadump_kobj, &register_attr.attr);
>>>> +  if (rc)
>>>> +          pr_err("unable to create registered sysfs file (%d)\n",
>>>> +                 rc);
>>>> +  if (fw_dump.dump_active) {
>>>> +          rc = sysfs_create_file(fadump_kobj, &release_attr.attr);
>>>> +          if (rc)
>>>> +                  pr_err("unable to create release_mem sysfs file (%d)\n",
>>>> +                         rc);
>>>> +  }
>>>>    return;
>>>>  }
>>> Hello,
>>>
>>
>> I’m so sorry for taking this long to write you back. 
>>
>>> wouldn't it make more sense to create the files in the new location and
>>> add a symlink at the old location?
>>
>> There are APIs which allow to create a symlink for an entire kobject but
>> I did not find a way to create symlink of an individual sysfs file.
>>
>> Do you have any approach in mind to achieve the same?
> 
> There is at least one example of plain symlink:
> 
> find /sys -type l -xtype f
> /sys/kernel/security/evm
> 
> If there is no interface to do one sanely duplicationg the files is
> better than nothing.

Hello Michal,

I found a function (__compat_only_sysfs_link_entry_to_kobj) that adds a symlink
to a kobject.

But the problem is __compat_only_sysfs_link_entry_to_kobj function keeps the
symlink file name similar to sysfs file and has no option to change it.

We can't use the __compat_only_sysfs_link_entry_to_kobj function directly 
because
our symlink file name must be different from the target file name.

        fadump_enabled -> fadump/enabled

But the good thing is we can tweak the __compat_only_sysfs_link_entry_to_kobj
function and allow the caller to change the sysmlink file name.

So I am writing a separate patch that adds a wrapper function around the 
__compat_only_sysfs_link_entry_to_kobj function which will allow to have a 
custom symlink file name.

Thanks,
Sourabh Jain

Reply via email to