forked from pool/xorg-x11-server
115 lines
3.6 KiB
Diff
115 lines
3.6 KiB
Diff
|
From 81bcada14e339fe2a2fb3f3a040566d94dc20bad Mon Sep 17 00:00:00 2001
|
||
|
From: Hans de Goede <hdegoede@redhat.com>
|
||
|
Date: Wed, 13 May 2015 13:17:09 +0200
|
||
|
Subject: [PATCH] linux: Add a may_fail paramter to linux_parse_vt_settings
|
||
|
|
||
|
linux_parse_vt_settings() was split out of xf86OpenConsole so that it can
|
||
|
be called earlier during systemd-logind init, but it is possible to run
|
||
|
the xserver in such a way that xf86OpenConsole() is never used.
|
||
|
|
||
|
The FatalError calls in linux_parse_vt_settings() may stop the Xorg xserver
|
||
|
from working when e.g. no /dev/tty0 is present in such a setup.
|
||
|
|
||
|
This commit adds a may_fail parameter to linux_parse_vt_settings() which
|
||
|
can be used to make linux_parse_vt_settings() fail silenty with an error
|
||
|
return in this case, rather then calling FatalError().
|
||
|
|
||
|
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
||
|
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
|
||
|
---
|
||
|
hw/xfree86/os-support/linux/linux.h | 2 +-
|
||
|
hw/xfree86/os-support/linux/lnx_init.c | 29 +++++++++++++++++++++--------
|
||
|
2 files changed, 22 insertions(+), 9 deletions(-)
|
||
|
|
||
|
--- a/hw/xfree86/os-support/linux/linux.h
|
||
|
+++ b/hw/xfree86/os-support/linux/linux.h
|
||
|
@@ -26,7 +26,7 @@
|
||
|
#ifndef XF86_LINUX_H
|
||
|
#define XF86_LINUX_H
|
||
|
|
||
|
-void linux_parse_vt_settings(void);
|
||
|
+int linux_parse_vt_settings(int may_fail);
|
||
|
int linux_get_keeptty(void);
|
||
|
|
||
|
#endif
|
||
|
--- a/hw/xfree86/os-support/linux/lnx_init.c
|
||
|
+++ b/hw/xfree86/os-support/linux/lnx_init.c
|
||
|
@@ -87,8 +87,8 @@ switch_to(int vt, const char *from, Bool
|
||
|
#pragma GCC diagnostic push
|
||
|
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||
|
|
||
|
-void
|
||
|
-linux_parse_vt_settings(void)
|
||
|
+int
|
||
|
+linux_parse_vt_settings(int may_fail)
|
||
|
{
|
||
|
int i, fd = -1, ret, current_vt = -1;
|
||
|
struct vt_stat vts;
|
||
|
@@ -100,7 +100,7 @@ linux_parse_vt_settings(void)
|
||
|
static int vt_settings_parsed = 0;
|
||
|
|
||
|
if (vt_settings_parsed)
|
||
|
- return;
|
||
|
+ return 1;
|
||
|
|
||
|
/*
|
||
|
* setup the virtual terminal manager
|
||
|
@@ -117,24 +117,36 @@ linux_parse_vt_settings(void)
|
||
|
i++;
|
||
|
}
|
||
|
|
||
|
- if (fd < 0)
|
||
|
+ if (fd < 0) {
|
||
|
+ if (may_fail)
|
||
|
+ return 0;
|
||
|
FatalError("parse_vt_settings: Cannot open /dev/tty0 (%s)\n",
|
||
|
strerror(errno));
|
||
|
+ }
|
||
|
|
||
|
if (xf86Info.ShareVTs) {
|
||
|
SYSCALL(ret = ioctl(fd, VT_GETSTATE, &vts));
|
||
|
- if (ret < 0)
|
||
|
+ if (ret < 0) {
|
||
|
+ if (may_fail)
|
||
|
+ return 0;
|
||
|
FatalError("parse_vt_settings: Cannot find the current"
|
||
|
" VT (%s)\n", strerror(errno));
|
||
|
+ }
|
||
|
xf86Info.vtno = vts.v_active;
|
||
|
}
|
||
|
else {
|
||
|
SYSCALL(ret = ioctl(fd, VT_OPENQRY, &xf86Info.vtno));
|
||
|
- if (ret < 0)
|
||
|
+ if (ret < 0) {
|
||
|
+ if (may_fail)
|
||
|
+ return 0;
|
||
|
FatalError("parse_vt_settings: Cannot find a free VT: "
|
||
|
"%s\n", strerror(errno));
|
||
|
- if (xf86Info.vtno == -1)
|
||
|
+ }
|
||
|
+ if (xf86Info.vtno == -1) {
|
||
|
+ if (may_fail)
|
||
|
+ return 0;
|
||
|
FatalError("parse_vt_settings: Cannot find a free VT\n");
|
||
|
+ }
|
||
|
}
|
||
|
close(fd);
|
||
|
}
|
||
|
@@ -158,6 +170,7 @@ linux_parse_vt_settings(void)
|
||
|
}
|
||
|
|
||
|
vt_settings_parsed = 1;
|
||
|
+ return 1;
|
||
|
}
|
||
|
|
||
|
int
|
||
|
@@ -175,7 +188,7 @@ xf86OpenConsole(void)
|
||
|
const char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
|
||
|
|
||
|
if (serverGeneration == 1) {
|
||
|
- linux_parse_vt_settings();
|
||
|
+ linux_parse_vt_settings(FALSE);
|
||
|
|
||
|
if (!KeepTty) {
|
||
|
pid_t ppid = getppid();
|