From be0917abc6343676c3a28a11f96624a528e49619 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 5 Jan 2026 15:56:31 -0500 Subject: Print /dev/input/event* device node in debug output. --- marsond.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/marsond.c b/marsond.c index 8070d78..d85673c 100644 --- a/marsond.c +++ b/marsond.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -293,6 +294,18 @@ void set_evbit(int outfd, int event) { } } +void get_device_node(char *result) { + char path[PATH_MAX]; + + /* trick here: outfd is the last file we opened. while running, we + have an open file descriptor for the virtual device, which *must* + be the next integer file descriptor after outfd. */ + snprintf(path, PATH_MAX - 1, "/proc/%d/fd/%d", getpid(), outfd + 1); + + if(readlink(path, result, UINPUT_MAX_NAME_SIZE - 1) < 0) + strcpy(result, "(unknown)"); +} + void print_device_name(void) { char name[UINPUT_MAX_NAME_SIZE]; @@ -301,6 +314,9 @@ void print_device_name(void) { } else { debug("created virtual keyboard device but couldn't get its name (old kernel?)"); } + + get_device_node(name); + debug("device node: %s", name); } int main(int argc, char **argv) { -- cgit v1.2.3