Changeset 2912 in kBuild for trunk/src/lib/nt/kFsCache.c
- Timestamp:
- Sep 14, 2016 1:36:15 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/nt/kFsCache.c
r2879 r2912 1916 1916 * @param pCache The cache. 1917 1917 * @param chLetter The uppercased drive letter. 1918 * @param fFlags Lookup flags, KFSCACHE_LOOKUP_F_XXX. 1918 1919 * @param penmError Where to return details as to why the lookup 1919 1920 * failed. 1920 1921 */ 1921 static PKFSOBJ kFswCacheLookupDrive(PKFSCACHE pCache, char chLetter, K FSLOOKUPERROR *penmError)1922 static PKFSOBJ kFswCacheLookupDrive(PKFSCACHE pCache, char chLetter, KU32 fFlags, KFSLOOKUPERROR *penmError) 1922 1923 { 1923 1924 KU32 const uHash = chLetter - 'A'; … … 1952 1953 return pCur; 1953 1954 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)) 1955 1957 return pCur; 1956 1958 return NULL; 1957 1959 } 1960 } 1961 1962 if (fFlags & KFSCACHE_LOOKUP_F_NO_INSERT) 1963 { 1964 *penmError = KFSLOOKUPERROR_PATH_COMP_NOT_FOUND; /* close enough */ 1965 return NULL; 1958 1966 } 1959 1967 … … 2199 2207 * @param pCache The cache. 2200 2208 * @param pszPath The path. 2209 * @param fFlags Lookup flags, KFSCACHE_LOOKUP_F_XXX. 2201 2210 * @param poff Where to return the root dire. 2202 2211 * @param penmError Where to return details as to why the lookup 2203 2212 * failed. 2204 2213 */ 2205 static PKFSOBJ kFswCacheLookupUncShareA(PKFSCACHE pCache, const char *pszPath, KU32 *poff, KFSLOOKUPERROR *penmError) 2214 static PKFSOBJ kFswCacheLookupUncShareA(PKFSCACHE pCache, const char *pszPath, KU32 fFlags, 2215 KU32 *poff, KFSLOOKUPERROR *penmError) 2206 2216 { 2207 2217 #if 0 /* later */ … … 2250 2260 * @param pCache The cache. 2251 2261 * @param pwszPath The path. 2262 * @param fFlags Lookup flags, KFSCACHE_LOOKUP_F_XXX. 2252 2263 * @param poff Where to return the root dire. 2253 2264 * @param penmError Where to return details as to why the lookup 2254 2265 * failed. 2255 2266 */ 2256 static PKFSOBJ kFswCacheLookupUncShareW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 *poff, KFSLOOKUPERROR *penmError) 2267 static PKFSOBJ kFswCacheLookupUncShareW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 fFlags, 2268 KU32 *poff, KFSLOOKUPERROR *penmError) 2257 2269 { 2258 2270 #if 0 /* later */ … … 2304 2316 * @param pszPath The path to walk. 2305 2317 * @param cchPath The length of the path. 2318 * @param fFlags Lookup flags, KFSCACHE_LOOKUP_F_XXX. 2306 2319 * @param penmError Where to return details as to why the lookup 2307 2320 * failed. … … 2310 2323 * found problem. Optional. 2311 2324 */ 2312 PKFSOBJ kFsCacheLookupRelativeToDirA(PKFSCACHE pCache, PKFSDIR pParent, const char *pszPath, KU32 cchPath, 2325 PKFSOBJ kFsCacheLookupRelativeToDirA(PKFSCACHE pCache, PKFSDIR pParent, const char *pszPath, KU32 cchPath, KU32 fFlags, 2313 2326 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor) 2314 2327 { … … 2345 2358 * Do we need to populate or refresh this directory first? 2346 2359 */ 2347 if ( pParent->fPopulated 2360 if ( !pParent->fNeedRePopulating 2361 && pParent->fPopulated 2348 2362 && ( pParent->Obj.uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2349 2363 || pParent->Obj.uCacheGen == pCache->auGenerations[pParent->Obj.fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) ) 2350 2364 { /* 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)) 2352 2367 { /* likely */ } 2353 2368 else … … 2365 2380 else 2366 2381 { 2367 if (pCache->fFlags & KFSCACHE_F_MISSING_OBJECTS) 2382 if ( (pCache->fFlags & KFSCACHE_F_MISSING_OBJECTS) 2383 && !(fFlags & KFSCACHE_LOOKUP_F_NO_INSERT)) 2368 2384 pChild = kFsCacheCreateMissingA(pCache, pParent, &pszPath[off], offEnd - off, penmError); 2369 2385 if (cchSlashes == 0 || offEnd + cchSlashes >= cchPath) … … 2388 2404 || pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2389 2405 || pChild->uCacheGen == pCache->auGenerationsMissing[pChild->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 2406 || (fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH) 2390 2407 || kFsCacheRefreshMissing(pCache, pChild, penmError) ) 2391 2408 { /* likely */ } … … 2409 2426 } 2410 2427 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)) 2412 2430 { 2413 2431 *penmError = KFSLOOKUPERROR_PATH_COMP_NOT_FOUND; … … 2444 2462 * @param pszPath The path to walk. No dot-dot bits allowed! 2445 2463 * @param cchPath The length of the path. 2464 * @param fFlags Lookup flags, KFSCACHE_LOOKUP_F_XXX. 2446 2465 * @param penmError Where to return details as to why the lookup 2447 2466 * failed. … … 2450 2469 * found problem. Optional. 2451 2470 */ 2452 PKFSOBJ kFsCacheLookupRelativeToDirW(PKFSCACHE pCache, PKFSDIR pParent, const wchar_t *pwszPath, KU32 cwcPath, 2471 PKFSOBJ kFsCacheLookupRelativeToDirW(PKFSCACHE pCache, PKFSDIR pParent, const wchar_t *pwszPath, KU32 cwcPath, KU32 fFlags, 2453 2472 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor) 2454 2473 { … … 2485 2504 * Do we need to populate or refresh this directory first? 2486 2505 */ 2487 if ( pParent->fPopulated 2506 if ( !pParent->fNeedRePopulating 2507 && pParent->fPopulated 2488 2508 && ( pParent->Obj.uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2489 2509 || pParent->Obj.uCacheGen == pCache->auGenerations[pParent->Obj.fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) ) 2490 2510 { /* 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)) 2492 2513 { /* likely */ } 2493 2514 else … … 2505 2526 else 2506 2527 { 2507 if (pCache->fFlags & KFSCACHE_F_MISSING_OBJECTS) 2528 if ( (pCache->fFlags & KFSCACHE_F_MISSING_OBJECTS) 2529 && !(fFlags & KFSCACHE_LOOKUP_F_NO_INSERT)) 2508 2530 pChild = kFsCacheCreateMissingW(pCache, pParent, &pwszPath[off], offEnd - off, penmError); 2509 2531 if (cwcSlashes == 0 || offEnd + cwcSlashes >= cwcPath) … … 2528 2550 || pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2529 2551 || pChild->uCacheGen == pCache->auGenerationsMissing[pChild->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 2552 || (fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH) 2530 2553 || kFsCacheRefreshMissing(pCache, pChild, penmError) ) 2531 2554 { /* likely */ } … … 2549 2572 } 2550 2573 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 2552 2577 { 2553 2578 *penmError = KFSLOOKUPERROR_PATH_COMP_NOT_FOUND; … … 2583 2608 * @param pszPath The path to walk. No dot-dot bits allowed! 2584 2609 * @param cchPath The length of the path. 2610 * @param fFlags Lookup flags, KFSCACHE_LOOKUP_F_XXX. 2585 2611 * @param penmError Where to return details as to why the lookup 2586 2612 * failed. … … 2589 2615 * found problem. Optional. 2590 2616 */ 2591 static PKFSOBJ kFsCacheLookupAbsoluteA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath, 2617 static PKFSOBJ kFsCacheLookupAbsoluteA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath, KU32 fFlags, 2592 2618 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor) 2593 2619 { … … 2609 2635 offEnd = 2; 2610 2636 kHlpAssert(IS_SLASH(pszPath[2])); 2611 pRoot = kFswCacheLookupDrive(pCache, toupper(pszPath[0]), penmError);2637 pRoot = kFswCacheLookupDrive(pCache, toupper(pszPath[0]), fFlags, penmError); 2612 2638 } 2613 2639 else if ( IS_SLASH(pszPath[0]) 2614 2640 && IS_SLASH(pszPath[1]) ) 2615 pRoot = kFswCacheLookupUncShareA(pCache, pszPath, &offEnd, penmError);2641 pRoot = kFswCacheLookupUncShareA(pCache, pszPath, fFlags, &offEnd, penmError); 2616 2642 else 2617 2643 { … … 2640 2666 ? pCache->auGenerations[ pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 2641 2667 : pCache->auGenerationsMissing[pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) 2668 || (fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH) 2642 2669 || kFsCacheRefreshObj(pCache, pRoot, penmError)) 2643 2670 return kFsCacheObjRetainInternal(pRoot); … … 2661 2688 */ 2662 2689 return kFsCacheLookupRelativeToDirA(pCache, (PKFSDIR)pRoot, &pszPath[offEnd + cchSlashes], 2663 cchPath - offEnd - cchSlashes, penmError, ppLastAncestor);2690 cchPath - offEnd - cchSlashes, fFlags, penmError, ppLastAncestor); 2664 2691 } 2665 2692 … … 2677 2704 * @param pwszPath The path to walk. 2678 2705 * @param cwcPath The length of the path (in wchar_t's). 2706 * @param fFlags Lookup flags, KFSCACHE_LOOKUP_F_XXX. 2679 2707 * @param penmError Where to return details as to why the lookup 2680 2708 * failed. … … 2683 2711 * found problem. Optional. 2684 2712 */ 2685 static PKFSOBJ kFsCacheLookupAbsoluteW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 cwcPath, 2713 static PKFSOBJ kFsCacheLookupAbsoluteW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 cwcPath, KU32 fFlags, 2686 2714 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor) 2687 2715 { … … 2706 2734 offEnd = 2; 2707 2735 kHlpAssert(IS_SLASH(pwszPath[2])); 2708 pRoot = kFswCacheLookupDrive(pCache, toupper(pwszPath[0]), penmError);2736 pRoot = kFswCacheLookupDrive(pCache, toupper(pwszPath[0]), fFlags, penmError); 2709 2737 } 2710 2738 else if ( IS_SLASH(pwszPath[0]) 2711 2739 && IS_SLASH(pwszPath[1]) ) 2712 pRoot = kFswCacheLookupUncShareW(pCache, pwszPath, &offEnd, penmError);2740 pRoot = kFswCacheLookupUncShareW(pCache, pwszPath, fFlags, &offEnd, penmError); 2713 2741 else 2714 2742 { … … 2737 2765 ? pCache->auGenerations[ pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 2738 2766 : pCache->auGenerationsMissing[pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) 2767 || (fFlags & KFSCACHE_LOOKUP_F_NO_REFRESH) 2739 2768 || kFsCacheRefreshObj(pCache, pRoot, penmError)) 2740 2769 return kFsCacheObjRetainInternal(pRoot); … … 2758 2787 */ 2759 2788 return kFsCacheLookupRelativeToDirW(pCache, (PKFSDIR)pRoot, &pwszPath[offEnd + cwcSlashes], 2760 cwcPath - offEnd - cwcSlashes, penmError, ppLastAncestor);2789 cwcPath - offEnd - cwcSlashes, fFlags, penmError, ppLastAncestor); 2761 2790 } 2762 2791 … … 2772 2801 * @param pszPath The path. 2773 2802 * @param cchPath The length of the path. 2803 * @param fFlags Lookup flags, KFSCACHE_LOOKUP_F_XXX. 2774 2804 * @param penmError Where to return details as to why the lookup 2775 2805 * failed. … … 2778 2808 * found problem. Optional. 2779 2809 */ 2780 static PKFSOBJ kFsCacheLookupSlowA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath, 2810 static PKFSOBJ kFsCacheLookupSlowA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath, KU32 fFlags, 2781 2811 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor) 2782 2812 { … … 2790 2820 && cchFull < sizeof(szFull)) 2791 2821 { 2792 PKFSOBJ pFsObj;2793 2822 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); 2808 2824 } 2809 2825 … … 2825 2841 * @param pwszPath The path. 2826 2842 * @param cwcPath The length of the path (in wchar_t's). 2843 * @param fFlags Lookup flags, KFSCACHE_LOOKUP_F_XXX. 2827 2844 * @param penmError Where to return details as to why the lookup 2828 2845 * failed. … … 2831 2848 * found problem. Optional. 2832 2849 */ 2833 static PKFSOBJ kFsCacheLookupSlowW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 wcwPath, 2850 static PKFSOBJ kFsCacheLookupSlowW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 wcwPath, KU32 fFlags, 2834 2851 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor) 2835 2852 { … … 2843 2860 && cwcFull < KFSCACHE_CFG_MAX_PATH) 2844 2861 { 2845 PKFSOBJ pFsObj;2846 2862 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); 2861 2864 } 2862 2865 … … 2882 2885 { 2883 2886 if (pHashEntry->fAbsolute) 2884 pHashEntry->pFsObj = kFsCacheLookupAbsoluteA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 2887 pHashEntry->pFsObj = kFsCacheLookupAbsoluteA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 0 /*fFlags*/, 2885 2888 &pHashEntry->enmError, &pLastAncestor); 2886 2889 else 2887 pHashEntry->pFsObj = kFsCacheLookupSlowA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 2890 pHashEntry->pFsObj = kFsCacheLookupSlowA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 0 /*fFlags*/, 2888 2891 &pHashEntry->enmError, &pLastAncestor); 2889 2892 } … … 2900 2903 kFsCacheObjRelease(pCache, pHashEntry->pFsObj); 2901 2904 if (pHashEntry->fAbsolute) 2902 pHashEntry->pFsObj = kFsCacheLookupAbsoluteA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 2905 pHashEntry->pFsObj = kFsCacheLookupAbsoluteA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 0 /*fFlags*/, 2903 2906 &pHashEntry->enmError, &pLastAncestor); 2904 2907 else 2905 pHashEntry->pFsObj = kFsCacheLookupSlowA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 2908 pHashEntry->pFsObj = kFsCacheLookupSlowA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 0 /*fFlags*/, 2906 2909 &pHashEntry->enmError, &pLastAncestor); 2907 2910 } … … 2943 2946 { 2944 2947 if (pHashEntry->fAbsolute) 2945 pHashEntry->pFsObj = kFsCacheLookupAbsoluteW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 2948 pHashEntry->pFsObj = kFsCacheLookupAbsoluteW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 0 /*fFlags*/, 2946 2949 &pHashEntry->enmError, &pLastAncestor); 2947 2950 else 2948 pHashEntry->pFsObj = kFsCacheLookupSlowW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 2951 pHashEntry->pFsObj = kFsCacheLookupSlowW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 0 /*fFlags*/, 2949 2952 &pHashEntry->enmError, &pLastAncestor); 2950 2953 } … … 2961 2964 kFsCacheObjRelease(pCache, pHashEntry->pFsObj); 2962 2965 if (pHashEntry->fAbsolute) 2963 pHashEntry->pFsObj = kFsCacheLookupAbsoluteW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 2966 pHashEntry->pFsObj = kFsCacheLookupAbsoluteW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 0 /*fFlags*/, 2964 2967 &pHashEntry->enmError, &pLastAncestor); 2965 2968 else 2966 pHashEntry->pFsObj = kFsCacheLookupSlowW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 2969 pHashEntry->pFsObj = kFsCacheLookupSlowW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 0 /*fFlags*/, 2967 2970 &pHashEntry->enmError, &pLastAncestor); 2968 2971 } … … 3069 3072 && !kFsCacheHasDotDotA(pchPath, cchPath) ) 3070 3073 { 3071 pFsObj = kFsCacheLookupAbsoluteA(pCache, pchPath, cchPath, penmError, &pLastAncestor);3074 pFsObj = kFsCacheLookupAbsoluteA(pCache, pchPath, cchPath, 0 /*fFlags*/, penmError, &pLastAncestor); 3072 3075 fAbsolute = K_TRUE; 3073 3076 } 3074 3077 else 3075 3078 { 3076 pFsObj = kFsCacheLookupSlowA(pCache, pchPath, cchPath, penmError, &pLastAncestor);3079 pFsObj = kFsCacheLookupSlowA(pCache, pchPath, cchPath, 0 /*fFlags*/, penmError, &pLastAncestor); 3077 3080 fAbsolute = K_FALSE; 3078 3081 } … … 3177 3180 && !kFsCacheHasDotDotW(pwcPath, cwcPath) ) 3178 3181 { 3179 pFsObj = kFsCacheLookupAbsoluteW(pCache, pwcPath, cwcPath, penmError, &pLastAncestor);3182 pFsObj = kFsCacheLookupAbsoluteW(pCache, pwcPath, cwcPath, 0 /*fFlags*/, penmError, &pLastAncestor); 3180 3183 fAbsolute = K_TRUE; 3181 3184 } 3182 3185 else 3183 3186 { 3184 pFsObj = kFsCacheLookupSlowW(pCache, pwcPath, cwcPath, penmError, &pLastAncestor);3187 pFsObj = kFsCacheLookupSlowW(pCache, pwcPath, cwcPath, 0 /*fFlags*/, penmError, &pLastAncestor); 3185 3188 fAbsolute = K_FALSE; 3186 3189 } … … 3980 3983 return K_TRUE; 3981 3984 } 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 */ 3996 KBOOL 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)); 3982 4043 return K_FALSE; 3983 4044 }
Note:
See TracChangeset
for help on using the changeset viewer.