On 09/03/2015 09:41, Natanael Copa wrote:
What I'd like to do is:
change mdev to:
- be able to read events from stdin. same format as from netlink socket.
The thing is, the format from the netlink socket is a bit painful to parse;
the hard part of netlink listeners isn't to actually listen to the netlink
(which is as small and easy as a socket() call), but to parse the messages.
If your goal is to keep the netlink stuff out of mdev, you're probably
better off designing a simpler format to pass the events to stdin.
If you don't want to do that, you might as well make mdev listen to the
netlink itself - you'll spare one extra process.
The information that a hotplug helper needs is actually very simple:
it's a small dictionary like an envp, and /proc/sys/kernel/hotplug forks
the helper with just the right information in its environment.
So I'm going to suggest the following format: when the netlink listener
gets an event, it sends a sequence of null-terminated VARIABLE=VALUE
strings to the helper's stdin, and the end of the set is notified via
an extra null character.
Example: HOME=/\0TERM=linux\0ACTION=something\0DEVPATH=/foo\0\0
- set a timeout on stdin (1 sec or so by default). when time out is
reached (no event within a sec) then just exit.
I'm still doubtful of the benefits of that approach. mdev is small,
and when it's not doing anything, it's not using many resources. And
you have to commit those resources anyway, since a kernel event might
appear at any time and you don't want to oom because of that - so,
why not simply keep a long-lived helper ?
--
Laurent
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox