changeset 17827:1e216edfab95

relocatable: support UNIXROOT in relocate() on EMX UNIXROOT is used to specify a drive of a root of FHS. So if a path is started with '/', then it should be translated to "$UNIXROOT/". * lib/relocatable.c (relocate): Prepend $UNIXROOT to pathname if it is started with '/' on EMX.
author KO Myung-Hun <komh78@gmail.com>
date Tue, 09 Dec 2014 10:40:48 +0900
parents 68470530f583
children 8680c9676a59
files ChangeLog lib/relocatable.c
diffstat 2 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-08  KO Myung-Hun  <komh78@gmail.com>
+
+	* lib/relocatable.c (relocate): Prepend $UNIXROOT to pathname if it is
+	started with '/' on EMX.
+
 2014-12-08  KO Myung-Hun  <komh78@gmail.com>
 
 	freopen: workaround freopen() on OS/2 kLIBC
--- a/lib/relocatable.c
+++ b/lib/relocatable.c
@@ -537,6 +537,27 @@
             }
         }
     }
+
+#ifdef __EMX__
+  if (pathname && ISSLASH (pathname[0]))
+    {
+      const char *unixroot = getenv ("UNIXROOT");
+
+      if (unixroot && HAS_DEVICE (unixroot) && !unixroot[2])
+        {
+          char *result = (char *) xmalloc (2 + strlen (pathname) + 1);
+#ifdef NO_XMALLOC
+          if (result != NULL)
+#endif
+            {
+              strcpy (result, unixroot);
+              strcpy (result + 2, pathname);
+              return result;
+            }
+        }
+    }
+#endif
+
   /* Nothing to relocate.  */
   return pathname;
 }