diff options
author | Adam Jackson <ajax@redhat.com> | 2010-05-11 09:16:19 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2010-11-30 13:28:28 -0500 |
commit | 7ee965a300c9eddcc1acacf9414cfe3e589222a8 (patch) | |
tree | 75c3b5bb173f66aa627c47bf8ed052e77aec99bf | |
parent | 0def735c6a9fab19acc4b806def6921a702f617f (diff) |
linux: Refactor VT switch on {re,}generation and shutdown
This makes more things fatal than were fatal before, but that's correct;
if you need the VT, then failing to get it on regeneration means things
are about to go very very badly.
Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
-rw-r--r-- | hw/xfree86/os-support/linux/lnx_init.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c index 58051d7c9..9c71a42b2 100644 --- a/hw/xfree86/os-support/linux/lnx_init.c +++ b/hw/xfree86/os-support/linux/lnx_init.c @@ -59,6 +59,16 @@ drain_console(int fd, void *closure) } } +static void +switch_to(int vt, const char *from) +{ + if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vt) < 0) + FatalError("%s: VT_ACTIVATE failed: %s\n", from, strerror(errno)); + + if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, vt) < 0) + FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno)); +} + void xf86OpenConsole(void) { @@ -174,13 +184,7 @@ xf86OpenConsole(void) /* * now get the VT. This _must_ succeed, or else fail completely. */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0) - FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n", - strerror(errno)); - - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0) - FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n", - strerror(errno)); + switch_to(xf86Info.vtno, "xf86OpenConsole"); if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) FatalError("xf86OpenConsole: VT_GETMODE failed %s\n", @@ -227,16 +231,8 @@ xf86OpenConsole(void) } else { /* serverGeneration != 1 */ if (!ShareVTs && VTSwitch) { - /* - * now get the VT - */ - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0) - xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed %s\n", - strerror(errno)); - - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0) - xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed %s\n", - strerror(errno)); + /* now get the VT */ + switch_to(xf86Info.vtno, "xf86OpenConsole"); } } } @@ -281,13 +277,7 @@ xf86CloseConsole(void) * Perform a switch back to the active VT when we were started */ if (activeVT >= 0) { - if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0) - xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n", - strerror(errno)); - if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, activeVT) < 0) - xf86Msg(X_WARNING, - "xf86CloseConsole: VT_WAITACTIVE failed: %s\n", - strerror(errno)); + switch_to(activeVT, "xf86CloseConsole"); activeVT = -1; } } |