Changeset 2496 for branches/libc-0.6


Ignore:
Timestamp:
Dec 18, 2005, 9:56:19 AM (20 years ago)
Author:
bird
Message:

#22: Added DosFindFirst() as fallback when DosQueryPathInfo() fails to query the symlink EA in the path resolver. This problem occurs when doing stat() on an open file (pwd_mkdb example).

Location:
branches/libc-0.6/src/emx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/ChangeLog.LIBC

    r2495 r2496  
    44
    552005-12-18: knut st. osmundsen <bird-gccos2-spam@anduin.net>
     6    - libc:
     7        o #22: Added DosFindFirst() as fallback when DosQueryPathInfo() fails
     8          to query the symlink EA in the path resolver. This problem occurs
     9          when doing stat() on an open file (pwd_mkdb example).
    610    - emxomfld:
    711        o Don't display usage() on failure, just the error message.
  • branches/libc-0.6/src/emx/src/lib/sys/fs.c

    r2495 r2496  
    973973             * This'll of course also provide proper verification of the path too. :-)
    974974             *
    975              * (This is a little bit messed up since we'll have to use wildcard for
    976              * getting the caseing resolved.)
     975             * This is a little bit messed up since we'll have to use wildcard for
     976             * getting the casing resolved.
    977977             */
    978978            //LIBC_ASSERT(psz - pszNativePath == cchNativePath); - figure this one.
     
    987987            psz[1] = chNext;
    988988            if (rc || cFiles == 0)
    989             {
    990989                hDir = HDIR_CREATE;
    991             }
    992990            while (!rc && cFiles == 1 && pFindBuf->cchName != psz - pszPrev)
    993991                rc = DosFindNext(hDir, pFindBuf, SIZEOF_ACHBUFFER, &cFiles);
     
    10081006
    10091007            /*
    1010              * Try querying the symlink EA value
     1008             * Try querying the symlink EA value.
    10111009             * (This operation will reuse the achBuffer overwriting the pFindBuf data!)
    10121010             *
     
    10151013             * returning the right things at some point, and besides it's return data
    10161014             * is rather clumsily laid out. So, I decided not to try my luck on it.
     1015             *
     1016             * On second thought, we seems to end up having to use DosFindFirst in some
     1017             * cases anyway... very nice.
    10171018             */
    10181019            if (    pFindBuf->cbList > sizeof(USHORT) * 2 + 1
    10191020                &&  (   (fFlags & BACKFS_FLAGS_RESOLVE_FULL)
    1020                      || chSlash))
    1021             {
    1022                 EAOP2   EaOp;
    1023                 EaOp.fpGEA2List = (PGEA2LIST)&gGEA2ListSymlink;
    1024                 EaOp.fpFEA2List = (PFEA2LIST)pachBuffer;
    1025                 EaOp.oError     = 0;
    1026                 EaOp.fpFEA2List->cbList = SIZEOF_ACHBUFFER;
    1027                 rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASFROMLIST, &EaOp, sizeof(EaOp));
     1021                     || chSlash)
     1022                &&  !(pFindBuf->attrFile & FILE_DIRECTORY))
     1023            {
     1024                PEAOP2  pEaOp2 = (PEAOP2)pachBuffer;
     1025                pEaOp2->fpGEA2List = (PGEA2LIST)&gGEA2ListSymlink;
     1026                pEaOp2->fpFEA2List = (PFEA2LIST)(pEaOp2 + 1);
     1027                pEaOp2->oError     = 0;
     1028                pEaOp2->fpFEA2List->cbList = SIZEOF_ACHBUFFER - sizeof(*pEaOp2);
     1029                rc = DosQueryPathInfo((PCSZ)pszNativePath, FIL_QUERYEASFROMLIST, pEaOp2, sizeof(*pEaOp2));
    10281030                if (rc)
    10291031                {
    1030                     LIBCLOG_MSG("DosQueryPathInfo('%s',,,) -> %d resolving '%s'\n", pszNativePath, rc, pszUserPathIn);
    1031                     if ((fFlags & BACKFS_FLAGS_RESOLVE_FULL_MAYBE_) && !chSlash)
    1032                         rcRet = 0;
    1033                     else
    1034                         rcRet = rc == ERROR_FILE_NOT_FOUND && chSlash ? -ENOENT : -__libc_native2errno(rc);
    1035                     break;
     1032                    cFiles = 1;
     1033                    pEaOp2->fpGEA2List = (PGEA2LIST)&gGEA2ListSymlink;
     1034                    pEaOp2->fpFEA2List = (PFEA2LIST)(pEaOp2 + 1);
     1035                    pEaOp2->oError     = 0;
     1036                    pEaOp2->fpFEA2List->cbList = SIZEOF_ACHBUFFER - sizeof(*pEaOp2);
     1037                    rc = DosFindFirst((PCSZ)pszNativePath, &hDir, 0, pEaOp2, pEaOp2->fpFEA2List->cbList + sizeof(*pEaOp2), &cFiles, FIL_QUERYEASFROMLIST);
     1038                    if (rc || cFiles == 0)
     1039                    {
     1040                        hDir = HDIR_CREATE;
     1041                        LIBCLOG_MSG("DosFindFirst('%s',,,pEaOp2,) -> %d resolving '%s'\n", pszNativePath, rc, pszUserPathIn);
     1042                        if ((fFlags & BACKFS_FLAGS_RESOLVE_FULL_MAYBE_) && !chSlash)
     1043                            rcRet = 0;
     1044                        else
     1045                            rcRet = rc == ERROR_FILE_NOT_FOUND && chSlash ? -ENOENT : -__libc_native2errno(rc);
     1046                        break;
     1047                    }
     1048                    pEaOp2->fpFEA2List = (PFEA2LIST)((char *)pEaOp2 + sizeof(EAOP2) + offsetof(FILEFINDBUF3, cchName));
    10361049                }
    10371050
     
    10391052                 * Did we find any symlink EA?
    10401053                 */
    1041                 if (    EaOp.fpFEA2List->cbList > sizeof(EaOp.fpFEA2List->list[0])
    1042                     &&  EaOp.fpFEA2List->list[0].cbValue)
     1054                if (    pEaOp2->fpFEA2List->cbList > sizeof(pEaOp2->fpFEA2List->list[0])
     1055                    &&  pEaOp2->fpFEA2List->list[0].cbValue)
    10431056                {
    10441057                    /* Validate the EA. */
    1045                     PUSHORT pusType = (PUSHORT)((char *)&EaOp.fpFEA2List->list[1] + EaOp.fpFEA2List->list[0].cbName);
     1058                    PUSHORT pusType = (PUSHORT)((char *)&pEaOp2->fpFEA2List->list[1] + pEaOp2->fpFEA2List->list[0].cbName);
    10461059                    char   *pszSymlink = (char *)&pusType[2];
    10471060                    if (    pusType[0] != EAT_ASCII
    1048                         ||  pusType[1] > EaOp.fpFEA2List->list[0].cbValue
     1061                        ||  pusType[1] > pEaOp2->fpFEA2List->list[0].cbValue
    10491062                        ||  !pusType[1]
    10501063                        ||  !*pszSymlink)
    10511064                    {
    10521065                        LIBCLOG_ERROR("Invalid symlink EA! type=%x len=%d cbValue=%d *pszSymlink=%c\n",
    1053                                       pusType[0], pusType[1], EaOp.fpFEA2List->list[0].cbValue, *pszSymlink);
     1066                                      pusType[0], pusType[1], pEaOp2->fpFEA2List->list[0].cbValue, *pszSymlink);
    10541067                        rcRet = -EFTYPE;
    10551068                        break;
Note: See TracChangeset for help on using the changeset viewer.