From 02867e00b17213de33355b32144071b5f511aa6a Mon Sep 17 00:00:00 2001 From: Josh Kropf Date: Mon, 25 May 2026 16:59:52 -0400 Subject: [PATCH 1/3] Gracefully handle missing ioctl on kernel 2.6.x --- src/raw_stream.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/raw_stream.rs b/src/raw_stream.rs index a3c5ae5..874914d 100644 --- a/src/raw_stream.rs +++ b/src/raw_stream.rs @@ -139,9 +139,16 @@ impl RawDevice { let props = { let mut props = AttributeSet::::new(); - unsafe { sys::eviocgprop(fd.as_raw_fd(), props.as_mut_raw_slice())? }; - props - }; // FIXME: handle old kernel + + match unsafe { sys::eviocgprop(fd.as_raw_fd(), props.as_mut_raw_slice()) } { + Ok(_) => props, + + // Kernel 2.6.x does not implement this ioctl, return empty props + Err(e) if e == nix::errno::Errno::EINVAL => props, + + Err(e) => return Err(e.into()) + } + }; let supported_keys = if ty.contains(EventType::KEY) { let mut keys = AttributeSet::::new(); From bf54bd2b98a0d4dd21d662c32477187e9f04f644 Mon Sep 17 00:00:00 2001 From: Josh Kropf Date: Mon, 25 May 2026 22:30:19 -0400 Subject: [PATCH 2/3] style: apply `cargo fmt` --- src/raw_stream.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/raw_stream.rs b/src/raw_stream.rs index 874914d..6b56eaa 100644 --- a/src/raw_stream.rs +++ b/src/raw_stream.rs @@ -146,7 +146,7 @@ impl RawDevice { // Kernel 2.6.x does not implement this ioctl, return empty props Err(e) if e == nix::errno::Errno::EINVAL => props, - Err(e) => return Err(e.into()) + Err(e) => return Err(e.into()), } }; From 3fe2059aff3a8d401f6d0d10998062a93627c124 Mon Sep 17 00:00:00 2001 From: Josh Kropf Date: Mon, 25 May 2026 22:46:57 -0400 Subject: [PATCH 3/3] style: remove unecessary guard --- src/raw_stream.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/raw_stream.rs b/src/raw_stream.rs index 6b56eaa..356c145 100644 --- a/src/raw_stream.rs +++ b/src/raw_stream.rs @@ -144,7 +144,7 @@ impl RawDevice { Ok(_) => props, // Kernel 2.6.x does not implement this ioctl, return empty props - Err(e) if e == nix::errno::Errno::EINVAL => props, + Err(nix::errno::Errno::EINVAL) => props, Err(e) => return Err(e.into()), }