open-src/xserver/xorg/6942816.patch
changeset 1088 1c99106ccbe0
parent 1087 a8aa060182e1
child 1089 590b35f0ad83
equal deleted inserted replaced
1087:a8aa060182e1 1088:1c99106ccbe0
     1 diff -urp -x '*~' -x '*.orig' hw/xfree86/os-support/solaris/sun_init.c hw/xfree86/os-support/solaris/sun_init.c
       
     2 --- hw/xfree86/os-support/solaris/sun_init.c	2010-04-15 14:27:02.090461037 +0800
       
     3 +++ hw/xfree86/os-support/solaris/sun_init.c	2010-04-15 14:27:04.834098942 +0800
       
     4 @@ -33,11 +33,24 @@
       
     5  # include <sys/kd.h>
       
     6  #endif
       
     7  
       
     8 +/*
       
     9 + * Applications see VT number as consecutive integers starting from 1.
       
    10 + * VT number			VT device
       
    11 + * -------------------------------------------------------
       
    12 + *     1             :          /dev/vt/0 (Alt + Ctrl + F1)
       
    13 + *     2             :          /dev/vt/2 (Alt + Ctrl + F2)
       
    14 + *     3             :          /dev/vt/3 (Alt + Ctrl + F3)
       
    15 + *  ... ...
       
    16 + */
       
    17 +#define	CONSOLE_VTNO	1
       
    18 +#define	SOL_CONSOLE_DEV	"/dev/console"
       
    19 +
       
    20  /* For use of VT_SETDISPLOGIN in dtlogin.c */
       
    21  extern int xf86ConsoleFd;
       
    22  
       
    23  static Bool KeepTty = FALSE;
       
    24  static Bool Protect0 = FALSE;
       
    25 +static Bool UseConsole = FALSE;
       
    26  #ifdef HAS_USL_VTS
       
    27  static int VTnum = -1;
       
    28  static int xf86StartVT = -1;
       
    29 @@ -96,7 +109,6 @@ xf86OpenConsole(void)
       
    30  	}
       
    31  
       
    32  #ifdef HAS_USL_VTS
       
    33 -
       
    34  	/*
       
    35  	 * Setup the virtual terminal manager
       
    36  	 */
       
    37 @@ -115,8 +127,30 @@ xf86OpenConsole(void)
       
    38  		vtEnabled = 0;
       
    39  	    }
       
    40  	}
       
    41 +#endif /*  HAS_USL_VTS */
       
    42  
       
    43 +	if (UseConsole)
       
    44 +	{
       
    45 +	    strlcpy(consoleDev, SOL_CONSOLE_DEV, sizeof(consoleDev));
       
    46 +
       
    47 +#ifdef HAS_USL_VTS
       
    48 +	    xf86Info.vtno = CONSOLE_VTNO;
       
    49  
       
    50 +	    if (vtEnabled == 0)
       
    51 +	    {
       
    52 +		xf86StartVT = 0;
       
    53 +	    }
       
    54 +	    else
       
    55 +	    {
       
    56 +		if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
       
    57 +		    FatalError("xf86OpenConsole: Cannot determine current VT\n");
       
    58 +		xf86StartVT = vtinfo.v_active;
       
    59 +	    }
       
    60 +#endif /*  HAS_USL_VTS */
       
    61 +	    goto OPENCONSOLE;
       
    62 +	}
       
    63 +		
       
    64 +#ifdef HAS_USL_VTS
       
    65  	if (vtEnabled == 0)
       
    66  	{
       
    67  	    /* VT not enabled - kernel too old or Sparc platforms
       
    68 @@ -126,32 +160,31 @@ xf86OpenConsole(void)
       
    69  	    xf86StartVT = 0;
       
    70  	    xf86Info.vtno = 0;
       
    71  	    strlcpy(consoleDev, xf86SolarisFbDev, sizeof(consoleDev));
       
    72 +	    goto OPENCONSOLE;
       
    73  	}
       
    74 -	else
       
    75 -	{
       
    76 -	    if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
       
    77 -		FatalError("xf86OpenConsole: Cannot determine current VT\n");
       
    78  
       
    79 -	    xf86StartVT = vtinfo.v_active;
       
    80 +	if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
       
    81 +	    FatalError("xf86OpenConsole: Cannot determine current VT\n");
       
    82  
       
    83 -	    if (VTnum != -1)
       
    84 -	    {
       
    85 -		xf86Info.vtno = VTnum;
       
    86 -		from = X_CMDLINE;
       
    87 -	    }
       
    88 -	    else
       
    89 +	xf86StartVT = vtinfo.v_active;
       
    90 +
       
    91 +	if (VTnum != -1)
       
    92 +	{
       
    93 +	    xf86Info.vtno = VTnum;
       
    94 +	    from = X_CMDLINE;
       
    95 +	}
       
    96 +	else
       
    97 +	{
       
    98 +	    if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
       
    99 +		(xf86Info.vtno == -1))
       
   100  	    {
       
   101 -		if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
       
   102 -		    (xf86Info.vtno == -1))
       
   103 -		{
       
   104 -		    FatalError("xf86OpenConsole: Cannot find a free VT\n");
       
   105 -		}
       
   106 +		FatalError("xf86OpenConsole: Cannot find a free VT\n");
       
   107  	    }
       
   108 -
       
   109 -	    xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
       
   110 -	    snprintf(consoleDev, PATH_MAX, "/dev/vt/%d", xf86Info.vtno);
       
   111  	}
       
   112  
       
   113 +	xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
       
   114 +	snprintf(consoleDev, PATH_MAX, "/dev/vt/%d", xf86Info.vtno);
       
   115 +
       
   116  	if (fd != -1)
       
   117  	{
       
   118  	    close(fd);
       
   119 @@ -159,6 +192,7 @@ xf86OpenConsole(void)
       
   120  
       
   121  #endif /* HAS_USL_VTS */
       
   122  
       
   123 +OPENCONSOLE:
       
   124  	if (!KeepTty)
       
   125  	    setpgrp();
       
   126  
       
   127 @@ -166,11 +200,10 @@ xf86OpenConsole(void)
       
   128  	    FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
       
   129  		       consoleDev, strerror(errno));
       
   130  
       
   131 -#ifdef HAS_USL_VTS
       
   132 -
       
   133 -	/* Change ownership of the vt */
       
   134 +	/* Change ownership of the vt or console */
       
   135  	chown(consoleDev, getuid(), getgid());
       
   136  
       
   137 +#ifdef HAS_USL_VTS
       
   138  	if (vtEnabled)
       
   139  	{
       
   140  	    /*
       
   141 @@ -182,6 +215,11 @@ xf86OpenConsole(void)
       
   142  	    if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
       
   143  		xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
       
   144  
       
   145 +	    if (strcmp(display, "0") == 0)
       
   146 +		if (ioctl(xf86Info.consoleFd, VT_SET_CONSUSER) != 0)
       
   147 +		    xf86Msg(X_WARNING,
       
   148 +			"xf86OpenConsole: VT_SET_CONSUSER failed\n");
       
   149 +
       
   150  	    if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
       
   151  		FatalError("xf86OpenConsole: VT_GETMODE failed\n");
       
   152  
       
   153 @@ -225,6 +263,11 @@ xf86OpenConsole(void)
       
   154  	    if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
       
   155  		xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
       
   156  
       
   157 +	    if (strcmp(display, "0") == 0)
       
   158 +		if (ioctl(xf86Info.consoleFd, VT_SET_CONSUSER) != 0)
       
   159 +		    xf86Msg(X_WARNING,
       
   160 +			"xf86OpenConsole: VT_SET_CONSUSER failed\n");
       
   161 +
       
   162  	    /*
       
   163  	     * If the server doesn't have the VT when the reset occurs,
       
   164  	     * this is to make sure we don't continue until the activate
       
   165 @@ -335,6 +378,15 @@ xf86ProcessArgument(int argc, char **arg
       
   166  	return 1;
       
   167      }
       
   168  
       
   169 +    /*
       
   170 +     * Use /dev/console as the console device.
       
   171 +     */  
       
   172 +    if (!strcmp(argv[i], "-C"))
       
   173 +    {
       
   174 +	UseConsole = TRUE;
       
   175 +	return 1;
       
   176 +    }
       
   177 +
       
   178  #ifdef HAS_USL_VTS
       
   179  
       
   180      if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
       
   181 @@ -369,4 +421,5 @@ void xf86UseMsg()
       
   182      ErrorF("-dev <fb>              Framebuffer device\n");
       
   183      ErrorF("-keeptty               Don't detach controlling tty\n");
       
   184      ErrorF("                       (for debugging only)\n");
       
   185 +    ErrorF("-C                     Use /dev/console as the console device\n");
       
   186  }