Using Sysfs uevents.

2012-02-15 Thread Pranay Kumar Srivastava
Hi,

I was playing with sysfs and I'm able to create kset and kobjects within them 
as well. I need to know how do I use the uevents of these kobjects that I 
create. For example while reading the code I found that certain events like 
ADD, DEL a couple more were there are apparently fired. Now currently I'm not 
handling these events, the ops field is null, so they don't bother me hence 
they are not mandatory?

If I were to actually do something with these events what it should be? Since 
my module runs fine and the uevents are supposed to be for userland 
applications (Hotplug) but the point is again how will a userspace application 
get to know about it? Does the application needs to create netlink sockets for 
it? If it does then why bother with the uevents of kobject?




::DISCLAIMER::
---

The contents of this e-mail and any attachment(s) are confidential and intended 
for the named recipient(s) only.
It shall not attach any liability on the originator or HCL or its affiliates. 
Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the 
opinions of HCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification, 
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is 
strictly prohibited. If you have
received this email in error please delete it and notify the sender 
immediately. Before opening any mail and
attachments please check them for viruses and defect.

---

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


Re: Using Sysfs uevents.

2012-02-15 Thread Greg KH
On Wed, Feb 15, 2012 at 06:17:28PM +0530, Pranay Kumar Srivastava wrote:
 Hi,
 
 I was playing with sysfs and I'm able to create kset and kobjects
 within them as well.

Nice, but why?  Almost no one ever should be touching raw sysfs
kobjects and ksets.

 I need to know how do I use the uevents of these kobjects that I
 create. For example while reading the code I found that certain events
 like ADD, DEL a couple more were there are apparently fired. Now
 currently I'm not handling these events, the ops field is null, so
 they don't bother me hence they are not mandatory?

They are created by the kobject core automatically for you.

 If I were to actually do something with these events what it should
 be? Since my module runs fine and the uevents are supposed to be for
 userland applications (Hotplug) but the point is again how will a
 userspace application get to know about it? Does the application needs
 to create netlink sockets for it? If it does then why bother with the
 uevents of kobject?

No, udev grabs all of these events and allows other programs to
subscribe to it and get that information.  You don't have to write your
own program to do this, the infrastructure is all there already.

But I wouldn't really worry about it to much, you shouldn't be messing
with kobjects directly anyway, why not use 'struct device' instead?

thanks,

greg k-h

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