[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-input-evdev: Changes to 'debian-experimental'



 configure.ac     |    2 
 debian/changelog |    6 ++
 src/evdev.c      |  114 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/evdev.h      |    4 +
 4 files changed, 124 insertions(+), 2 deletions(-)

New commits:
commit 7a0c4edcbf434043eb022c87086f97fb5ef398cb
Author: Timo Aaltonen <tjaalton@cc.hut.fi>
Date:   Wed Nov 19 15:37:09 2008 +0200

    Update the changelog.

diff --git a/debian/changelog b/debian/changelog
index 9d09e19..b672544 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+xserver-xorg-input-evdev (1:2.1.0-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Timo Aaltonen <tepsipakki@ubuntu.com>  Wed, 19 Nov 2008 15:34:39 +0200
+
 xserver-xorg-input-evdev (1:2.0.99.3-1) experimental; urgency=low
 
   [ Timo Aaltonen ]

commit b879ae73510ad733c266fba80e0ec4b0f903e71b
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Mon Nov 17 09:27:25 2008 +1000

    evdev 2.1

diff --git a/configure.ac b/configure.ac
index f1d06cd..f668d1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -22,7 +22,7 @@
 
 AC_PREREQ(2.57)
 AC_INIT([xf86-input-evdev],
-        2.0.99.3,
+        2.1.0,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-input-evdev)
 

commit 53566b7d4d7e641df4db5720ae9132eb4c812c84
Author: Peter Hutterer <peter.hutterer@redhat.com>
Date:   Mon Nov 17 10:03:11 2008 +1000

    Store device file's minor/major to avoid duplicate devices.
    
    Devices added that use the same min/maj as an already added device are ignored
    by the driver. This way users can have an xorg.conf entry on
    /dev/input/by-id/blahblah and not get the same device added by HAL.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>
    (cherry picked from commit 63af314368cec47b6b8266db331f2c820e7a071f)

diff --git a/src/evdev.c b/src/evdev.c
index 3051531..25325a3 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -32,6 +32,7 @@
 
 #include <X11/keysym.h>
 
+#include <sys/stat.h>
 #include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -51,6 +52,10 @@
 #include <evdev-properties.h>
 #endif
 
+#ifndef MAXDEVICES
+#include <inputstr.h> /* for MAX_DEVICES */
+#define MAXDEVICES MAX_DEVICES
+#endif
 
 /* 2.4 compatibility */
 #ifndef EVIOCGRAB
@@ -112,6 +117,88 @@ static Atom prop_calibration = 0;
 static Atom prop_swap = 0;
 #endif
 
+/* All devices the evdev driver has allocated and knows about.
+ * MAXDEVICES is safe as null-terminated array, as two devices (VCP and VCK)
+ * cannot be used by evdev, leaving us with a space of 2 at the end. */
+static EvdevPtr evdev_devices[MAXDEVICES] = {0};
+
+static int
+EvdevGetMajorMinor(InputInfoPtr pInfo)
+{
+    struct stat st;
+
+    if (fstat(pInfo->fd, &st) == -1)
+    {
+        xf86Msg(X_ERROR, "%s: stat failed (%s). cannot check for duplicates.\n",
+                pInfo->name, strerror(errno));
+        return 0;
+    }
+
+    return st.st_rdev;
+}
+
+/**
+ * Return TRUE if one of the devices we know about has the same min/maj
+ * number.
+ */
+static BOOL
+EvdevIsDuplicate(InputInfoPtr pInfo)
+{
+    EvdevPtr pEvdev = pInfo->private;
+    EvdevPtr* dev   = evdev_devices;
+
+    if (pEvdev->min_maj)
+    {
+        while(*dev)
+        {
+            if ((*dev) != pEvdev &&
+                (*dev)->min_maj &&
+                (*dev)->min_maj == pEvdev->min_maj)
+                return TRUE;
+            dev++;
+        }
+    }
+    return FALSE;
+}
+
+/**
+ * Add to internal device list.
+ */
+static void
+EvdevAddDevice(InputInfoPtr pInfo)
+{
+    EvdevPtr pEvdev = pInfo->private;
+    EvdevPtr* dev = evdev_devices;
+
+    while(*dev)
+        dev++;
+
+    *dev = pEvdev;
+}
+
+/**
+ * Remove from internal device list.
+ */
+static void
+EvdevRemoveDevice(InputInfoPtr pInfo)
+{
+    EvdevPtr pEvdev = pInfo->private;
+    EvdevPtr *dev   = evdev_devices;
+    int count       = 0;
+
+    while(*dev)
+    {
+        count++;
+        if (*dev == pEvdev)
+        {
+            memmove(dev, dev + 1,
+                    sizeof(evdev_devices) - (count * sizeof(EvdevPtr)));
+            break;
+        }
+        dev++;
+    }
+}
+
 
 static void
 SetXkbOption(InputInfoPtr pInfo, char *name, char **option)
@@ -205,6 +292,7 @@ EvdevReopenTimer(OsTimerPtr timer, CARD32 time, pointer arg)
             DisableDevice(pInfo->dev);
             close(pInfo->fd);
             pInfo->fd = -1;
+            pEvdev->min_maj = 0; /* don't hog the device */
         }
         pEvdev->reopen_left = 0;
         return 0;
@@ -217,6 +305,7 @@ EvdevReopenTimer(OsTimerPtr timer, CARD32 time, pointer arg)
         xf86Msg(X_ERROR, "%s: Failed to reopen device after %d attempts.\n",
                 pInfo->name, pEvdev->reopen_attempts);
         DisableDevice(pInfo->dev);
+        pEvdev->min_maj = 0; /* don't hog the device */
         return 0;
     }
 
@@ -1024,6 +1113,14 @@ EvdevOn(DeviceIntPtr device)
         pEvdev->reopen_timer = TimerSet(NULL, 0, 100, EvdevReopenTimer, pInfo);
     } else
     {
+        pEvdev->min_maj = EvdevGetMajorMinor(pInfo);
+        if (EvdevIsDuplicate(pInfo))
+        {
+            xf86Msg(X_WARNING, "%s: Refusing to enable duplicate device.\n",
+                    pInfo->name);
+            return !Success;
+        }
+
         xf86FlushInput(pInfo->fd);
         xf86AddEnabledDevice(pInfo);
         EvdevMBEmuOn(pInfo);
@@ -1062,6 +1159,7 @@ EvdevProc(DeviceIntPtr device, int what)
             close(pInfo->fd);
             pInfo->fd = -1;
         }
+        pEvdev->min_maj = 0;
         if (pEvdev->flags & EVDEV_INITIALIZED)
             EvdevMBEmuFinalize(pInfo);
         pEvdev->flags &= ~EVDEV_INITIALIZED;
@@ -1079,6 +1177,8 @@ EvdevProc(DeviceIntPtr device, int what)
             close(pInfo->fd);
             pInfo->fd = -1;
         }
+        EvdevRemoveDevice(pInfo);
+        pEvdev->min_maj = 0;
 	break;
     }
 
@@ -1386,6 +1486,17 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
         return NULL;
     }
 
+    /* Check major/minor of device node to avoid adding duplicate devices. */
+    pEvdev->min_maj = EvdevGetMajorMinor(pInfo);
+    if (EvdevIsDuplicate(pInfo))
+    {
+        xf86Msg(X_WARNING, "%s: device file already in use. Ignoring.\n",
+                pInfo->name);
+        close(pInfo->fd);
+        xf86DeleteInput(pInfo, 0);
+        return NULL;
+    }
+
     pEvdev->reopen_attempts = xf86SetIntOption(pInfo->options, "ReopenAttempts", 10);
     pEvdev->invert_x = xf86SetBoolOption(pInfo->options, "InvertX", FALSE);
     pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
@@ -1407,6 +1518,7 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
     }
 
     EvdevCacheCompare(pInfo, FALSE); /* cache device data */
+    EvdevAddDevice(pInfo);
 
     if (pEvdev->flags & EVDEV_BUTTON_EVENTS)
     {
diff --git a/src/evdev.h b/src/evdev.h
index 32da81c..af88741 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -31,6 +31,7 @@
 #define EVDEV_H
 
 #include <linux/input.h>
+#include <linux/types.h>
 
 #include <xf86Xinput.h>
 #include <xf86_OSproc.h>
@@ -125,6 +126,9 @@ typedef struct {
     long abs_bitmask[NBITS(ABS_MAX)];
     long led_bitmask[NBITS(LED_MAX)];
     struct input_absinfo absinfo[ABS_MAX];
+
+    /* minor/major number */
+    dev_t min_maj;
 } EvdevRec, *EvdevPtr;
 
 unsigned int EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code);

commit 29c2765fc30c74171e51ba694ea4810916803c31
Author: Fernando Carrijo <fcarrijo@yahoo.com.br>
Date:   Thu Nov 6 13:20:16 2008 -0500

    Fix error message
    (cherry picked from commit 4c5c9c111d406e5590429377262b86e91868ef76)

diff --git a/src/evdev.c b/src/evdev.c
index 638831d..3051531 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1118,7 +1118,7 @@ EvdevCacheCompare(InputInfoPtr pInfo, BOOL compare)
 
     if (ioctl(pInfo->fd,
               EVIOCGBIT(0, sizeof(bitmask)), bitmask) < 0) {
-        xf86Msg(X_ERROR, "ioctl EVIOCGNAME failed: %s\n", strerror(errno));
+        xf86Msg(X_ERROR, "ioctl EVIOCGBIT failed: %s\n", strerror(errno));
         goto error;
     }
 


Reply to: