[PATCH] linux: Fix error message when /dev/tty0 fails to open

Chad Versace chad.versace at linux.intel.com
Fri Jan 13 16:12:25 PST 2012


When attempting to open the console device during initialization, X first
tries to open /dev/tty0 in write-only mode, and if that fails it attempts
to open /dev/vc/0. If both attempts fail, the error message below is
logged. The message is incorrect because the errno is that resulting from
the failure to open /dev/vc/0.

    xf86OpenConsole: Cannot open /dev/tty0 ({strerror(errno)})

On a machine in which /dev/tty0 does exist but /dev/vc/0 does not, such as
my machine, the log misleadingly says:

    Fatal server error:
    [  3167.976] xf86OpenConsole: Cannot open /dev/tty0 (No such file or directory)

This patch fixes the log to report the correct errno for each device. The
result is this log snippet:

    [  3755.177] (WW) xf86OpenConsole: Failed to open /dev/tty0 for writing (Permission denied)
    [  3755.177] (WW) xf86OpenConsole: Failed to open /dev/vc/0 for writing (No such file or directory)
    [  3755.177]
    Fatal server error:
    [  3755.177] xf86OpenConsole: Failed to open console device

Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 hw/xfree86/os-support/linux/lnx_init.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 2176985..b1ad1a8 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -96,13 +96,13 @@ xf86OpenConsole(void)
 	    while (tty0[i] != NULL) {
 		if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)
 		  break;
+		xf86Msg(X_WARNING, "xf86OpenConsole: Failed to open %s for "
+		        "writing (%s)\n", tty0[i], strerror(errno));
 		i++;
 	    }
 	    
 	    if (fd < 0)
-		FatalError(
-		    "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
-		    strerror(errno));
+		FatalError("xf86OpenConsole: Failed to open console device\n");
 
             if (xf86Info.ShareVTs)
             {
-- 
1.7.7.4



More information about the xorg-devel mailing list