[PATCH] weston-launch: Protect KDGKBMODE K_OFF ioctl by KERNEL_VERSION check

Krzysztof Konopko kris at youview.com
Thu Sep 15 11:06:20 UTC 2016


From: Tomasz SZKUTKOWSKI <tomasz.szkutkowski at youview.com>

This patch disables unsupported ioctl `KDGKBMODE K_OFF` command if Weston
is built against kernel older than 2.6.39, as this ioctl has been
introduced in 2.6.39 kernel version.

No functional changes have been observed by disabling this ioctl.

Signed-off-by: Tomasz SZKUTKOWSKI <tomasz.szkutkowski at youview.com>
Signed-off-by: Krzysztof Konopko <kris at youview.com>
---
 libweston/launcher-direct.c | 5 +++++
 libweston/weston-launch.c   | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/libweston/launcher-direct.c b/libweston/launcher-direct.c
index 29d9c28..34fe5cd 100644
--- a/libweston/launcher-direct.c
+++ b/libweston/launcher-direct.c
@@ -34,6 +34,7 @@
 #include <linux/vt.h>
 #include <linux/kd.h>
 #include <linux/major.h>
+#include <linux/version.h>

 #include "launcher-impl.h"

@@ -157,8 +158,12 @@ setup_tty(struct launcher_direct *launcher, int tty)
                goto err_close;
        }

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
        if (ioctl(launcher->tty, KDSKBMUTE, 1) &&
            ioctl(launcher->tty, KDSKBMODE, K_OFF)) {
+#else
+       if (ioctl(launcher->tty, KDSKBMUTE, 1)) {
+#endif
                weston_log("failed to set K_OFF keyboard mode: %m\n");
                goto err_close;
        }
diff --git a/libweston/weston-launch.c b/libweston/weston-launch.c
index 140fde1..74b80dd 100644
--- a/libweston/weston-launch.c
+++ b/libweston/weston-launch.c
@@ -49,6 +49,7 @@
 #include <linux/vt.h>
 #include <linux/major.h>
 #include <linux/kd.h>
+#include <linux/version.h>

 #include <pwd.h>
 #include <grp.h>
@@ -561,8 +562,12 @@ setup_tty(struct weston_launch *wl, const char *tty)
        if (ioctl(wl->tty, KDGKBMODE, &wl->kb_mode))
                error(1, errno, "failed to get current keyboard mode: %m\n");

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
        if (ioctl(wl->tty, KDSKBMUTE, 1) &&
            ioctl(wl->tty, KDSKBMODE, K_OFF))
+#else
+       if (ioctl(wl->tty, KDSKBMUTE, 1))
+#endif
                error(1, errno, "failed to set K_OFF keyboard mode: %m\n");

        if (ioctl(wl->tty, KDSETMODE, KD_GRAPHICS))
--
2.1.4

This transmission contains information that may be confidential and contain personal views which are not necessarily those of YouView TV Ltd. YouView TV Ltd (Co No:7308805) is a limited liability company registered in England and Wales with its registered address at YouView TV Ltd, 3rd Floor, 10 Lower Thames Street, London, EC3R 6YT. For details see our web site at http://www.youview.com


More information about the wayland-devel mailing list