Re: procfs question

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

 





On 6/19/06, Greg KH <greg@xxxxxxxxx> wrote:
On Sun, Jun 18, 2006 at 08:33:38PM +0200, Fernando Apestegu?a wrote:
> Hi list!
>
> I need to create a hierarchy of procfs files. I made some tests
> successfully.
> Now, I want to create a hierarchy as follows:
>
> procfs
> |
> |
> |-my_directory
>          |
>          |-dir_a
>          |     |
>          |     |-field 1
>          |     |-field 2
>          |     |-field 3
>          |
>          |-dir_b
>          |     |-field 1
>          |     |-field 2
>          |     |-field 3
>
> dir_a and dir_b has the correspondent dir_a and dir_b structs inside my
> module. These structs has the same type (the same fields but different
> values). So my idea was to assign the same read_proc function to all of my
> proc_dir_entry for "field *" files. Once inside this function, make a switch
> to know which concrete struct should I ask.
> Here reaches my question. The switch would depend on the parent directory
> (if I'm reading from field 1 subdir of dir_a, then search for dir_a struct)
> but the comment at proc_fs.h say that "this is not complete implemented
> yet".
>
> Can I use that fileds? Is there a easier way to implement this? I would like
> to write as fewer lines as possible to achieve this.

Use debugfs instead.  It's much easier to do this there.  If you really
want to, sysfs can be used also, but it depends on what you want to
provide in those files.

Thanks for your reply.

Each file will provide three numbers. So I wouldn't like to duplicate code. Just write a single read_proc function and then perform the switch to know which three values should I return. I know about the existence of sysfs but not about debugfs. I would prefer to use procfs for other reasons (legacy code, in fact). However, could you point me to a good tutorial about sysfs and debugfs?

Thanks in advance

good luck,

greg k-h


[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