Re: Need help in understanding sysfs

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

 




 
On Wed, Aug 10, 2011 at 3:12 PM, Greg KH <greg@xxxxxxxxx> wrote:
On Wed, Aug 10, 2011 at 02:43:31PM -0700, Vaibhav Jain wrote:
> Sorry for the vague question. I would clarify. There are two things I need :
>
> 1-  I need to know how information is organized in the sysfs and  understand
> the concepts of kobjects , attributes etc.

Please read the in-kernel documentation for kobjects and sysfs which
will explain this.  If not, please let us know what is lacking.

The sysfs documentation in the kernel is a bit old, but the basics
remain the same.  The kobject documentation is quite up to date, and
should be very useful.

But, it turns out you really don't want to mess with a kobject directly
because:

> 2.- I need to understand how to create a file entry in the sysfs.
> Particulary i need to create an entry inside the
> directory /sys/devices/system/cpu/ .

No you don't :)

> I will be required to write some driver in the future which will
> accept inputs from this file but I am not very clear about that right
> now. So I was thinking of just trying to create an entry for now.

You really don't want to create a new file there unless you really know
what you are doing, and get a whole lot of buy-in by some of the core
kernel developers.

The sysdev code is a mess, and currently being worked on, and hopefully
adding files to /sys/devices/system/ will be easier than it currently is
in the future.  Until then, I'd strongly suggest staying away from
/sys/devices/system unless you coordinate it with the sysfs and driver
core subsystem kernel maintainer.

What type of file are you wanting to add?  What do you want it to do?

And most importantly, why not just look at the code that adds those
files to sysfs for how to do it yourself?

thanks,

greg k-h
 
 
Hi Greg,
 
Thanks for ther reply!
But I really need to create an entry in /sys/devices/system.
I am working on a project on extending the cpu hotplug (/sys/devices/system/cpu) .
I went through the books LDD and LKD and got some understanding of sysfs but they are
lacking samples. I thought of looking into the code that adds the entries inside   /sys/devices/system/cpu   but I am unable to find it.
Could you please suggest how should I go about finding the code ?  I searched for it in google but did not hit anything significant.
 
Thanks
Vaibhav Jain

_______________________________________________
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