Netlink user space and the relationship between the kernel and space

I study programming in embedded systems, using Linux as the main platform. And I want to create a device event management service. This service is an application / daemon for user space that will determine if the connected hardware module raised an event. But my problem is that I don’t know where to start.

I read about the Netlink implementation for exchanging data between users and the kernels, and it seems like a good idea, but not sure if this is the best solution. But I read that the UDEV device manager uses Netlink to wait for uevent from the kernel space, but it’s not clear to me how to do this.

I read about sysfs polls, but it seems nice to try out the file system.

What implementation do you think I should use in my service? Should I use netlink (hard / no clue how to) or just poll sysfs (not sure if it works)?

thanks

+6
linux
source share
2 answers

Yes, the survey is not recommended. These resources: LJ's Netlink article, "Understanding and Programming with Netlink Sockets," seems not so difficult to make netlink. Here is an example of netlink sockets in python.

udevtrigger is a great tool for responding to udev changes.

http://www.linuxjournal.com/article/7356

http://smacked.org/docs/netlink.pdf

http://guichaz.free.fr/misc/iotop.py

http://manpages.ubuntu.com/manpages/gutsy/man8/udevtrigger.8.html

+1
source share

If all you do is wait for an event, you can use sysfs, which will be much easier than netlink. An example is the edge file of a GPIO system.

+1
source share

All Articles