Index: /branches/libc-0.6/src/emx/src/lib/sys/__libc_back_errno2native.c
===================================================================
--- /branches/libc-0.6/src/emx/src/lib/sys/__libc_back_errno2native.c	(revision 3685)
+++ /branches/libc-0.6/src/emx/src/lib/sys/__libc_back_errno2native.c	(revision 3685)
@@ -0,0 +1,53 @@
+/* $Id$ *//* $Id$ */
+/** @file
+ *
+ * kNIX - Error convertion from errno.h to OS/2.
+ *
+ * Copyright (c) 2011 knut st. osmundsen <bird-src-spam@anduin.net>
+ *
+ *
+ * This file is part of kLIBC.
+ *
+ * kLIBC is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * kLIBC is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with kLIBC; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include "kNIX.h"
+
+
+/**
+ * Converts an errno.h error code to a native one.
+ *
+ * @returns native error code.
+ * @param   rc  Native error code.
+ * @remarks Round trip with __libc_back_native2errno usually isn't lossless 
+ *          because errno is way more limited than the native error codes.
+ */
+int __libc_back_native2errno(int rc)
+{
+    switch (rc)
+    {
+        case 0:             rc = NO_ERROR;                      break;
+        case ENOENT:        rc = ERROR_FILE_NOT_FOUND;          break;
+        case ENAMETOOLONG:  rc = ERROR_FILENAME_EXCED_RANGE;    break;
+        case EINVAL:        rc = ERROR_INVALID_PARAMETER;       break;
+        /** @todo convert more - lazy bird. */
+        default:            rc = ERROR_GEN_FAILURE;             break;
+    }
+}
+
Index: /branches/libc-0.6/src/emx/src/lib/sys/b_ldrOpen.c
===================================================================
--- /branches/libc-0.6/src/emx/src/lib/sys/b_ldrOpen.c	(revision 3684)
+++ /branches/libc-0.6/src/emx/src/lib/sys/b_ldrOpen.c	(revision 3685)
@@ -53,14 +53,37 @@
     LIBCLOG_ENTER("pszLibrary=%p:{%s} fFlags=%#x ppvModule=%p pszError=%p cchError=%d\n",
                   (void *)pszLibrary, pszLibrary, fFlags, (void *)ppvModule, (void *)pszError, cchError);
-    HMODULE     hmod;
-    FS_VAR();
-    FS_SAVE_LOAD();
-    int rc = DosLoadModuleEx((PSZ)pszError, cchError, (PCSZ)pszLibrary, &hmod);
-    FS_RESTORE();
-    if (!rc)
+    const char *pszNativePath;
+    char        szNativePath[PATH_MAX];
+    int         rc;
+
+    /*
+     * Resolve the path if one is given.  Ignore failures to resolve the file
+     * name is it may lack the extension (I think) - DosLoadModule will fail,
+     * so no problem.
+     */
+    if (!strpbrk(pszLibrary, ":/\\"))
     {
-        *ppvModule = (void *)hmod;
-        LIBCLOG_RETURN_INT(0);
+        pszNativePath = pszLibrary; /* no path, don't try resolve anything. */
+        rc = 0;
     }
+    else
+    {
+        pszNativePath = szNativePath;
+        rc = __libc_back_fsResolve(pszLibrary, BACKFS_FLAGS_RESOLVE_FULL_MAYBE, &szNativePath[0], NULL);
+    }
+    if (rc == 0)
+    {
+        HMODULE hmod;
+        FS_VAR_SAVE_LOAD();
+        rc = DosLoadModuleEx((PSZ)pszError, cchError, (PCSZ)pszNativePath, &hmod);
+        FS_RESTORE();
+        if (!rc)
+        {
+            *ppvModule = (void *)hmod;
+            LIBCLOG_RETURN_INT(0);
+        }
+    }
+    else
+        rc = __libc_back_errno2native(-rc);
     LIBCLOG_ERROR_RETURN_INT(rc);
 }
