--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/open-src/xserver/xorg/6872917.patch Tue Aug 18 16:24:38 2009 -0700
@@ -0,0 +1,146 @@
+# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, and/or sell copies of the Software, and to permit persons
+# to whom the Software is furnished to do so, provided that the above
+# copyright notice(s) and this permission notice appear in all copies of
+# the Software and that both the above copyright notice(s) and this
+# permission notice appear in supporting documentation.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder
+# shall not be used in advertising or otherwise to promote the sale, use
+# or other dealings in this Software without prior written authorization
+# of the copyright holder.
+
+6872917 Xorg not loading nvidia driver when no /etc/X11/xorg.conf exists
+
+vt.patch broke the autoconfiguration code in xf86AutoConfig.c that uses the
+Solaris-specific VIS_GETIDENTIFIER ioctl on a frame buffer device like /dev/fb
+by changing xf86Info.consoleFd from /dev/fb to a /dev/vt/* device.
+
+This fixes it by reworking the code to split the console device (/dev/vt/*,
+the vtXX CLI option) from the frame buffer device (/dev/fb, -dev option) to
+allow both VT and autoconfig to work.
+
+It also fixes the console device to use /dev/fb when VT's are not supported
+instead of throwing a Fatal Error because it can't open /dev/vt/0.
+
+--- hw/xfree86/common/xf86AutoConfig.c~ 2009-08-15 19:21:29.790065000 -0700
++++ hw/xfree86/common/xf86AutoConfig.c 2009-08-18 15:07:14.284126000 -0700
+@@ -475,8 +475,25 @@ listPossibleVideoDrivers(char *matches[]
+ if (xf86Info.consoleFd >= 0) {
+ struct vis_identifier visid;
+ const char *cp;
++ extern char xf86SolarisFbDev[PATH_MAX];
++ int iret;
+
+- if (ioctl(xf86Info.consoleFd, VIS_GETIDENTIFIER, &visid) >= 0) {
++ SYSCALL(iret = ioctl(xf86Info.consoleFd, VIS_GETIDENTIFIER, &visid));
++ if (iret < 0) {
++ int fbfd;
++
++ fbfd = open(xf86SolarisFbDev, O_RDONLY);
++ if (fbfd >= 0) {
++ SYSCALL(iret = ioctl(fbfd, VIS_GETIDENTIFIER, &visid));
++ close(fbfd);
++ }
++ }
++
++ if (iret < 0) {
++ xf86Msg(X_WARNING,
++ "could not get frame buffer identifier from %s\n",
++ xf86SolarisFbDev);
++ } else {
+ xf86Msg(X_PROBED, "console driver: %s\n", visid.name);
+
+ /* Special case from before the general case was set */
+--- hw/xfree86/os-support/solaris/sun_init.c~ 2009-08-15 19:21:29.935340000 -0700
++++ hw/xfree86/os-support/solaris/sun_init.c 2009-08-18 14:56:15.708529000 -0700
+@@ -42,11 +42,15 @@ static Bool Protect0 = FALSE;
+ static int VTnum = -1;
+ static int xf86StartVT = -1;
+ static int vtEnabled = 0;
+-static char fb_dev[PATH_MAX] = "/dev/vt/0";
+-#else
+-static char fb_dev[PATH_MAX] = "/dev/fb";
+ #endif
+
++/* Device to open as xf86Info.consoleFd */
++static char console_dev[PATH_MAX] = "/dev/fb";
++
++/* Set by -dev argument on CLI
++ Used by hw/xfree86/common/xf86AutoConfig.c for VIS_GETIDENTIFIER */
++_X_HIDDEN char xf86SolarisFbDev[PATH_MAX] = "/dev/fb";
++
+ void
+ xf86OpenConsole(void)
+ {
+@@ -118,6 +122,7 @@ xf86OpenConsole(void)
+
+ xf86StartVT = 0;
+ xf86Info.vtno = 0;
++ strlcpy(console_dev, xf86SolarisFbDev, sizeof(console_dev));
+ }
+ else
+ {
+@@ -141,7 +146,7 @@ xf86OpenConsole(void)
+ }
+
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+- snprintf(fb_dev, PATH_MAX, "/dev/vt/%d", xf86Info.vtno);
++ snprintf(console_dev, PATH_MAX, "/dev/vt/%d", xf86Info.vtno);
+ }
+
+ if (fd != -1)
+@@ -154,14 +159,14 @@ xf86OpenConsole(void)
+ if (!KeepTty)
+ setpgrp();
+
+- if (((xf86Info.consoleFd = open(fb_dev, O_RDWR | O_NDELAY, 0)) < 0))
++ if (((xf86Info.consoleFd = open(console_dev, O_RDWR | O_NDELAY, 0)) < 0))
+ FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
+- fb_dev, strerror(errno));
++ console_dev, strerror(errno));
+
+ #ifdef HAS_USL_VTS
+
+ /* Change ownership of the vt */
+- chown(fb_dev, getuid(), getgid());
++ chown(console_dev, getuid(), getgid());
+
+ if (vtEnabled)
+ {
+@@ -198,7 +203,7 @@ xf86OpenConsole(void)
+ if (i < 0) {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: KDSETMODE KD_GRAPHICS failed on %s (%s)\n",
+- fb_dev, strerror(errno));
++ console_dev, strerror(errno));
+ }
+ #endif
+ }
+@@ -347,8 +352,8 @@ xf86ProcessArgument(int argc, char **arg
+
+ if ((i + 1) < argc) {
+ if (!strcmp(argv[i], "-dev")) {
+- strncpy(fb_dev, argv[i+1], PATH_MAX);
+- fb_dev[PATH_MAX - 1] = '\0';
++ strncpy(xf86SolarisFbDev, argv[i+1], PATH_MAX);
++ xf86SolarisFbDev[PATH_MAX - 1] = '\0';
+ return 2;
+ }
+ }