Re: [libudev] is there a function to filter message from kernel with property and value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Di, 31.05.22 02:48, Wang, Yuan1 (yuan1.wang@xxxxxxxxx) wrote:

> Hi
>
> Need your kind help for one question!
>
> Do libudev have a function that could be used to filter the message with property from kernel socket?

No, because that is not optimizable. i.e. we have no way to filter
these missages in kernel. We could filter them in userspace on the
library once we have them, but that's not really too useful, since you
might as well do that yourself, the library wouldn't be any more
efficient.

Usually, what you want to do instead is mark devices to filter for
with a "tag". Which are short strings that devices can be labelled
with. Each device can have zero, one or more tags. You set them via
udev rules. These tags can then efficiently be filtered for via the
library. This is internally implemented via a Bloom Filter, that is
tested via a BPF socket filter, which means the kernel already filters
the messages, and userspace is never bothered anymore (well, bloom
filters are probabilistic, so userspace has to check for false
positives).

Anyway, long story short: filtering by properties is not supported
because you should not do that, and should use tags instead.

Also, libudev is obsolete and does not recieve new additions. Use the
sd-device API instead.

--
Lennart Poettering, Berlin



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux