Index: trunk/src/emx/src/lib/sys/__chdir.c
===================================================================
--- trunk/src/emx/src/lib/sys/__chdir.c	(revision 1325)
+++ trunk/src/emx/src/lib/sys/__chdir.c	(revision 1326)
@@ -1,24 +1,59 @@
-/* sys/chdir.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
+/* sys/chdir.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
+                         -- Copyright (c) 2003-2004 by knut st. osmundsen */
 
 #include "libc-alias.h"
 #define INCL_FSMACROS
 #include <os2emx.h>
+#include <stdlib.h>
+#include <errno.h>
 #include <emx/syscalls.h>
 #include "syscalls.h"
+#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
+#include <InnoTekLIBC/logstrict.h>
+#include <InnoTekLIBC/pathrewrite.h>
 
 
-int __chdir (const char *name)
+int __chdir (const char *pszPath)
 {
-  ULONG rc;
-  FS_VAR();
+    LIBCLOG_ENTER("pszPath=%s\n", pszPath);
+    ULONG   rc;
+    int     cch;
+    FS_VAR();
 
-  FS_SAVE_LOAD();
-  rc = DosSetCurrentDir (name);
-  FS_RESTORE();
-  if (rc != 0)
+    /*
+     * Rewrite the specified file path.
+     */
+    cch = __libc_PathRewrite(pszPath, NULL, 0);
+    if (cch > 0)
     {
-      _sys_set_errno (rc);
-      return -1;
+        char *pszRewritten = alloca(cch);
+        if (!pszRewritten)
+        {
+            errno = ENOMEM;
+            LIBCLOG_RETURN_INT(-1);
+        }
+        cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
+        if (cch > 0)
+            pszPath = pszRewritten;
+        /* else happens when someone changes the rules between the two calls. */
+        else if (cch < 0)
+        {
+            errno = EAGAIN;             /* non-standard, I'm sure. */
+            LIBCLOG_RETURN_INT(-1);
+        }
     }
-  return 0;
+
+    /*
+     * Change the current directory.
+     */
+    FS_SAVE_LOAD();
+    rc = DosSetCurrentDir((PCSZ)pszPath);
+    FS_RESTORE();
+    if (rc != 0)
+    {
+        _sys_set_errno(rc);
+        LIBCLOG_RETURN_INT(-1);
+
+    }
+    LIBCLOG_RETURN_INT(0);
 }
Index: trunk/src/emx/src/lib/sys/__chmod.c
===================================================================
--- trunk/src/emx/src/lib/sys/__chmod.c	(revision 1325)
+++ trunk/src/emx/src/lib/sys/__chmod.c	(revision 1326)
@@ -1,50 +1,99 @@
-/* sys/chmod.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
+/* sys/chmod.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
+                         -- Copyright (c) 2003-2004 by knut st. osmundsen */
 
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
 #include "libc-alias.h"
 #include <string.h>
 #include <errno.h>
+#include <stdlib.h>
 #define INCL_FSMACROS
 #include <os2emx.h>
 #include <emx/syscalls.h>
 #include "syscalls.h"
+#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
+#include <InnoTekLIBC/logstrict.h>
+#include <InnoTekLIBC/pathrewrite.h>
 
-int __chmod (const char *name, int flag, int attr)
+
+int __chmod(const char *pszPath, int flag, int attr)
 {
-  ULONG rc;
-  FILESTATUS3 info;
-  FS_VAR();
+    LIBCLOG_ENTER("pszPath=%s flag=%#x attr=%#x\n", pszPath, flag, attr);
+    ULONG       rc;
+    int         cch;
+    FILESTATUS3 info;
+    FS_VAR();
 
-  if (flag < 0 || flag > 1)
+    /*
+     * Rewrite the specified file path.
+     */
+    cch = __libc_PathRewrite(pszPath, NULL, 0);
+    if (cch > 0)
     {
-      errno = EINVAL;
-      return -1;
+        char *pszRewritten = alloca(cch);
+        if (!pszRewritten)
+        {
+            errno = ENOMEM;
+            LIBCLOG_RETURN_INT(-1);
+        }
+        cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
+        if (cch > 0)
+            pszPath = pszRewritten;
+        /* else happens when someone changes the rules between the two calls. */
+        else if (cch < 0)
+        {
+            errno = EAGAIN;             /* non-standard, I'm sure. */
+            LIBCLOG_RETURN_INT(-1);
+        }
     }
-  if ((name[0] == '/' || name[0] == '\\') && strlen (name) >= 6 &&
-      memicmp (name+1, "pipe", 4) == 0 && (name[5] == '/' || name[5] == '\\'))
+
+    /*
+     * Validate input.
+     */
+    if (flag < 0 || flag > 1)
     {
-      errno = ENOENT;
-      return -1;
+        errno = EINVAL;
+        LIBCLOG_RETURN_INT(-1);
     }
-  FS_SAVE_LOAD();
-  rc = DosQueryPathInfo (name, FIL_STANDARD, &info, sizeof (info));
-  if (rc != 0)
+    if (    (pszPath[0] == '/' || pszPath[0] == '\\')
+        &&  (pszPath[1] == 'p' || pszPath[1] == 'P')
+        &&  (pszPath[2] == 'i' || pszPath[2] == 'I')
+        &&  (pszPath[3] == 'p' || pszPath[3] == 'P')
+        &&  (pszPath[4] == 'e' || pszPath[4] == 'E')
+        &&  (pszPath[5] == '/' || pszPath[5] == '\\'))
     {
-      FS_RESTORE();
-      _sys_set_errno (rc);
-      return -1;
+        errno = ENOENT;
+        LIBCLOG_RETURN_INT(-1);
     }
-  if (flag == 0)
+
+    /*
+     * Query current attributes.
+     */
+    FS_SAVE_LOAD();
+    rc = DosQueryPathInfo((PCSZ)pszPath, FIL_STANDARD, &info, sizeof(info));
+    if (rc != 0)
     {
-      FS_RESTORE();
-      return info.attrFile;
+        FS_RESTORE();
+        _sys_set_errno(rc);
+        LIBCLOG_RETURN_INT(-1);
     }
-  info.attrFile = attr;
-  rc = DosSetPathInfo (name, FIL_STANDARD, &info, sizeof (info), 0);
-  FS_RESTORE();
-  if (rc != 0)
+    if (flag == 0)
     {
-      _sys_set_errno (rc);
-      return -1;
+        FS_RESTORE();
+        LIBCLOG_RETURN_INT((int)info.attrFile);
     }
-  return 0;
+
+    /*
+     * Change attributes.
+     */
+    info.attrFile = attr;
+    rc = DosSetPathInfo((PCSZ)pszPath, FIL_STANDARD, &info, sizeof(info), 0);
+    FS_RESTORE();
+    if (rc != 0)
+    {
+        _sys_set_errno(rc);
+        LIBCLOG_RETURN_INT(-1);
+    }
+    LIBCLOG_RETURN_INT(0);
 }
Index: trunk/src/emx/src/lib/sys/__fstat.c
===================================================================
--- trunk/src/emx/src/lib/sys/__fstat.c	(revision 1325)
+++ trunk/src/emx/src/lib/sys/__fstat.c	(revision 1326)
@@ -1,6 +1,9 @@
 /* sys/fstat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
-   sys/__fstat.c (libc)  -- Copyright (c) 2003 by knut st. osmundsen
+ * sys/__fstat.c (libc)  -- Copyright (c) 2003-2004 by knut st. osmundsen
  */
 
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
 #include "libc-alias.h"
 #define INCL_FSMACROS
@@ -14,7 +17,10 @@
 #include <limits.h>
 #include "syscalls.h"
+#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
+#include <InnoTekLIBC/logstrict.h>
 
 int __fstat(int hFile, struct stat *pStat)
 {
+    LIBCLOG_ENTER("hFile=%d pStat=%p\n", hFile, (void *)pStat);
     ULONG   rc;
     ULONG   ulType;
@@ -30,5 +36,5 @@
     {
         errno = EBADF;
-        return -1;
+        LIBCLOG_RETURN_INT(-1);
     }
 
@@ -44,5 +50,5 @@
             FS_RESTORE();
             _sys_set_errno(rc);
-            return -1;
+            LIBCLOG_RETURN_INT(-1);
         }
         switch (pFH->fFlags & F_TYPEMASK)
@@ -83,5 +89,5 @@
                 FS_RESTORE();
                 _sys_set_errno (rc);
-                return -1;
+                LIBCLOG_RETURN_INT(-1);
             }
 
@@ -133,5 +139,5 @@
                 FS_RESTORE();
                 _sys_set_errno (rc);
-                return -1;
+                LIBCLOG_RETURN_INT(-1);
             }
             if ((flFlags & 7) == OPEN_ACCESS_READONLY)
@@ -159,7 +165,21 @@
          */
         errno = EPERM;
-        return -1;
+        LIBCLOG_RETURN_INT(-1);
     }
 
-    return 0;
+    LIBCLOG_MSG("st_dev:     %#x\n",  pStat->st_dev);
+    LIBCLOG_MSG("st_ino:     %#x\n",  pStat->st_ino);
+    LIBCLOG_MSG("st_mode:    %#x\n",  pStat->st_mode);
+    LIBCLOG_MSG("st_nlink:   %u\n",   pStat->st_nlink);
+    LIBCLOG_MSG("st_uid:     %u\n",   pStat->st_uid);
+    LIBCLOG_MSG("st_gid:     %u\n",   pStat->st_gid);
+    LIBCLOG_MSG("st_rdev:    %#x\n",  pStat->st_rdev);
+    LIBCLOG_MSG("st_atime:   %d\n",   pStat->st_atime);
+    LIBCLOG_MSG("st_mtime:   %d\n",   pStat->st_mtime);
+    LIBCLOG_MSG("st_ctime:   %d\n",   pStat->st_ctime);
+    LIBCLOG_MSG("st_size:    %lld\n", pStat->st_size);
+    LIBCLOG_MSG("st_blocks:  %lld\n", pStat->st_blocks);
+    LIBCLOG_MSG("st_blksize: %u\n",   pStat->st_blksize);
+    LIBCLOG_MSG("st_attr:    %ld\n",  pStat->st_attr);
+    LIBCLOG_RETURN_INT(0);
 }
Index: trunk/src/emx/src/lib/sys/__mkdir.c
===================================================================
--- trunk/src/emx/src/lib/sys/__mkdir.c	(revision 1325)
+++ trunk/src/emx/src/lib/sys/__mkdir.c	(revision 1326)
@@ -1,23 +1,58 @@
-/* sys/mkdir.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
+/* sys/mkdir.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
+                         -- Copyright (c) 2003-2004 by knut st. osmundsen */
 
 #include "libc-alias.h"
 #define INCL_FSMACROS
 #include <os2emx.h>
+#include <stdlib.h>
+#include <errno.h>
 #include <emx/syscalls.h>
 #include "syscalls.h"
+#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
+#include <InnoTekLIBC/logstrict.h>
+#include <InnoTekLIBC/pathrewrite.h>
 
-int __mkdir (const char *name)
+
+int __mkdir(const char *pszPath)
 {
-  ULONG rc;
-  FS_VAR();
+    LIBCLOG_ENTER("pszPath=%s\n", pszPath);
+    ULONG   rc;
+    int     cch;
+    FS_VAR();
 
-  FS_SAVE_LOAD();
-  rc = DosCreateDir (name, NULL);
-  FS_RESTORE();
-  if (rc != 0)
+    /*
+     * Rewrite the specified file path.
+     */
+    cch = __libc_PathRewrite(pszPath, NULL, 0);
+    if (cch > 0)
     {
-      _sys_set_errno (rc);
-      return -1;
+        char *pszRewritten = alloca(cch);
+        if (!pszRewritten)
+        {
+            errno = ENOMEM;
+            LIBCLOG_RETURN_INT(-1);
+        }
+        cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
+        if (cch > 0)
+            pszPath = pszRewritten;
+        /* else happens when someone changes the rules between the two calls. */
+        else if (cch < 0)
+        {
+            errno = EAGAIN;             /* non-standard, I'm sure. */
+            LIBCLOG_RETURN_INT(-1);
+        }
     }
-  return 0;
+
+    /*
+     * Do It.
+     */
+    FS_SAVE_LOAD();
+    rc = DosCreateDir((PCSZ)pszPath, NULL);
+    FS_RESTORE();
+    if (rc != 0)
+    {
+        _sys_set_errno(rc);
+        LIBCLOG_RETURN_INT(-1);
+    }
+    LIBCLOG_RETURN_INT(0);
 }
Index: trunk/src/emx/src/lib/sys/__open.c
===================================================================
--- trunk/src/emx/src/lib/sys/__open.c	(revision 1325)
+++ trunk/src/emx/src/lib/sys/__open.c	(revision 1326)
@@ -1,7 +1,10 @@
 /* sys/open.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
    Copyright (c) 2003 Dimitry Froloff
-   Copyright (c) 2003 knut st. osmundsen
+   Copyright (c) 2003-2004 knut st. osmundsen
  */
 
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
 #include "libc-alias.h"
 #define INCL_DOSERRORS
@@ -18,4 +21,5 @@
 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
 #include <InnoTekLIBC/logstrict.h>
+
 
 int __open(const char *pszFile, int flags, off_t cbInitial, unsigned fLibc, PLIBCFH *ppFH)
Index: trunk/src/emx/src/lib/sys/__rmdir.c
===================================================================
--- trunk/src/emx/src/lib/sys/__rmdir.c	(revision 1325)
+++ trunk/src/emx/src/lib/sys/__rmdir.c	(revision 1326)
@@ -4,20 +4,53 @@
 #define INCL_FSMACROS
 #include <os2emx.h>
+#include <stdlib.h>
+#include <errno.h>
 #include <emx/syscalls.h>
 #include "syscalls.h"
+#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
+#include <InnoTekLIBC/logstrict.h>
+#include <InnoTekLIBC/pathrewrite.h>
 
-int __rmdir (const char *name)
+int __rmdir(const char *pszPath)
 {
-  ULONG rc;
-  FS_VAR();
+    LIBCLOG_ENTER("pszPath=%s\n", pszPath);
+    ULONG   rc;
+    int     cch;
+    FS_VAR();
 
-  FS_SAVE_LOAD();
-  rc = DosDeleteDir (name);
-  FS_RESTORE();
-  if (rc != 0)
+    /*
+     * Rewrite the specified file path.
+     */
+    cch = __libc_PathRewrite(pszPath, NULL, 0);
+    if (cch > 0)
     {
-      _sys_set_errno (rc);
-      return -1;
+        char *pszRewritten = alloca(cch);
+        if (!pszRewritten)
+        {
+            errno = ENOMEM;
+            LIBCLOG_RETURN_INT(-1);
+        }
+        cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
+        if (cch > 0)
+            pszPath = pszRewritten;
+        /* else happens when someone changes the rules between the two calls. */
+        else if (cch < 0)
+        {
+            errno = EAGAIN;             /* non-standard, I'm sure. */
+            LIBCLOG_RETURN_INT(-1);
+        }
     }
-  return 0;
+
+    /*
+     * Do It.
+     */
+    FS_SAVE_LOAD();
+    rc = DosDeleteDir((PCSZ)pszPath);
+    FS_RESTORE();
+    if (rc)
+    {
+        _sys_set_errno(rc);
+        LIBCLOG_RETURN_INT(-1);
+    }
+    LIBCLOG_RETURN_INT(0);
 }
Index: trunk/src/emx/src/lib/sys/__stat.c
===================================================================
--- trunk/src/emx/src/lib/sys/__stat.c	(revision 1325)
+++ trunk/src/emx/src/lib/sys/__stat.c	(revision 1326)
@@ -1,6 +1,9 @@
 /* sys/stat.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
-   sys/__stat.c (libc)  -- Copyright (c) 2003 by knut st. osmundsen
+ * sys/__stat.c (libc)  -- Copyright (c) 2003-2004 by knut st. osmundsen
  */
 
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
 #include "libc-alias.h"
 #define INCL_FSMACROS
@@ -8,4 +11,5 @@
 #include <string.h>
 #include <errno.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -13,8 +17,13 @@
 #include <limits.h>
 #include "syscalls.h"
+#include <InnoTekLIBC/pathrewrite.h>
+#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
+#include <InnoTekLIBC/logstrict.h>
 
 int __stat(const char *pszPath, struct stat *pStat)
 {
+    LIBCLOG_ENTER("pszPath=%s pStat=%p\n", pszPath, (void *)pStat);
     ULONG   rc;
+    int     cch;
     union
     {
@@ -27,14 +36,41 @@
     FS_VAR();
 
+    memset(pStat, 0, sizeof(*pStat));
+
+    /*
+     * Rewrite the specified file path.
+     */
+    cch = __libc_PathRewrite(pszPath, NULL, 0);
+    if (cch > 0)
+    {
+        char *pszRewritten = alloca(cch);
+        if (!pszRewritten)
+        {
+            errno = ENOMEM;
+            LIBCLOG_RETURN_INT(-1);
+        }
+        cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
+        if (cch > 0)
+            pszPath = pszRewritten;
+        /* else happens when someone changes the rules between the two calls. */
+        else if (cch < 0)
+        {
+            errno = EAGAIN;             /* non-standard, I'm sure. */
+            LIBCLOG_RETURN_INT(-1);
+        }
+    }
+
     /*
      * Validate input, refusing named pipes.
      */
-    memset(pStat, 0, sizeof(*pStat));
     if (    (pszPath[0] == '/' || pszPath[0] == '\\')
-        &&  !strnicmp(pszPath+1, "pipe", 4)
+        &&  (pszPath[1] == 'p' || pszPath[1] == 'P')
+        &&  (pszPath[2] == 'i' || pszPath[2] == 'I')
+        &&  (pszPath[3] == 'p' || pszPath[3] == 'P')
+        &&  (pszPath[4] == 'e' || pszPath[4] == 'E')
         &&  (pszPath[5] == '/' || pszPath[5] == '\\'))
     {
         errno = ENOENT;
-        return -1;
+        LIBCLOG_RETURN_INT(-1);
     }
 
@@ -46,15 +82,15 @@
     if (__pfnDosOpenL)
     {
-        rc = DosQueryPathInfo(pszPath, FIL_STANDARDL, &info, sizeof(info.fsts3L));
+        rc = DosQueryPathInfo((PCSZ)pszPath, FIL_STANDARDL, &info, sizeof(info.fsts3L));
         fLarge = 1;
     }
     else
 #endif
-        rc = DosQueryPathInfo(pszPath, FIL_STANDARD, &info, sizeof(info.fsts3));
+        rc = DosQueryPathInfo((PCSZ)pszPath, FIL_STANDARD, &info, sizeof(info.fsts3));
     FS_RESTORE();
     if (rc)
     {
         _sys_set_errno(rc);
-        return -1;
+        LIBCLOG_RETURN_INT(-1);
     }
 
@@ -121,4 +157,19 @@
     pStat->st_nlink = 1;
     pStat->st_blksize = 4096*48;
-    return 0;
+
+    LIBCLOG_MSG("st_dev:     %#x\n",  pStat->st_dev);
+    LIBCLOG_MSG("st_ino:     %#x\n",  pStat->st_ino);
+    LIBCLOG_MSG("st_mode:    %#x\n",  pStat->st_mode);
+    LIBCLOG_MSG("st_nlink:   %u\n",   pStat->st_nlink);
+    LIBCLOG_MSG("st_uid:     %u\n",   pStat->st_uid);
+    LIBCLOG_MSG("st_gid:     %u\n",   pStat->st_gid);
+    LIBCLOG_MSG("st_rdev:    %#x\n",  pStat->st_rdev);
+    LIBCLOG_MSG("st_atime:   %d\n",   pStat->st_atime);
+    LIBCLOG_MSG("st_mtime:   %d\n",   pStat->st_mtime);
+    LIBCLOG_MSG("st_ctime:   %d\n",   pStat->st_ctime);
+    LIBCLOG_MSG("st_size:    %lld\n", pStat->st_size);
+    LIBCLOG_MSG("st_blocks:  %lld\n", pStat->st_blocks);
+    LIBCLOG_MSG("st_blksize: %u\n",   pStat->st_blksize);
+    LIBCLOG_MSG("st_attr:    %ld\n",  pStat->st_attr);
+    LIBCLOG_RETURN_INT(0);
 }
Index: trunk/src/emx/src/lib/sys/__utimes.c
===================================================================
--- trunk/src/emx/src/lib/sys/__utimes.c	(revision 1325)
+++ trunk/src/emx/src/lib/sys/__utimes.c	(revision 1326)
@@ -5,4 +5,5 @@
 #include <os2emx.h>
 #include <string.h>
+#include <stdlib.h>
 #include <errno.h>
 #include <time.h>
@@ -10,56 +11,102 @@
 #include <emx/syscalls.h>
 #include "syscalls.h"
+#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
+#include <InnoTekLIBC/logstrict.h>
+#include <InnoTekLIBC/pathrewrite.h>
 
-static void _sys_t2p (long sec, PFTIME time, PFDATE date)
+
+static void _sys_t2p(long sec, PFTIME time, PFDATE date)
 {
-  struct tm *p;
-  USHORT tmp;
+    struct tm *p;
+    USHORT tmp;
 
-  p = gmtime (&sec);
+    p = gmtime(&sec);
 #if 0                           /* This didn't work in GCC versions <= 2.4 */
-  time->twosecs = p->tm_sec / 2;
-  time->minutes = p->tm_min;
-  time->hours = p->tm_hour;
-  date->day = p->tm_mday;
-  date->month = p->tm_mon + 1;
-  date->year = p->tm_year - 1980 + 1900;
+    time->twosecs   = p->tm_sec / 2;
+    time->minutes   = p->tm_min;
+    time->hours     = p->tm_hour;
+    date->day       = p->tm_mday;
+    date->month     = p->tm_mon + 1;
+    date->year      = p->tm_year - 1980 + 1900;
 #else
-  tmp = (p->tm_sec / 2) + (p->tm_min << 5) + (p->tm_hour << 11);
-  *(USHORT *)time = tmp;
-  tmp = p->tm_mday + ((p->tm_mon + 1) << 5) + ((p->tm_year - 80) << 9);
-  *(USHORT *)date = tmp;
+    tmp = (p->tm_sec / 2) + (p->tm_min << 5) + (p->tm_hour << 11);
+    *(USHORT *)time = tmp;
+    tmp = p->tm_mday + ((p->tm_mon + 1) << 5) + ((p->tm_year - 80) << 9);
+    *(USHORT *)date = tmp;
 #endif
 }
 
 
-int __utimes (const char *name, const struct timeval *tvp)
+int __utimes(const char *pszPath, const struct timeval *tvp)
 {
-  ULONG rc;
-  FILESTATUS3 info;
-  FS_VAR();
+    LIBCLOG_ENTER("pszPath=%s tvp=%p {{%ld,%ld}, {%ld,%ld}}\n", pszPath, (void*)tvp,
+                  tvp ? tvp[0].tv_sec : ~0, tvp ? tvp[0].tv_usec : ~0,
+                  tvp ? tvp[1].tv_sec : ~0, tvp ? tvp[1].tv_usec : ~0);
+    int         cch;
+    ULONG       rc;
+    FILESTATUS3 info;
+    FS_VAR();
 
-  if ((name[0] == '/' || name[0] == '\\') && strlen (name) >= 6 &&
-      memicmp (name+1, "pipe", 4) == 0 && (name[5] == '/' || name[5] == '\\'))
+    /*
+     * Rewrite the specified file path.
+     */
+    cch = __libc_PathRewrite(pszPath, NULL, 0);
+    if (cch > 0)
     {
-      errno = ENOENT;
-      return -1;
+        char *pszRewritten = alloca(cch);
+        if (!pszRewritten)
+        {
+            errno = ENOMEM;
+            LIBCLOG_RETURN_INT(-1);
+        }
+        cch = __libc_PathRewrite(pszPath, pszRewritten, cch);
+        if (cch > 0)
+            pszPath = pszRewritten;
+        /* else happens when someone changes the rules between the two calls. */
+        else if (cch < 0)
+        {
+            errno = EAGAIN;             /* non-standard, I'm sure. */
+            LIBCLOG_RETURN_INT(-1);
+        }
     }
-  FS_SAVE_LOAD();
-  rc = DosQueryPathInfo (name, FIL_STANDARD, &info, sizeof (info));
-  if (rc != 0)
+
+    /*
+     * Validate input.
+     */
+    if (    (pszPath[0] == '/' || pszPath[0] == '\\')
+        &&  (pszPath[1] == 'p' || pszPath[1] == 'P')
+        &&  (pszPath[2] == 'i' || pszPath[2] == 'I')
+        &&  (pszPath[3] == 'p' || pszPath[3] == 'P')
+        &&  (pszPath[4] == 'e' || pszPath[4] == 'E')
+        &&  (pszPath[5] == '/' || pszPath[5] == '\\'))
     {
-      FS_RESTORE();
-      _sys_set_errno (rc);
-      return -1;
+        errno = ENOENT;
+        return -1;
     }
-  _sys_t2p (tvp[0].tv_sec, &info.ftimeLastAccess, &info.fdateLastAccess);
-  _sys_t2p (tvp[1].tv_sec, &info.ftimeLastWrite, &info.fdateLastWrite);
-  rc = DosSetPathInfo (name, FIL_STANDARD, &info, sizeof (info), 0);
-  FS_RESTORE();
-  if (rc != 0)
+
+    /*
+     * Query current path info.
+     */
+    FS_SAVE_LOAD();
+    rc = DosQueryPathInfo((PCSZ)pszPath, FIL_STANDARD, &info, sizeof(info));
+    if (rc)
     {
-      _sys_set_errno (rc);
-      return -1;
+        FS_RESTORE();
+        _sys_set_errno(rc);
+        LIBCLOG_RETURN_INT(-1);
     }
-  return 0;
+
+    /*
+     * Apply the new times and update.
+     */
+    _sys_t2p(tvp[0].tv_sec, &info.ftimeLastAccess, &info.fdateLastAccess);
+    _sys_t2p(tvp[1].tv_sec, &info.ftimeLastWrite,  &info.fdateLastWrite);
+    rc = DosSetPathInfo((PCSZ)pszPath, FIL_STANDARD, &info, sizeof(info), 0);
+    FS_RESTORE();
+    if (rc)
+    {
+        _sys_set_errno(rc);
+        LIBCLOG_RETURN_INT(-1);
+    }
+    LIBCLOG_RETURN_INT(0);
 }
Index: trunk/src/emx/src/lib/sys/filefind.c
===================================================================
--- trunk/src/emx/src/lib/sys/filefind.c	(revision 1325)
+++ trunk/src/emx/src/lib/sys/filefind.c	(revision 1326)
@@ -1,7 +1,11 @@
 /* sys/filefind.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
-   sys/filefind.c (libc)    -- Copyright (c) 2003 by knut st. osmundsen
+   sys/filefind.c (libc)    -- Copyright (c) 2003-2004 by knut st. osmundsen
 */
 
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
 #include "libc-alias.h"
+#include <stdlib.h>
 #include <string.h>
 #include <errno.h>
@@ -13,4 +17,7 @@
 #include "syscalls.h"
 #include <InnoTekLIBC/thread.h>
+#include <InnoTekLIBC/pathrewrite.h>
+#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
+#include <InnoTekLIBC/logstrict.h>
 
 /**
@@ -114,7 +121,32 @@
 int __findfirst(const char *pszName, int attr, struct _find *fp)
 {
-    ULONG               rc;
+    LIBCLOG_ENTER("pszName=%s attr=%#x fp=%p\n", pszName, attr, (void *)fp);
+    int                 rc;
+    int                 cch;
     struct find_data   *pFD = &__libc_threadCurrent()->b.sys.fd;
     FS_VAR();
+
+    /*
+     * Rewrite the specified file path.
+     */
+    cch = __libc_PathRewrite(pszName, NULL, 0);
+    if (cch > 0)
+    {
+        char *pszRewritten = alloca(cch);
+        if (!pszRewritten)
+        {
+            errno = ENOMEM;
+            LIBCLOG_RETURN_INT(-1);
+        }
+        cch = __libc_PathRewrite(pszName, pszRewritten, cch);
+        if (cch > 0)
+            pszName = pszRewritten;
+        /* else happens when someone changes the rules between the two calls. */
+        else if (cch < 0)
+        {
+            errno = EAGAIN;             /* non-standard, I'm sure. */
+            LIBCLOG_RETURN_INT(-1);
+        }
+    }
 
     /*
@@ -160,8 +192,9 @@
         pFD->pchNext = NULL;
         _sys_set_errno(rc);
-        return -1;
+        LIBCLOG_RETURN_INT(-1);
     }
     pFD->pchNext = &pFD->achBuffer[0];
-    return find_conv(pFD, fp);
+    rc = find_conv(pFD, fp);
+    LIBCLOG_RETURN_INT(rc);
 }
 
Index: trunk/src/emx/src/lib/sys/remove.c
===================================================================
--- trunk/src/emx/src/lib/sys/remove.c	(revision 1325)
+++ trunk/src/emx/src/lib/sys/remove.c	(revision 1326)
@@ -1,5 +1,8 @@
 /* sys/remove.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
-                          -- Copyright (c) 2003 by Knut St. Osmundsen */
+                          -- Copyright (c) 2003-2004 by Knut St. Osmundsen */
 
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
 #include "libc-alias.h"
 #define INCL_FSMACROS
@@ -7,13 +10,43 @@
 #include <os2safe.h>
 #include <os2emx.h>
+#include <stdlib.h>
 #include <stdio.h>
+#include <errno.h>
 #include <emx/syscalls.h>
 #include "syscalls.h"
+#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
+#include <InnoTekLIBC/logstrict.h>
+#include <InnoTekLIBC/pathrewrite.h>
 
-int _STD(remove)(const char *name)
+int _STD(remove)(const char *pszFile)
 {
-    static int    fUseForce; /* state: 0 - uninit, 1 - DosForceDelete, -1 - DosDelete */
-    ULONG         rc;
+    LIBCLOG_ENTER("pszFile=%s\n", pszFile);
+    static int  fUseForce; /* state: 0 - uninit, 1 - DosForceDelete, -1 - DosDelete */
+    ULONG       rc;
+    int         cch;
     FS_VAR();
+
+    /*
+     * Rewrite the specified file path.
+     */
+    cch = __libc_PathRewrite(pszFile, NULL, 0);
+    if (cch > 0)
+    {
+        char *pszRewritten = alloca(cch);
+        if (!pszRewritten)
+        {
+            errno = ENOMEM;
+            LIBCLOG_RETURN_INT(-1);
+        }
+        cch = __libc_PathRewrite(pszFile, pszRewritten, cch);
+        if (cch > 0)
+            pszFile = pszRewritten;
+        /* else happens when someone changes the rules between the two calls. */
+        else if (cch < 0)
+        {
+            errno = EAGAIN;             /* non-standard, I'm sure. */
+            LIBCLOG_RETURN_INT(-1);
+        }
+    }
 
     FS_SAVE_LOAD();
@@ -30,5 +63,5 @@
     {
         PSZ psz = NULL;
-        if (DosScanEnv("DELDIR", &psz) || !psz)
+        if (DosScanEnv((PCSZ)"DELDIR", &psz) || !psz)
             fUseForce = 1;
         else
@@ -40,13 +73,13 @@
      */
     if (fUseForce == 1)
-        rc = DosForceDelete(name);
+        rc = DosForceDelete((PCSZ)pszFile);
     else
-        rc = DosDelete(name);
+        rc = DosDelete((PCSZ)pszFile);
     FS_RESTORE();
     if (rc)
     {
         _sys_set_errno(rc);
-        return -1;
+        LIBCLOG_RETURN_INT(-1);
     }
-    return 0;
+    LIBCLOG_RETURN_INT(0);
 }
Index: trunk/src/emx/src/lib/sys/rename.c
===================================================================
--- trunk/src/emx/src/lib/sys/rename.c	(revision 1325)
+++ trunk/src/emx/src/lib/sys/rename.c	(revision 1326)
@@ -1,24 +1,81 @@
-/* sys/rename.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
+/* sys/rename.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes
+                          -- Copyright (c) 2003-2004 by knut st. osmundsen */
 
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
 #include "libc-alias.h"
 #define INCL_FSMACROS
 #include <os2emx.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
 #include <emx/syscalls.h>
 #include "syscalls.h"
+#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
+#include <InnoTekLIBC/logstrict.h>
+#include <InnoTekLIBC/pathrewrite.h>
 
-int _STD(rename) (const char *old_name, const char *new_name)
+int _STD(rename)(const char *pszOldName, const char *pszNewName)
 {
-  ULONG rc;
-  FS_VAR();
+    LIBCLOG_ENTER("pszOldName=%s pszNewName=%s\n", pszOldName, pszNewName);
+    ULONG   rc;
+    int     cch;
+    FS_VAR();
 
-  FS_SAVE_LOAD();
-  rc = DosMove (old_name, new_name);
-  FS_RESTORE();
-  if (rc != 0)
+    /*
+     * Rewrite the specified paths.
+     */
+    cch = __libc_PathRewrite(pszOldName, NULL, 0);
+    if (cch > 0)
     {
-      _sys_set_errno (rc);
-      return -1;
+        char *pszRewritten = alloca(cch);
+        if (!pszRewritten)
+        {
+            errno = ENOMEM;
+            LIBCLOG_RETURN_INT(-1);
+        }
+        cch = __libc_PathRewrite(pszOldName, pszRewritten, cch);
+        if (cch > 0)
+            pszOldName = pszRewritten;
+        /* else happens when someone changes the rules between the two calls. */
+        else if (cch < 0)
+        {
+            errno = EAGAIN;             /* non-standard, I'm sure. */
+            LIBCLOG_RETURN_INT(-1);
+        }
     }
-  return 0;
+
+    cch = __libc_PathRewrite(pszNewName, NULL, 0);
+    if (cch > 0)
+    {
+        char *pszRewritten = alloca(cch);
+        if (!pszRewritten)
+        {
+            errno = ENOMEM;
+            LIBCLOG_RETURN_INT(-1);
+        }
+        cch = __libc_PathRewrite(pszNewName, pszRewritten, cch);
+        if (cch > 0)
+            pszNewName = pszRewritten;
+        /* else happens when someone changes the rules between the two calls. */
+        else if (cch < 0)
+        {
+            errno = EAGAIN;             /* non-standard, I'm sure. */
+            LIBCLOG_RETURN_INT(-1);
+        }
+    }
+
+    /*
+     * Rename it.
+     */
+    FS_SAVE_LOAD();
+    rc = DosMove((PCSZ)pszOldName, (PCSZ)pszNewName);
+    FS_RESTORE();
+    if (rc)
+    {
+        _sys_set_errno(rc);
+        LIBCLOG_RETURN_INT(-1);
+    }
+    LIBCLOG_RETURN_INT(0);
 }
