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

Dima Ryazanov dima at gmail.com
Tue Sep 27 21:44:30 UTC 2016


The kernel version used to build Weston isn't necessarily the same as the
version that will be used to run it. Weston should already work fine on
older versions: the second ioctl will return an error - but it's ok as long
as the first one succeeds.

Also, a compile-time check would prevent Weston built on an old kernel from
taking advantage of new features when running on a new kernel.


On Tue, Sep 27, 2016 at 9:37 AM, Krzysztof Konopko <kris at youview.com> wrote:

> 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
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20160927/342a6078/attachment.html>


More information about the wayland-devel mailing list