1265N/A# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
98N/A#
98N/A# Permission is hereby granted, free of charge, to any person obtaining a
919N/A# copy of this software and associated documentation files (the "Software"),
919N/A# to deal in the Software without restriction, including without limitation
919N/A# the rights to use, copy, modify, merge, publish, distribute, sublicense,
919N/A# and/or sell copies of the Software, and to permit persons to whom the
919N/A# Software is furnished to do so, subject to the following conditions:
919N/A#
919N/A# The above copyright notice and this permission notice (including the next
919N/A# paragraph) shall be included in all copies or substantial portions of the
919N/A# Software.
919N/A#
919N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
919N/A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
919N/A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
919N/A# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
919N/A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
919N/A# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
919N/A# DEALINGS IN THE SOFTWARE.
1097N/A
1333N/A--- a/hw/xfree86/loader/loadmod.c Wed Sep 12 10:49:02 2012
1333N/A+++ b/hw/xfree86/loader/loadmod.c Wed Sep 12 10:52:48 2012
1333N/A@@ -166,6 +166,12 @@
1276N/A list[n][len - 1] = '/';
1276N/A list[n][len] = '\0';
1276N/A }
852N/A+
157N/A+#ifdef SUNSOFT /* strip amd64/ off loader path if it's there */
1276N/A+ if (strcmp(list[n] + (len - 6), "amd64/") == 0) {
1276N/A+ list[n][len - 6] = '\0';
1276N/A+ }
98N/A+#endif
1276N/A n++;
1276N/A }
1276N/A elem = strtok(NULL, ",");
1333N/A@@ -397,6 +403,24 @@
852N/A char *ret = NULL, tmpBuf[PATH_MAX];
852N/A struct stat stat_buf;
852N/A
852N/A+#if defined(SUNSOFT) && defined(__x86)
852N/A+ Bool in_64_dir = FALSE;
852N/A+
852N/A+ if (strstr(dirpath, "/amd64") != NULL) {
852N/A+# if !(defined(__amd64) || defined(__amd64__))
852N/A+ return NULL;
852N/A+# else
852N/A+ in_64_dir = TRUE;
852N/A+# endif
852N/A+ }
1097N/A+ /* After the 32-bit EOF, all modules under /usr/lib/xorg are 64-bit,
1097N/A+ but legacy modules under /usr/X11/lib are still split into 32-bit
1097N/A+ and 64-bit versions */
1097N/A+ if (strncmp(dirpath, "/usr/X11/lib/modules/", 21) != 0) {
1276N/A+ in_64_dir = TRUE;
1097N/A+ }
852N/A+#endif
852N/A+
852N/A dir = opendir(dirpath);
852N/A if (!dir)
852N/A return NULL;
1333N/A@@ -404,6 +428,12 @@
852N/A while ((direntry = readdir(dir))) {
852N/A if (direntry->d_name[0] == '.')
852N/A continue;
852N/A+
852N/A+#if defined(SUNSOFT) && (defined(__i386) || defined(__i386__))
852N/A+ /* skip 64-bit subdirectories when running 32-bit server */
852N/A+ if (strcmp(direntry->d_name, "amd64") == 0)
852N/A+ continue;
852N/A+#endif
852N/A snprintf(tmpBuf, PATH_MAX, "%s%s/", dirpath, direntry->d_name);
1276N/A /* the stat with the appended / fails for normal files,
1276N/A and works for sub dirs fine, looks a bit strange in strace
1333N/A@@ -414,6 +444,12 @@
852N/A continue;
852N/A }
1276N/A
98N/A+#if defined(SUNSOFT) && (defined(__amd64) || defined(__amd64__))
852N/A+ /* Don't match files in non-amd64 directories */
852N/A+ if (!in_64_dir)
852N/A+ continue;
1276N/A+#endif
1276N/A+
1333N/A #ifdef __CYGWIN__
1333N/A snprintf(tmpBuf, PATH_MAX, "cyg%s.dll", module);
1333N/A #else