drm-lease: Disable weston TTY switch
[AGL/meta-agl-devel.git] / meta-agl-drm-lease / recipes-graphics / weston / weston / 0004-launcher-direct-handle-seat0-without-VTs.patch
1 From 3b72ab4b5399641bb69e29464bcbd14f5f6cb6c0 Mon Sep 17 00:00:00 2001
2 From: nerdopolis <bluescreen_avenger@verizon.net>
3 Date: Wed, 20 Jan 2021 22:00:18 -0500
4 Subject: [PATCH 4/4] launcher-direct: handle seat0 without VTs
5
6 This allows launcher-direct to run when seat0 has no TTYs
7 This checks for a proper /dev/tty0 device as /dev/tty0
8 does not get created by kernels compiled with CONFIG_VT=n
9
10 (cherry picked from commit 72db3ac694c0f84f3c193df42e81be8329e52b61)
11 Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp>
12 ---
13  libweston/launcher-direct.c | 7 ++++++-
14  1 file changed, 6 insertions(+), 1 deletion(-)
15
16 diff --git a/libweston/launcher-direct.c b/libweston/launcher-direct.c
17 index 71c332a..840a3c5 100644
18 --- a/libweston/launcher-direct.c
19 +++ b/libweston/launcher-direct.c
20 @@ -290,6 +290,7 @@ launcher_direct_connect(struct weston_launcher **out, struct weston_compositor *
21                         int tty, const char *seat_id, bool sync_drm)
22  {
23         struct launcher_direct *launcher;
24 +       struct stat buf;
25  
26  #ifndef ENABLE_USER_START
27         if (geteuid() != 0)
28 @@ -303,7 +304,11 @@ launcher_direct_connect(struct weston_launcher **out, struct weston_compositor *
29         launcher->base.iface = &launcher_direct_iface;
30         launcher->compositor = compositor;
31  
32 -       if (strcmp("seat0", seat_id) == 0) {
33 +       /* Checking the existance of /dev/tty0 and verifying it's a TTY
34 +        * device, as kernels compiled with CONFIG_VT=0 do not create these
35 +        * devices. */
36 +       if (stat("/dev/tty0", &buf) == 0 &&
37 +           strcmp("seat0", seat_id) == 0 && major(buf.st_rdev) == TTY_MAJOR) {
38                 if (setup_tty(launcher, tty) == -1) {
39                         free(launcher);
40                         return -1;
41 -- 
42 2.17.1
43