Changeset 1324


Ignore:
Timestamp:
Mar 21, 2004, 7:37:19 AM (21 years ago)
Author:
bird
Message:

#991: Initial implementation of the Path Rewrite Feature.

Location:
trunk/src/emx
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/libc.def

    • Property cvs2svn:cvs-rev changed from 1.52 to 1.53
    r1323 r1324  
    10931093    "_catgets" @1116
    10941094    "_catopen" @1117
     1095    "___libc_PathRewrite" @1118
     1096    "___libc_PathRewriteAdd" @1119
     1097    "___libc_PathRewriteRemove" @1120
  • trunk/src/emx/src/lib/sys/__open.c

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r1323 r1324  
    1515#include <alloca.h>
    1616#include "syscalls.h"
     17#include <InnoTekLIBC/pathrewrite.h>
     18#define __LIBC_LOG_GROUP __LIBC_LOG_GRP_BACK_IO
     19#include <InnoTekLIBC/logstrict.h>
    1720
    1821int __open(const char *pszFile, int flags, off_t cbInitial, unsigned fLibc, PLIBCFH *ppFH)
    1922{
     23    LIBCLOG_ENTER("pszFile=%s flags=%#x cbInitial=%lld fLibc=%#x ppFH=%p\n",
     24                  pszFile, flags, cbInitial, fLibc, (void*)ppFH);
    2025    ULONG   rc;
    2126    ULONG   flOpenMode;
     
    2429    ULONG   ulAction;
    2530    HFILE   hFile;
     31    int     cch;
    2632    int     failed_open_errno;
    2733    FS_VAR();
    2834
     35
    2936    /*
    30      * Interpret "/dev/null" as the pszFile of the null device "NUL".
    31      * Interpret "/dev/tty" as the pszFile of the console device "CON".
     37     * Rewrite the specified file path.
    3238     */
    33     if (!strcmp(pszFile, "/dev/null"))
    34         pszFile = "nul";
    35     else if (!strcmp(pszFile, "/dev/tty"))
    36         pszFile = "con";
     39    cch = __libc_PathRewrite(pszFile, NULL, 0);
     40    if (cch > 0)
     41    {
     42        char *pszRewritten = alloca(cch);
     43        if (!pszRewritten)
     44        {
     45            errno = ENOMEM;
     46            LIBCLOG_RETURN_INT(-1);
     47        }
     48        cch = __libc_PathRewrite(pszFile, pszRewritten, cch);
     49        if (cch > 0)
     50            pszFile = pszRewritten;
     51        /* else happens when someone changes the rules between the two calls. */
     52        else if (cch < 0)
     53        {
     54            errno = EAGAIN;             /* non-standard, I'm sure. */
     55            LIBCLOG_RETURN_INT(-1);
     56        }
     57    }
    3758
    3859    /*
     
    98119        {
    99120            strcpy(pszFile_safe, pszFile);
    100             rc = __pfnDosOpenL(pszFile_safe, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
     121            rc = __pfnDosOpenL((PCSZ)pszFile_safe, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
    101122        }
    102123        else
     
    110131            FS_RESTORE();
    111132            errno = EOVERFLOW;
    112             return -1;
     133            LIBCLOG_RETURN_INT(-1);
    113134        }
    114         rc = DosOpen(pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
     135        rc = DosOpen((PCSZ)pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
    115136    }
    116137#else
    117138    {
    118139        ULONG cbInitialTmp = cbInitial;
    119         rc = DosOpen(pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
     140        rc = DosOpen((PCSZ)pszFile, &hFile, &ulAction, cbInitialTmp, flAttr, flOpenFlags, flOpenMode, NULL);
    120141    }
    121142#endif
     
    150171             */
    151172            rc = __libc_FHAllocate(hFile, fLibc, sizeof(LIBCFH), NULL, ppFH, NULL);
     173            LIBCLOG_MSG("hFile=%#lx fLibc=%#x fulType=%#lx ulAction=%lu\n",
     174                        hFile, fLibc, fulType, ulAction);
    152175        }
    153176
     
    166189        else
    167190            _sys_set_errno(rc);
    168         return -1;
     191        LIBCLOG_RETURN_INT(-1);
    169192    }
    170193    return hFile;
Note: See TracChangeset for help on using the changeset viewer.