Skip to content

udev-dev: Enumerate evdev devices via kern.evdev.input sysctls#12

Open
Defenso-QTH wants to merge 1 commit into
wulf7:masterfrom
Defenso-QTH:evdev-sysctl-enumerate
Open

udev-dev: Enumerate evdev devices via kern.evdev.input sysctls#12
Defenso-QTH wants to merge 1 commit into
wulf7:masterfrom
Defenso-QTH:evdev-sysctl-enumerate

Conversation

@Defenso-QTH
Copy link
Copy Markdown

When /dev/input/ is not visible to the calling process (for example, a FreeBSD jail without the corresponding devfs ruleset), the existing scandir-based enumeration in udev_dev_enumerate() cannot discover any input devices, even though the kern.evdev.input.* sysctls remain readable and the per-device property handlers already populate from those sysctls.

Add a sysctl tree-walk fallback that runs after the scandir pass. The walk uses CTL_SYSCTL_NEXT to discover the actual children of kern.evdev.input without a fixed upper bound, then resolves each unit's name via CTL_SYSCTL_NAME to extract the unit number for the /dev/input/eventN syspath. Devices already discovered by scandir are deduplicated by udev_list_insert.

This lets libinput (and other libudev consumers) enumerate input devices in environments where the evdev sysctls are accessible but the devnodes are not.

Test setup:

When /dev/input/ is not visible to the calling process (for example, a
FreeBSD jail without the corresponding devfs ruleset), the existing
scandir-based enumeration in udev_dev_enumerate() cannot discover any
input devices, even though the kern.evdev.input.* sysctls remain
readable and the per-device property handlers already populate from
those sysctls.

Add a sysctl tree-walk fallback that runs after the scandir pass.  The
walk uses CTL_SYSCTL_NEXT to discover the actual children of
kern.evdev.input without a fixed upper bound, then resolves each unit's
name via CTL_SYSCTL_NAME to extract the unit number for the
/dev/input/eventN syspath.  Devices already discovered by scandir are
deduplicated by udev_list_insert.

This lets libinput (and other libudev consumers) enumerate input devices
in environments where the evdev sysctls are accessible but the devnodes
are not.

Signed-off-by: Quentin Thebault <quentin.thebault@defenso.fr>
Sponsored-by: Defenso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant