amd64-loader-path.patch revision 919
1276N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
98N/A# Use is subject to license terms.
98N/A#
919N/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
1276N/A# DEALINGS IN THE SOFTWARE.
1124N/Adiff -urp -x '*~' -x '*.orig' hw/xfree86/loader/loadmod.c hw/xfree86/loader/loadmod.c
1124N/A--- hw/xfree86/loader/loadmod.c 2009-11-29 21:42:31.000000000 -0800
1634N/A+++ hw/xfree86/loader/loadmod.c 2009-12-06 12:38:47.776703128 -0800
98N/A@@ -167,6 +167,13 @@ InitPathList(const char *path)
98N/A list[n][len - 1] = '/';
1366N/A list[n][len] = '\0';
98N/A }
98N/A+
1366N/A+#ifdef SUNSOFT /* strip amd64/ off loader path if it's there */
98N/A+ if (strcmp(list[n] + (len - 6), "amd64/") == 0) {
1634N/A+ list[n][len - 6] = '\0';
1124N/A+ }
1634N/A+#endif
1634N/A+
1276N/A n++;
98N/A }
1366N/A elem = strtok(NULL, ",");
98N/A@@ -392,6 +399,18 @@ FindModuleInSubdir(const char *dirpath,
1276N/A char *ret = NULL, tmpBuf[PATH_MAX];
1088N/A struct stat stat_buf;
1276N/A
1634N/A+#if defined(SUNSOFT) && defined(__x86)
1276N/A+ Bool in_64_dir = FALSE;
1276N/A+
1366N/A+ if (strstr(dirpath, "/amd64") != NULL) {
98N/A+# if !(defined(__amd64) || defined(__amd64__))
1634N/A+ return NULL;
1634N/A+# else
1634N/A+ in_64_dir = TRUE;
+# endif
+ }
+#endif
+
dir = opendir(dirpath);
if (!dir)
return NULL;
@@ -399,6 +418,13 @@ FindModuleInSubdir(const char *dirpath,
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
@@ -408,6 +434,12 @@ FindModuleInSubdir(const char *dirpath,
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) {