On 13.03.2015 10:52, Natanael Copa wrote:
Crazy idea:
have a netlink listener/handler that is installed in
/proc/sys/kernel/hotplug.
On startup it will set up a netlink listener and remove itself from
/proc/sys/kernel/hotplug so all subsequent events comes via netlink.
Read events from netlink and handle those.
On timeout (no events for N seconds), restore itself in
/proc/sys/kernel/hotplug and exit.
I don't think this is possible to implement without race conditions
so I still believe a minimal forever running netlink listening
daemon is the way to go.
Crazy! ... but otherwise ACK ... you may try this, on my intended
modular device management. Modify the hotplug helper to disable hotplug,
fire up netlink, but don't loose the initial hotplug handler event ...
but I don't expect main stream stability
What happens if new event comes after netlink manager is started up but
before the netlink listener is setup up?
For example /dev/sda event comes and the user space hotplug program is
fork/executed, but before it has reached to set up netlink listener the
event for /dev/sda1 comes.
How do you prevent races? I suppose you would need kernel help for
solving that properly, like Denys suggested.
That is where the fifo (named pipe) steps in. The pipe (some bytes of
descriptor in kernel) will still be there (sense of fifo manager). Any
active mechanism handler, just write a message to the fifo, when
complete event information has bean gathered. Event messages are then
consumed by the parser / handler in the order they have been written
into the pipe. If no parser is running the fifo manager fires one up.
Event processing may be slight delayed, but processing is always in the
order the messages have been written to the pipe (meanwhile the kernel
uses some buffer space to hold the messages). On modern machines the
event gathering and handling can even run on different CPU cores, for no
extra cost.
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox