diff options
| author | B. Watson <urchlay@slackware.uk> | 2026-01-05 15:56:31 -0500 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2026-01-05 15:56:31 -0500 |
| commit | be0917abc6343676c3a28a11f96624a528e49619 (patch) | |
| tree | a99f333bf09b9e32fee37109394f7f10cc9c078f | |
| parent | 5f1ea71209b185c80072debb66fec38e7573da13 (diff) | |
| download | marsond-be0917abc6343676c3a28a11f96624a528e49619.tar.gz | |
Print /dev/input/event* device node in debug output.
| -rw-r--r-- | marsond.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -11,6 +11,7 @@ #include <pwd.h> #include <grp.h> #include <signal.h> +#include <limits.h> #include <sys/resource.h> #include <sys/mman.h> @@ -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) { |
