<p><br>
On May 14, 2011 3:39 PM, "Cody Maloney" <<a href="mailto:cmaloney@theoreticalchaos.com">cmaloney@theoreticalchaos.com</a>> wrote:<br>
><br>
> According to the comment in the Linux kernel source file<br>
> drivers/tty/vt/vt_ioctl.c /dev/tty0 points to /dev/console,<br>
> so we should just go to /dev/console, and virtual terminals<br>
> are always labeled /dev/ttyN where N is 1..MAX_NR_CONSOLES,<br>
> so only check /dev/ttyN.<br>
><br>
> Signed-off-by: Cody Maloney <<a href="mailto:cmaloney@theoreticalchaos.com">cmaloney@theoreticalchaos.com</a>><br>
> ---<br>
> hw/xfree86/os-support/linux/lnx_init.c | 39 ++++++-------------------------<br>
> 1 files changed, 8 insertions(+), 31 deletions(-)<br>
><br>
> diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c<br>
> index 77dfb2f..04518f3 100644<br>
> --- a/hw/xfree86/os-support/linux/lnx_init.c<br>
> +++ b/hw/xfree86/os-support/linux/lnx_init.c<br>
> @@ -76,17 +76,17 @@ switch_to(int vt, const char *from)<br>
> void<br>
> xf86OpenConsole(void)<br>
> {<br>
> - int i, fd = -1, ret;<br>
> + int fd = -1, ret;<br>
> struct vt_mode VT;<br>
> struct vt_stat vts;<br>
> MessageType from = X_PROBED;<br>
> - char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };<br>
> - char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };<br>
> + const char *console_fname = "/dev/console";<br>
> + char *vcs = "/dev/tty%d";<br>
><br>
> if (serverGeneration == 1) {<br>
><br>
> /* when KeepTty check if we're run with euid==0 */<br>
> - if (KeepTty && geteuid() != 0)<br>
> + if (KeepTty && geteuid() != 0)<br>
> FatalError("xf86OpenConsole:"<br>
> " Server must be suid root for option \"KeepTTY\"\n");<br>
><br>
> @@ -96,17 +96,11 @@ xf86OpenConsole(void)<br>
> if (xf86Info.vtno != -1) {<br>
> from = X_CMDLINE;<br>
> } else {<br>
> + fd = open(console_fname, O_WRONLY, 0);<br>
><br>
> - i=0;<br>
> - while (tty0[i] != NULL) {<br>
> - if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)<br>
> - break;<br>
> - i++;<br>
> - }<br>
> -<br>
> if (fd < 0)<br>
> FatalError(<br>
> - "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",<br>
> + "xf86OpenConsole: Cannot open /dev/console to use VT ioctls (%s)\n",<br>
> strerror(errno));<br>
><br>
> if (ShareVTs)<br>
> @@ -149,13 +143,8 @@ xf86OpenConsole(void)<br>
> strerror(errno));<br>
> }<br>
><br>
> - i=0;<br>
> - while (vcs[i] != NULL) {<br>
> - sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */<br>
> - if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0)<br>
> - break;<br>
> - i++;<br>
> - }<br>
> + sprintf(vtname, vcs, xf86Info.vtno); /* /dev/tty1-64 */<br>
> + xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0);<br>
><br>
> if (xf86Info.consoleFd < 0)<br>
> FatalError("xf86OpenConsole: Cannot open virtual console"<br>
> @@ -172,18 +161,6 @@ xf86OpenConsole(void)<br>
> else<br>
> activeVT = vts.v_active;<br>
><br>
> -#if 0<br>
> - if (!KeepTty) {<br>
> - /*<br>
> - * Detach from the controlling tty to avoid char loss<br>
> - */<br>
> - if ((i = open("/dev/tty",O_RDWR)) >= 0) {<br>
> - SYSCALL(ioctl(i, TIOCNOTTY, 0));<br>
> - close(i);<br>
> - }<br>
> - }<br>
> -#endif<br>
> -<br>
> if (!ShareVTs)<br>
> {<br>
> struct termios nTty;<br>
> --<br>
> 1.7.5.1<br>
><br>
> _______________________________________________<br>
> <a href="mailto:xorg-devel@lists.x.org">xorg-devel@lists.x.org</a>: X.Org development<br>
> Archives: <a href="http://lists.x.org/archives/xorg-devel">http://lists.x.org/archives/xorg-devel</a><br>
> Info: <a href="http://lists.x.org/mailman/listinfo/xorg-devel">http://lists.x.org/mailman/listinfo/xorg-devel</a></p>
<p>This may be different when operating under mdev, devfs, android init, devtmpfs (devfs replacement, not sure that's what it's called), especially /dev/vc/*</p>
<p>Timothy Meade (tmzt)</p>