udev-hid-bpf: Allow to add and remove multiple files
When a device has multiples interfaces, it is required to load the BPF program in all of them. This is the script I used to develop the XP-Pen Deco Mini 4 driver:
$ ninja -C builddir && \
for f in /sys/bus/hid/devices/0003:28BD:0929.*; do \
sudo ./builddir/udev-hid-bpf remove $f; \
sudo ./builddir/udev-hid-bpf --verbose add $f builddir/src/bpf/testing/10-XPPen__DecoMini4.bpf.o; \
done
This MR allows to pass a list of devices to remove
and adds a new command add-devices
to simplify the build/remove/add process to:
$ ninja -C builddir && \
sudo ./builddir/udev-hid-bpf remove /sys/bus/hid/devices/0003:28BD:0929.* && \
sudo ./builddir/udev-hid-bpf --verbose add-devices /sys/bus/hid/devices/0003:28BD:0929.* -o builddir/src/bpf/testing/10-XPPen__DecoMini4.bpf.o
I had to add a new command (add-devices
) because Add::objfile
is a positional argument and it is not possible to keeps backwards compatibility while accepting a list of device paths. Let me know if breaking backwards compatibility is preferred in this case.