aboutsummaryrefslogtreecommitdiff
path: root/marsond.c
diff options
context:
space:
mode:
Diffstat (limited to 'marsond.c')
-rw-r--r--marsond.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/marsond.c b/marsond.c
index 8070d78..d85673c 100644
--- a/marsond.c
+++ b/marsond.c
@@ -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) {