122 lines
3.8 KiB
Diff
122 lines
3.8 KiB
Diff
From 4237375e8c159ce95ec77868f74edacc896f8714 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 v2 2/3] 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>
|
|
---
|
|
hw/xfree86/os-support/linux/linux.h | 2 +-
|
|
hw/xfree86/os-support/linux/lnx_init.c | 29 +++++++++++++++++++++--------
|
|
2 files changed, 22 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/hw/xfree86/os-support/linux/linux.h b/hw/xfree86/os-support/linux/linux.h
|
|
index 8cb8e3d..83506fd 100644
|
|
--- 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
|
|
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
|
|
index 22c61bf..12ddf91 100644
|
|
--- a/hw/xfree86/os-support/linux/lnx_init.c
|
|
+++ b/hw/xfree86/os-support/linux/lnx_init.c
|
|
@@ -80,8 +80,8 @@ switch_to(int vt, const char *from)
|
|
#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;
|
|
@@ -93,7 +93,7 @@ linux_parse_vt_settings(void)
|
|
static int vt_settings_parsed = 0;
|
|
|
|
if (vt_settings_parsed)
|
|
- return;
|
|
+ return 1;
|
|
|
|
/*
|
|
* setup the virtual terminal manager
|
|
@@ -110,24 +110,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);
|
|
}
|
|
@@ -151,6 +163,7 @@ linux_parse_vt_settings(void)
|
|
}
|
|
|
|
vt_settings_parsed = 1;
|
|
+ return 1;
|
|
}
|
|
|
|
int
|
|
@@ -168,7 +181,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();
|
|
--
|
|
2.4.0
|
|
|