diff options
author | Tom Lear <tom@trap.mtview.ca.us> | 2011-07-20 13:17:16 +0300 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2011-07-20 16:29:41 +0200 |
commit | 042c70beed197fbe0b81523d9ddd12b4fa4b8af0 (patch) | |
tree | 5c94c3f4e09ca89dbadd90f9a6b7aab9bdda32a4 | |
parent | 3963bdfd72f1a0c619d507d0a824ff255746713f (diff) | |
download | input-042c70beed197fbe0b81523d9ddd12b4fa4b8af0.tar.gz |
ignore gaps in the input device numbering
This bug can be reproduced on any architecture, plug in 2 usb mice, then
unplug the first one... there's your gap in event device numbers.
http://bugs.debian.org/326149
-rw-r--r-- | lsinput.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -1,5 +1,6 @@ #include <stdio.h> #include <stdlib.h> +#include <sys/stat.h> #include <unistd.h> #include <fcntl.h> @@ -10,14 +11,19 @@ static void list_devices(void) { int i,fd; + char filename[32]; + struct stat statbuf; for (i = 0; i < 32; i++) { - /* try to open */ - fd = device_open(i,1); - if (-1 == fd) - return; - device_info(fd); - close(fd); + snprintf(filename,sizeof(filename), "/dev/input/event%d",i); + if (stat(filename, &statbuf) == 0) { + /* try to open */ + fd = device_open(i,1); + if (-1 == fd) + return; + device_info(fd); + close(fd); + } } return; } |