2018-01-13 12:40 GMT-03:00 Guillermo:
>
> 2018-01-12 23:10 GMT-03:00 Laurent Bercot:
>>
>>  Anyway, I will change to what udev does; but this is annoying because
>> it requires a rearchitecture, so it will take some time.
>>
>>  With the mdev -s model, it was possible to just read from sysfs,
>> synthesize events, and send the synthetic events to a dedicated mdevd
>> instance. With the udevadm trigger model, this is not what happens:
>> instead of reading from sysfs and synthesizing events, the coldplugger
>> actually pokes the kernel, which creates real events; and the netlink
>> listener must be up in order to receive and process them.
>
> I'm not sure you'd need to modify this part. The uevent files can
> still be read, systemd does try to read IFINDEX, MAJOR and MINOR from
> them during enumerator_scan_dir_and_add_devices(), and from what I've
> seen, the information you can read from them is pretty much the same
> as what you get from events triggered by writing to them. I'll tell
> you what, I'm going to try doing both things (using eudev's 'udevadm
> monitor' to check the netlink part) and see if I get the same results.

OK, I did this, I compared what I got by reading every
/sys/class/*/*/uevent and /sys/bus/*/devices/*/uevent file (like
mdevd-coldplug does for /sys/dev/*/*/uevent) with what I got by
writing 'add' to them (like udevadm trigger does) and then using
'udevadm monitor --kernel --property' to watch the netlink events, and
there's no difference.

udevadm monitor showed:

* ACTION=add, as expected. mdevd-coldplug adds it for the synthetic event.
* A DEVPATH starting with /device that corresponds to the /sys/devices
subdirectory. The DEVPATH added by mdevd-coldplug for the synthetic
event starts with /dev and corresponds to the /sys/dev symlink.
* A SEQNUM line that I suppose can be ignored.
* A SUBSYSTEM line. mdevd-coldplug adds it for the synthetic event
using readlinkat() with the 'subsystem' symlink found in the same
directory as the uevent file, and retrieving the last pathname
component. This works with /sys/{class,bus} too.

And everything else was the same as the contents of the uevent file.
So reading /sys/class/*/*/uevent and /sys/bus/*/devices/*/uevent (or
/sys/subsystem/*/devices/*/uevent instead, if it exists), synthesizing
events and sending them to mdevd's standard input would work, it
seems.

G.

Reply via email to