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