-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monitor example? #15
Comments
I also ran into problems trying to integrate I'm using Ubuntu 22.04 (kernel 6.2.0, udev from systemd 249.11), and I tried using use std::{sync::Arc, thread, time::Duration};
use udevrs::{Udev, UdevMonitor};
fn main() {
env_logger::init();
let udev = Arc::new(Udev::new());
let mut monitor = UdevMonitor::new_from_netlink(udev, "udev").unwrap();
monitor.enable_receiving().unwrap();
loop {
println!("{:?}", monitor.receive_device());
// for lack of an easy way to set it to blocking mode or poll
thread::sleep(Duration::from_secs(1));
}
} This prints I compared the
but this library is passing 0:
which from what I can tell, means not to subscribe to any multicast events. Looking at the code, this value comes from So I tried forcing --- a/src/monitor.rs
+++ b/src/monitor.rs
@@ -652,10 +652,11 @@ impl UdevMonitor {
let mut err = if !self.bound {
// SAFETY: all arguments are valid, and pointers reference valid memory.
+ let snl = UdevSocket::new_nl(libc::AF_NETLINK, 0, 2);
unsafe {
libc::bind(
self.sock,
- self.snl.as_nl_ptr()? as *const _,
+ snl.as_nl_ptr()? as *const _,
mem::size_of::<libc::sockaddr_nl>() as u32,
)
} Now it receives what looks like plausible events in
but fails to parse them and returns |
Sets the default `nl_groups` value to `2` for `Monitor::snl`. This ensures that if users do not call a method that sets `snl`, the default will be valid to begin receiving `Netlink` events. Part of resolving: #15
I've set this as the default value when creating a new
There is the monitor.set_snl(UdevSocket::new_nl(libc::AF_NETLINK, 0, 2)); Most of this code was ported from the library portion of
I'll continue debugging this error, thank you both for the detailed error reports. |
Fixes the polling mechanism for UDEV events by correcting `ucred` parsing. Adds an example, credit to @kevinmehall: <#15 (comment)> Resolves: #15
Fixes the polling mechanism for UDEV events by correcting `ucred` parsing. Adds an example, credit to @kevinmehall: <#15 (comment)> Resolves: #15
Either I misunderstand how to use this library, or it doesn't setup something properly?
Using version 0.1.1, removing filter/connecting to kernel doesn't change anything, socket is never ready.
The text was updated successfully, but these errors were encountered: