Re: Dynamic Sysfs Attribute Files

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

 



> Date: Wed, 24 Apr 2013 15:39:42 +0200
> From: Tobias Boege <tobias@xxxxxxxxxxxxxx>
>
> On Wed, 24 Apr 2013, Matt Davis wrote:
>> Hello,
>> I want my kernel module to dynamically add sysfs files for its
>> corresponding device.  Without going into detail, the attribute file
>> will be named something like: /sys/class/myclass/mydev0/fileX where
>> 'X' is an integer ranging from 1-256.  I did not see anything in the
>> api to allow this.  I suppose I could just dynamically allocate an
>> attribute, give it the unique name by tacking on my own integer, and
>> pass that off to device_create_file().  However, I have not seen
>> anywhere in the codebase where another module does this; I assume it
>> is not allowed (or there is a better solution).
>>
>> The other solution (instead of sysfs) would be to add an ioctl, but
>> this means the userland application must know the specific 'file' id
>> to query.  In the sysfs version above, the userland application can
>> just grab the directory listing of /sys/class/myclaass/mydev0/ and see
>> how many 'file' instances exist.
>>
>> -Matt
>
> Hmm, the following led some places on my system:
>
> $ shopt -s extglob
> $ find /sys/!(module|kernel) -name "*[0-9]"
> ...
> /sys/firmware/acpi/interrupts/gpe00
> /sys/firmware/acpi/interrupts/gpe01
> /sys/firmware/acpi/interrupts/gpe02
> /sys/firmware/acpi/interrupts/gpe03
> /sys/firmware/acpi/interrupts/gpe04
> /sys/firmware/acpi/interrupts/gpe05
> ...
>
> >From a quick grep, the source _may_ be somewhere around
>
> drivers/acpi/sysfs.c:
> 658                         sprintf(buffer, "gpe%02X", i);
>
> Hope this helps you further.

Tobi,
That is exactly what I am looking for; that and the fact no one
explicitly flamed me for my idea.

-Matt

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux