[PATCH] linux: Clean up filenames used in Linux VT init.
Timothy Meade
zt.tmzt at gmail.com
Mon May 16 05:27:13 PDT 2011
On May 14, 2011 3:39 PM, "Cody Maloney" <cmaloney at theoreticalchaos.com>
wrote:
>
> According to the comment in the Linux kernel source file
> drivers/tty/vt/vt_ioctl.c /dev/tty0 points to /dev/console,
> so we should just go to /dev/console, and virtual terminals
> are always labeled /dev/ttyN where N is 1..MAX_NR_CONSOLES,
> so only check /dev/ttyN.
>
> Signed-off-by: Cody Maloney <cmaloney at theoreticalchaos.com>
> ---
> hw/xfree86/os-support/linux/lnx_init.c | 39
++++++-------------------------
> 1 files changed, 8 insertions(+), 31 deletions(-)
>
> diff --git a/hw/xfree86/os-support/linux/lnx_init.c
b/hw/xfree86/os-support/linux/lnx_init.c
> index 77dfb2f..04518f3 100644
> --- a/hw/xfree86/os-support/linux/lnx_init.c
> +++ b/hw/xfree86/os-support/linux/lnx_init.c
> @@ -76,17 +76,17 @@ switch_to(int vt, const char *from)
> void
> xf86OpenConsole(void)
> {
> - int i, fd = -1, ret;
> + int fd = -1, ret;
> struct vt_mode VT;
> struct vt_stat vts;
> MessageType from = X_PROBED;
> - char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
> - char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
> + const char *console_fname = "/dev/console";
> + char *vcs = "/dev/tty%d";
>
> if (serverGeneration == 1) {
>
> /* when KeepTty check if we're run with euid==0 */
> - if (KeepTty && geteuid() != 0)
> + if (KeepTty && geteuid() != 0)
> FatalError("xf86OpenConsole:"
> " Server must be suid root for option
\"KeepTTY\"\n");
>
> @@ -96,17 +96,11 @@ xf86OpenConsole(void)
> if (xf86Info.vtno != -1) {
> from = X_CMDLINE;
> } else {
> + fd = open(console_fname, O_WRONLY, 0);
>
> - i=0;
> - while (tty0[i] != NULL) {
> - if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)
> - break;
> - i++;
> - }
> -
> if (fd < 0)
> FatalError(
> - "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
> + "xf86OpenConsole: Cannot open /dev/console to use VT
ioctls (%s)\n",
> strerror(errno));
>
> if (ShareVTs)
> @@ -149,13 +143,8 @@ xf86OpenConsole(void)
> strerror(errno));
> }
>
> - i=0;
> - while (vcs[i] != NULL) {
> - sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
> - if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >=
0)
> - break;
> - i++;
> - }
> + sprintf(vtname, vcs, xf86Info.vtno); /* /dev/tty1-64 */
> + xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0);
>
> if (xf86Info.consoleFd < 0)
> FatalError("xf86OpenConsole: Cannot open virtual console"
> @@ -172,18 +161,6 @@ xf86OpenConsole(void)
> else
> activeVT = vts.v_active;
>
> -#if 0
> - if (!KeepTty) {
> - /*
> - * Detach from the controlling tty to avoid char loss
> - */
> - if ((i = open("/dev/tty",O_RDWR)) >= 0) {
> - SYSCALL(ioctl(i, TIOCNOTTY, 0));
> - close(i);
> - }
> - }
> -#endif
> -
> if (!ShareVTs)
> {
> struct termios nTty;
> --
> 1.7.5.1
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
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/*
Timothy Meade (tmzt)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20110516/e60686dc/attachment.htm>
More information about the xorg-devel
mailing list