VirtualBox

Changeset 2912 in kBuild for trunk/src/lib/nt/kFsCache.c


Ignore:
Timestamp:
Sep 14, 2016 1:36:15 PM (9 years ago)
Author:
bird
Message:

rewrote kmk_redirect to skip the separate process. Added chache invalidation after directory deletion for addressing kmk rebuild and fetching.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/nt/kFsCache.c

    r2879 r2912  
    19161916 * @param   pCache              The cache.
    19171917 * @param   chLetter            The uppercased drive letter.
     1918 * @param   fFlags              Lookup flags, KFSCACHE_LOOKUP_F_XXX.
    19181919 * @param   penmError           Where to return details as to why the lookup
    19191920 *                              failed.
    19201921 */
    1921 static PKFSOBJ kFswCacheLookupDrive(PKFSCACHE pCache, char chLetter, KFSLOOKUPERROR *penmError)
     1922static PKFSOBJ kFswCacheLookupDrive(PKFSCACHE pCache, char chLetter, KU32 fFlags, KFSLOOKUPERROR *penmError)
    19221923{
    19231924    KU32 const          uHash = chLetter - 'A';
     
    19521953                return pCur;
    19531954            kHlpAssert(pCur->bObjType == KFSOBJ_TYPE_MISSING);
    1954             if (kFsCacheRefreshMissingIntermediateDir(pCache, pCur, penmError))
     1955            if (   (fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH)
     1956                || kFsCacheRefreshMissingIntermediateDir(pCache, pCur, penmError))
    19551957                return pCur;
    19561958            return NULL;
    19571959        }
     1960    }
     1961
     1962    if (fFlags & KFSCACHE_LOOKUP_F_NO_INSERT)
     1963    {
     1964        *penmError = KFSLOOKUPERROR_PATH_COMP_NOT_FOUND; /* close enough */
     1965        return NULL;
    19581966    }
    19591967
     
    21992207 * @param   pCache              The cache.
    22002208 * @param   pszPath             The path.
     2209 * @param   fFlags              Lookup flags, KFSCACHE_LOOKUP_F_XXX.
    22012210 * @param   poff                Where to return the root dire.
    22022211 * @param   penmError           Where to return details as to why the lookup
    22032212 *                              failed.
    22042213 */
    2205 static PKFSOBJ kFswCacheLookupUncShareA(PKFSCACHE pCache, const char *pszPath, KU32 *poff, KFSLOOKUPERROR *penmError)
     2214static PKFSOBJ kFswCacheLookupUncShareA(PKFSCACHE pCache, const char *pszPath, KU32 fFlags,
     2215                                        KU32 *poff, KFSLOOKUPERROR *penmError)
    22062216{
    22072217#if 0 /* later */
     
    22502260 * @param   pCache              The cache.
    22512261 * @param   pwszPath            The path.
     2262 * @param   fFlags              Lookup flags, KFSCACHE_LOOKUP_F_XXX.
    22522263 * @param   poff                Where to return the root dire.
    22532264 * @param   penmError           Where to return details as to why the lookup
    22542265 *                              failed.
    22552266 */
    2256 static PKFSOBJ kFswCacheLookupUncShareW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 *poff, KFSLOOKUPERROR *penmError)
     2267static PKFSOBJ kFswCacheLookupUncShareW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 fFlags,
     2268                                        KU32 *poff, KFSLOOKUPERROR *penmError)
    22572269{
    22582270#if 0 /* later */
     
    23042316 * @param   pszPath             The path to walk.
    23052317 * @param   cchPath             The length of the path.
     2318 * @param   fFlags              Lookup flags, KFSCACHE_LOOKUP_F_XXX.
    23062319 * @param   penmError           Where to return details as to why the lookup
    23072320 *                              failed.
     
    23102323 *                              found problem.  Optional.
    23112324 */
    2312 PKFSOBJ kFsCacheLookupRelativeToDirA(PKFSCACHE pCache, PKFSDIR pParent, const char *pszPath, KU32 cchPath,
     2325PKFSOBJ kFsCacheLookupRelativeToDirA(PKFSCACHE pCache, PKFSDIR pParent, const char *pszPath, KU32 cchPath, KU32 fFlags,
    23132326                                     KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor)
    23142327{
     
    23452358         * Do we need to populate or refresh this directory first?
    23462359         */
    2347         if (   pParent->fPopulated
     2360        if (   !pParent->fNeedRePopulating
     2361            && pParent->fPopulated
    23482362            && (   pParent->Obj.uCacheGen == KFSOBJ_CACHE_GEN_IGNORE
    23492363                || pParent->Obj.uCacheGen == pCache->auGenerations[pParent->Obj.fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) )
    23502364        { /* likely */ }
    2351         else if (kFsCachePopuplateOrRefreshDir(pCache, pParent, penmError))
     2365        else if (   (fFlags & (KFSCACHE_LOOKUP_F_NO_INSERT | fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH))
     2366                 || kFsCachePopuplateOrRefreshDir(pCache, pParent, penmError))
    23522367        { /* likely */ }
    23532368        else
     
    23652380        else
    23662381        {
    2367             if (pCache->fFlags & KFSCACHE_F_MISSING_OBJECTS)
     2382            if (    (pCache->fFlags & KFSCACHE_F_MISSING_OBJECTS)
     2383                && !(fFlags & KFSCACHE_LOOKUP_F_NO_INSERT))
    23682384                pChild = kFsCacheCreateMissingA(pCache, pParent, &pszPath[off], offEnd - off, penmError);
    23692385            if (cchSlashes == 0 || offEnd + cchSlashes >= cchPath)
     
    23882404                || pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE
    23892405                || pChild->uCacheGen == pCache->auGenerationsMissing[pChild->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]
     2406                || (fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH)
    23902407                || kFsCacheRefreshMissing(pCache, pChild, penmError) )
    23912408            { /* likely */ }
     
    24092426        }
    24102427        else if (   pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE
    2411                  || pChild->uCacheGen == pCache->auGenerationsMissing[pChild->fFlags & KFSOBJ_F_USE_CUSTOM_GEN])
     2428                 || pChild->uCacheGen == pCache->auGenerationsMissing[pChild->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]
     2429                 || (fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH))
    24122430        {
    24132431            *penmError = KFSLOOKUPERROR_PATH_COMP_NOT_FOUND;
     
    24442462 * @param   pszPath             The path to walk.  No dot-dot bits allowed!
    24452463 * @param   cchPath             The length of the path.
     2464 * @param   fFlags              Lookup flags, KFSCACHE_LOOKUP_F_XXX.
    24462465 * @param   penmError           Where to return details as to why the lookup
    24472466 *                              failed.
     
    24502469 *                              found problem.  Optional.
    24512470 */
    2452 PKFSOBJ kFsCacheLookupRelativeToDirW(PKFSCACHE pCache, PKFSDIR pParent, const wchar_t *pwszPath, KU32 cwcPath,
     2471PKFSOBJ kFsCacheLookupRelativeToDirW(PKFSCACHE pCache, PKFSDIR pParent, const wchar_t *pwszPath, KU32 cwcPath, KU32 fFlags,
    24532472                                     KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor)
    24542473{
     
    24852504         * Do we need to populate or refresh this directory first?
    24862505         */
    2487         if (   pParent->fPopulated
     2506        if (   !pParent->fNeedRePopulating
     2507            && pParent->fPopulated
    24882508            && (   pParent->Obj.uCacheGen == KFSOBJ_CACHE_GEN_IGNORE
    24892509                || pParent->Obj.uCacheGen == pCache->auGenerations[pParent->Obj.fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) )
    24902510        { /* likely */ }
    2491         else if (kFsCachePopuplateOrRefreshDir(pCache, pParent, penmError))
     2511        else if (   (fFlags & (KFSCACHE_LOOKUP_F_NO_INSERT | fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH))
     2512                 || kFsCachePopuplateOrRefreshDir(pCache, pParent, penmError))
    24922513        { /* likely */ }
    24932514        else
     
    25052526        else
    25062527        {
    2507             if (pCache->fFlags & KFSCACHE_F_MISSING_OBJECTS)
     2528            if (    (pCache->fFlags & KFSCACHE_F_MISSING_OBJECTS)
     2529                && !(fFlags & KFSCACHE_LOOKUP_F_NO_INSERT))
    25082530                pChild = kFsCacheCreateMissingW(pCache, pParent, &pwszPath[off], offEnd - off, penmError);
    25092531            if (cwcSlashes == 0 || offEnd + cwcSlashes >= cwcPath)
     
    25282550                || pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE
    25292551                || pChild->uCacheGen == pCache->auGenerationsMissing[pChild->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]
     2552                || (fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH)
    25302553                || kFsCacheRefreshMissing(pCache, pChild, penmError) )
    25312554            { /* likely */ }
     
    25492572        }
    25502573        else if (   pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE
    2551                  || pChild->uCacheGen == pCache->auGenerationsMissing[pChild->fFlags & KFSOBJ_F_USE_CUSTOM_GEN])
     2574                 || pChild->uCacheGen == pCache->auGenerationsMissing[pChild->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]
     2575                 || (fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH) )
     2576
    25522577        {
    25532578            *penmError = KFSLOOKUPERROR_PATH_COMP_NOT_FOUND;
     
    25832608 * @param   pszPath             The path to walk. No dot-dot bits allowed!
    25842609 * @param   cchPath             The length of the path.
     2610 * @param   fFlags              Lookup flags, KFSCACHE_LOOKUP_F_XXX.
    25852611 * @param   penmError           Where to return details as to why the lookup
    25862612 *                              failed.
     
    25892615 *                              found problem.  Optional.
    25902616 */
    2591 static PKFSOBJ kFsCacheLookupAbsoluteA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath,
     2617static PKFSOBJ kFsCacheLookupAbsoluteA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath, KU32 fFlags,
    25922618                                       KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor)
    25932619{
     
    26092635        offEnd = 2;
    26102636        kHlpAssert(IS_SLASH(pszPath[2]));
    2611         pRoot = kFswCacheLookupDrive(pCache, toupper(pszPath[0]), penmError);
     2637        pRoot = kFswCacheLookupDrive(pCache, toupper(pszPath[0]), fFlags, penmError);
    26122638    }
    26132639    else if (   IS_SLASH(pszPath[0])
    26142640             && IS_SLASH(pszPath[1]) )
    2615         pRoot = kFswCacheLookupUncShareA(pCache, pszPath, &offEnd, penmError);
     2641        pRoot = kFswCacheLookupUncShareA(pCache, pszPath, fFlags, &offEnd, penmError);
    26162642    else
    26172643    {
     
    26402666                                    ? pCache->auGenerations[       pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]
    26412667                                    : pCache->auGenerationsMissing[pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN])
     2668            || (fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH)
    26422669            || kFsCacheRefreshObj(pCache, pRoot, penmError))
    26432670            return kFsCacheObjRetainInternal(pRoot);
     
    26612688     */
    26622689    return kFsCacheLookupRelativeToDirA(pCache, (PKFSDIR)pRoot, &pszPath[offEnd + cchSlashes],
    2663                                         cchPath - offEnd - cchSlashes, penmError, ppLastAncestor);
     2690                                        cchPath - offEnd - cchSlashes, fFlags, penmError, ppLastAncestor);
    26642691}
    26652692
     
    26772704 * @param   pwszPath            The path to walk.
    26782705 * @param   cwcPath             The length of the path (in wchar_t's).
     2706 * @param   fFlags              Lookup flags, KFSCACHE_LOOKUP_F_XXX.
    26792707 * @param   penmError           Where to return details as to why the lookup
    26802708 *                              failed.
     
    26832711 *                              found problem.  Optional.
    26842712 */
    2685 static PKFSOBJ kFsCacheLookupAbsoluteW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 cwcPath,
     2713static PKFSOBJ kFsCacheLookupAbsoluteW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 cwcPath, KU32 fFlags,
    26862714                                       KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor)
    26872715{
     
    27062734        offEnd = 2;
    27072735        kHlpAssert(IS_SLASH(pwszPath[2]));
    2708         pRoot = kFswCacheLookupDrive(pCache, toupper(pwszPath[0]), penmError);
     2736        pRoot = kFswCacheLookupDrive(pCache, toupper(pwszPath[0]), fFlags, penmError);
    27092737    }
    27102738    else if (   IS_SLASH(pwszPath[0])
    27112739             && IS_SLASH(pwszPath[1]) )
    2712         pRoot = kFswCacheLookupUncShareW(pCache, pwszPath, &offEnd, penmError);
     2740        pRoot = kFswCacheLookupUncShareW(pCache, pwszPath, fFlags, &offEnd, penmError);
    27132741    else
    27142742    {
     
    27372765                                    ? pCache->auGenerations[       pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]
    27382766                                    : pCache->auGenerationsMissing[pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN])
     2767            || (fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH)
    27392768            || kFsCacheRefreshObj(pCache, pRoot, penmError))
    27402769            return kFsCacheObjRetainInternal(pRoot);
     
    27582787     */
    27592788    return kFsCacheLookupRelativeToDirW(pCache, (PKFSDIR)pRoot, &pwszPath[offEnd + cwcSlashes],
    2760                                         cwcPath - offEnd - cwcSlashes, penmError, ppLastAncestor);
     2789                                        cwcPath - offEnd - cwcSlashes, fFlags, penmError, ppLastAncestor);
    27612790}
    27622791
     
    27722801 * @param   pszPath             The path.
    27732802 * @param   cchPath             The length of the path.
     2803 * @param   fFlags              Lookup flags, KFSCACHE_LOOKUP_F_XXX.
    27742804 * @param   penmError           Where to return details as to why the lookup
    27752805 *                              failed.
     
    27782808 *                              found problem.  Optional.
    27792809 */
    2780 static PKFSOBJ kFsCacheLookupSlowA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath,
     2810static PKFSOBJ kFsCacheLookupSlowA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath, KU32 fFlags,
    27812811                                   KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor)
    27822812{
     
    27902820        && cchFull < sizeof(szFull))
    27912821    {
    2792         PKFSOBJ pFsObj;
    27932822        KFSCACHE_LOG2(("kFsCacheLookupSlowA(%s)\n", pszPath));
    2794         pFsObj = kFsCacheLookupAbsoluteA(pCache, szFull, cchFull, penmError, ppLastAncestor);
    2795 
    2796 #if 0 /* No need to do this until it's actually queried. */
    2797         /* Cache the resulting path. */
    2798         if (   pFsObj
    2799             || (pCache->fFlags & KFSCACHE_F_MISSING_PATHS)
    2800             || *penmError == KFSLOOKUPERROR_UNSUPPORTED)
    2801         {
    2802             KU32 uHashPath = kFsCacheStrHash(szFull);
    2803             kFsCacheCreatePathHashTabEntryA(pCache, pFsObj, pszPath, cchPath, uHashPath,
    2804                                             uHashPath % K_ELEMENTS(pCache->apAnsiPaths), *penmError);
    2805         }
    2806 #endif
    2807         return pFsObj;
     2823        return kFsCacheLookupAbsoluteA(pCache, szFull, cchFull, fFlags, penmError, ppLastAncestor);
    28082824    }
    28092825
     
    28252841 * @param   pwszPath            The path.
    28262842 * @param   cwcPath             The length of the path (in wchar_t's).
     2843 * @param   fFlags              Lookup flags, KFSCACHE_LOOKUP_F_XXX.
    28272844 * @param   penmError           Where to return details as to why the lookup
    28282845 *                              failed.
     
    28312848 *                              found problem.  Optional.
    28322849 */
    2833 static PKFSOBJ kFsCacheLookupSlowW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 wcwPath,
     2850static PKFSOBJ kFsCacheLookupSlowW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 wcwPath, KU32 fFlags,
    28342851                                   KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor)
    28352852{
     
    28432860        && cwcFull < KFSCACHE_CFG_MAX_PATH)
    28442861    {
    2845         PKFSOBJ pFsObj;
    28462862        KFSCACHE_LOG2(("kFsCacheLookupSlowA(%ls)\n", pwszPath));
    2847         pFsObj = kFsCacheLookupAbsoluteW(pCache, wszFull, cwcFull, penmError, ppLastAncestor);
    2848 
    2849 #if 0 /* No need to do this until it's actually queried. */
    2850         /* Cache the resulting path. */
    2851         if (   pFsObj
    2852             || (pCache->fFlags & KFSCACHE_F_MISSING_PATHS)
    2853             || *penmError == KFSLOOKUPERROR_UNSUPPORTED)
    2854         {
    2855             KU32 uHashPath = kFsCacheStrHash(szFull);
    2856             kFsCacheCreatePathHashTabEntryA(pCache, pFsObj, pszPath, cchPath, uHashPath,
    2857                                             uHashPath % K_ELEMENTS(pCache->apAnsiPaths), *penmError);
    2858         }
    2859 #endif
    2860         return pFsObj;
     2863        return kFsCacheLookupAbsoluteW(pCache, wszFull, cwcFull, fFlags, penmError, ppLastAncestor);
    28612864    }
    28622865
     
    28822885    {
    28832886        if (pHashEntry->fAbsolute)
    2884             pHashEntry->pFsObj = kFsCacheLookupAbsoluteA(pCache, pHashEntry->pszPath, pHashEntry->cchPath,
     2887            pHashEntry->pFsObj = kFsCacheLookupAbsoluteA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 0 /*fFlags*/,
    28852888                                                         &pHashEntry->enmError, &pLastAncestor);
    28862889        else
    2887             pHashEntry->pFsObj = kFsCacheLookupSlowA(pCache, pHashEntry->pszPath, pHashEntry->cchPath,
     2890            pHashEntry->pFsObj = kFsCacheLookupSlowA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 0 /*fFlags*/,
    28882891                                                     &pHashEntry->enmError, &pLastAncestor);
    28892892    }
     
    29002903                kFsCacheObjRelease(pCache, pHashEntry->pFsObj);
    29012904                if (pHashEntry->fAbsolute)
    2902                     pHashEntry->pFsObj = kFsCacheLookupAbsoluteA(pCache, pHashEntry->pszPath, pHashEntry->cchPath,
     2905                    pHashEntry->pFsObj = kFsCacheLookupAbsoluteA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 0 /*fFlags*/,
    29032906                                                                 &pHashEntry->enmError, &pLastAncestor);
    29042907                else
    2905                     pHashEntry->pFsObj = kFsCacheLookupSlowA(pCache, pHashEntry->pszPath, pHashEntry->cchPath,
     2908                    pHashEntry->pFsObj = kFsCacheLookupSlowA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 0 /*fFlags*/,
    29062909                                                             &pHashEntry->enmError, &pLastAncestor);
    29072910            }
     
    29432946    {
    29442947        if (pHashEntry->fAbsolute)
    2945             pHashEntry->pFsObj = kFsCacheLookupAbsoluteW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath,
     2948            pHashEntry->pFsObj = kFsCacheLookupAbsoluteW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 0 /*fFlags*/,
    29462949                                                         &pHashEntry->enmError, &pLastAncestor);
    29472950        else
    2948             pHashEntry->pFsObj = kFsCacheLookupSlowW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath,
     2951            pHashEntry->pFsObj = kFsCacheLookupSlowW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 0 /*fFlags*/,
    29492952                                                     &pHashEntry->enmError, &pLastAncestor);
    29502953    }
     
    29612964                kFsCacheObjRelease(pCache, pHashEntry->pFsObj);
    29622965                if (pHashEntry->fAbsolute)
    2963                     pHashEntry->pFsObj = kFsCacheLookupAbsoluteW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath,
     2966                    pHashEntry->pFsObj = kFsCacheLookupAbsoluteW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 0 /*fFlags*/,
    29642967                                                                 &pHashEntry->enmError, &pLastAncestor);
    29652968                else
    2966                     pHashEntry->pFsObj = kFsCacheLookupSlowW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath,
     2969                    pHashEntry->pFsObj = kFsCacheLookupSlowW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 0 /*fFlags*/,
    29672970                                                             &pHashEntry->enmError, &pLastAncestor);
    29682971            }
     
    30693072            && !kFsCacheHasDotDotA(pchPath, cchPath) )
    30703073        {
    3071             pFsObj = kFsCacheLookupAbsoluteA(pCache, pchPath, cchPath, penmError, &pLastAncestor);
     3074            pFsObj = kFsCacheLookupAbsoluteA(pCache, pchPath, cchPath, 0 /*fFlags*/, penmError, &pLastAncestor);
    30723075            fAbsolute = K_TRUE;
    30733076        }
    30743077        else
    30753078        {
    3076             pFsObj = kFsCacheLookupSlowA(pCache, pchPath, cchPath, penmError, &pLastAncestor);
     3079            pFsObj = kFsCacheLookupSlowA(pCache, pchPath, cchPath, 0 /*fFlags*/, penmError, &pLastAncestor);
    30773080            fAbsolute = K_FALSE;
    30783081        }
     
    31773180            && !kFsCacheHasDotDotW(pwcPath, cwcPath) )
    31783181        {
    3179             pFsObj = kFsCacheLookupAbsoluteW(pCache, pwcPath, cwcPath, penmError, &pLastAncestor);
     3182            pFsObj = kFsCacheLookupAbsoluteW(pCache, pwcPath, cwcPath, 0 /*fFlags*/, penmError, &pLastAncestor);
    31803183            fAbsolute = K_TRUE;
    31813184        }
    31823185        else
    31833186        {
    3184             pFsObj = kFsCacheLookupSlowW(pCache, pwcPath, cwcPath, penmError, &pLastAncestor);
     3187            pFsObj = kFsCacheLookupSlowW(pCache, pwcPath, cwcPath, 0 /*fFlags*/, penmError, &pLastAncestor);
    31853188            fAbsolute = K_FALSE;
    31863189        }
     
    39803983        return K_TRUE;
    39813984    }
     3985    return K_FALSE;
     3986}
     3987
     3988
     3989/**
     3990 * Invalidates a deleted directory, ANSI version.
     3991 *
     3992 * @returns K_TRUE if found and is a non-root directory. Otherwise K_FALSE.
     3993 * @param   pCache              The cache.
     3994 * @param   pszDir              The directory.
     3995 */
     3996KBOOL kFsCacheInvalidateDeletedDirectoryA(PKFSCACHE pCache, const char *pszDir)
     3997{
     3998    KU32            cchDir = (KU32)kHlpStrLen(pszDir);
     3999    KFSLOOKUPERROR  enmError;
     4000    PKFSOBJ         pFsObj;
     4001
     4002    /* Is absolute without any '..' bits? */
     4003    if (   cchDir >= 3
     4004        && (   (   pszDir[1] == ':'    /* Drive letter */
     4005                && IS_SLASH(pszDir[2])
     4006                && IS_ALPHA(pszDir[0]) )
     4007            || (   IS_SLASH(pszDir[0]) /* UNC */
     4008                && IS_SLASH(pszDir[1]) ) )
     4009        && !kFsCacheHasDotDotA(pszDir, cchDir) )
     4010        pFsObj = kFsCacheLookupAbsoluteA(pCache, pszDir, cchDir, KFSCACHE_LOOKUP_F_NO_INSERT | KFSCACHE_LOOKUP_F_NO_REFRESH,
     4011                                         &enmError, NULL);
     4012    else
     4013        pFsObj = kFsCacheLookupSlowA(pCache, pszDir, cchDir, KFSCACHE_LOOKUP_F_NO_INSERT | KFSCACHE_LOOKUP_F_NO_REFRESH,
     4014                                     &enmError, NULL);
     4015    if (pFsObj)
     4016    {
     4017        /* Is directory? */
     4018        if (pFsObj->bObjType == KFSOBJ_TYPE_DIR)
     4019        {
     4020            if (pFsObj->pParent != &pCache->RootDir)
     4021            {
     4022                PKFSDIR pDir = (PKFSDIR)pFsObj;
     4023                KFSCACHE_LOG(("kFsCacheInvalidateDeletedDirectoryA: %s hDir=%p\n", pszDir, pDir->hDir));
     4024                if (pDir->hDir != INVALID_HANDLE_VALUE)
     4025                {
     4026                    g_pfnNtClose(pDir->hDir);
     4027                    pDir->hDir = INVALID_HANDLE_VALUE;
     4028                }
     4029                pDir->fNeedRePopulating = K_TRUE;
     4030                pDir->Obj.uCacheGen = pCache->auGenerations[pDir->Obj.fFlags & KFSOBJ_F_USE_CUSTOM_GEN] - 1;
     4031                kFsCacheObjRetainInternal(&pDir->Obj);
     4032                return K_TRUE;
     4033            }
     4034            KFSCACHE_LOG(("kFsCacheInvalidateDeletedDirectoryA: Trying to invalidate a root directory was deleted! %s\n", pszDir));
     4035        }
     4036        else
     4037            KFSCACHE_LOG(("kFsCacheInvalidateDeletedDirectoryA: Trying to invalidate a non-directory: bObjType=%d %s\n",
     4038                          pFsObj->bObjType, pszDir));
     4039        kFsCacheObjRetainInternal(pFsObj);
     4040    }
     4041    else
     4042        KFSCACHE_LOG(("kFsCacheInvalidateDeletedDirectoryA: '%s' was not found\n", pszDir));
    39824043    return K_FALSE;
    39834044}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette