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>
This commit is contained in:
parent
1dba5a0b19
commit
81bcada14e
|
@ -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
|
||||
|
|
|
@ -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,25 +110,37 @@ 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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user