Changeset 2868 in kBuild
- Timestamp:
- Sep 4, 2016 1:28:12 AM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kWorker/kWorker.c
r2867 r2868 4716 4716 4717 4717 /* 4718 * Invalidate the missing cache entries. 4718 * Invalidate the volatile parts of cache (kBuild output directory, 4719 * temporary directory, whatever). 4719 4720 */ 4720 kFsCacheInvalidate Missing(g_pFsCache);4721 kFsCacheInvalidateCustomBoth(g_pFsCache); 4721 4722 return 0; 4722 4723 } … … 5234 5235 int main(int argc, char **argv) 5235 5236 { 5236 KSIZE cbMsgBuf = 0; 5237 KU8 *pbMsgBuf = NULL; 5238 int i; 5239 HANDLE hPipe = INVALID_HANDLE_VALUE; 5237 KSIZE cbMsgBuf = 0; 5238 KU8 *pbMsgBuf = NULL; 5239 int i; 5240 HANDLE hPipe = INVALID_HANDLE_VALUE; 5241 const char *pszTmp; 5242 KFSLOOKUPERROR enmIgnored; 5240 5243 5241 5244 /* 5242 * Create the cache .5245 * Create the cache and mark the temporary directory as using the custom revision. 5243 5246 */ 5244 5247 g_pFsCache = kFsCacheCreate(KFSCACHE_F_MISSING_OBJECTS | KFSCACHE_F_MISSING_PATHS); 5245 5248 if (!g_pFsCache) 5246 5249 return kwErrPrintfRc(3, "kFsCacheCreate failed!\n"); 5250 5251 pszTmp = getenv("TEMP"); 5252 if (pszTmp && *pszTmp != '\0') 5253 kFsCacheSetupCustomRevisionForTree(g_pFsCache, kFsCacheLookupA(g_pFsCache, pszTmp, &enmIgnored)); 5254 pszTmp = getenv("TMP"); 5255 if (pszTmp && *pszTmp != '\0') 5256 kFsCacheSetupCustomRevisionForTree(g_pFsCache, kFsCacheLookupA(g_pFsCache, pszTmp, &enmIgnored)); 5257 pszTmp = getenv("TMPDIR"); 5258 if (pszTmp && *pszTmp != '\0') 5259 kFsCacheSetupCustomRevisionForTree(g_pFsCache, kFsCacheLookupA(g_pFsCache, pszTmp, &enmIgnored)); 5247 5260 5248 5261 /* … … 5271 5284 return kwErrPrintfRc(2, "--pipe takes an argument!\n"); 5272 5285 } 5286 else if (strcmp(argv[i], "--volatile") == 0) 5287 { 5288 i++; 5289 if (i < argc) 5290 kFsCacheSetupCustomRevisionForTree(g_pFsCache, kFsCacheLookupA(g_pFsCache, argv[i], &enmIgnored)); 5291 else 5292 return kwErrPrintfRc(2, "--volatile takes an argument!\n"); 5293 } 5273 5294 else if (strcmp(argv[i], "--test") == 0) 5274 5295 return kwTestRun(argc - i - 1, &argv[i + 1]); … … 5277 5298 || strcmp(argv[i], "-?") == 0) 5278 5299 { 5279 printf("usage: kWorker --pipe <pipe-handle>\n"5300 printf("usage: kWorker [--volatile dir] --pipe <pipe-handle>\n" 5280 5301 "usage: kWorker <--help|-h>\n" 5281 5302 "usage: kWorker <--version|-V>\n" 5282 "usage: kWorker --test [<times> [--chdir <dir>]] -- args\n"5303 "usage: kWorker [--volatile dir] --test [<times> [--chdir <dir>]] -- args\n" 5283 5304 "\n" 5284 5305 "This is an internal kmk program that is used via the builtin_kSubmit.\n"); -
trunk/src/kmk/dir-nt-bird.c
r2862 r2868 114 114 { 115 115 PKFSOBJ pNameObj = kFsCacheLookupRelativeToDirA(g_pFsCache, (PKFSDIR)pDirObj, 116 pszName, strlen(pszName), &enmError );116 pszName, strlen(pszName), &enmError, NULL); 117 117 if (pNameObj) 118 118 { -
trunk/src/kmk/kmkbuiltin/kSubmit.c
r2858 r2868 307 307 size_t const cbExecutableBuf = GET_PATH_MAX; 308 308 PATH_VAR(szExecutable); 309 #define TUPLE(a_sz) a_sz, sizeof(a_sz) - 1 310 struct variable *pVarVolatile = lookup_variable(TUPLE("PATH_OUT")); 311 if (pVarVolatile) 312 { /* likely */ } 313 else 314 { 315 pVarVolatile = lookup_variable(TUPLE("PATH_OUT_BASE")); 316 if (!pVarVolatile) 317 warn("Neither PATH_OUT_BASE nor PATH_OUT was found."); 318 } 309 319 310 320 /* … … 373 383 { 374 384 char szHandleArg[32]; 375 const char *apszArgs[4] = { szExecutable, "--pipe", szHandleArg, NULL }; 385 const char *apszArgs[6] = 386 { 387 szExecutable, "--pipe", szHandleArg, 388 pVarVolatile ? "--volatile" : NULL, pVarVolatile ? pVarVolatile->value : NULL, 389 NULL 390 }; 376 391 _snprintf(szHandleArg, sizeof(szHandleArg), "%p", hWorkerPipe); 377 392 -
trunk/src/lib/nt/kFsCache.c
r2866 r2868 399 399 * @param fAbsolute Whether it can be refreshed using an absolute 400 400 * lookup or requires the slow treatment. 401 * @parma idxMissingGen The missing generation index. 401 402 * @param idxHashTab The hash table index of the path. 402 403 * @param enmError The lookup error. 403 404 */ 404 405 static PKFSHASHA kFsCacheCreatePathHashTabEntryA(PKFSCACHE pCache, PKFSOBJ pFsObj, const char *pszPath, KU32 cchPath, 405 KU32 uHashPath, KU32 idxHashTab, BOOL fAbsolute, KFSLOOKUPERROR enmError) 406 KU32 uHashPath, KU32 idxHashTab, BOOL fAbsolute, KU32 idxMissingGen, 407 KFSLOOKUPERROR enmError) 406 408 { 407 409 PKFSHASHA pHashEntry = (PKFSHASHA)kHlpAlloc(sizeof(*pHashEntry) + cchPath + 1); 408 410 if (pHashEntry) 409 411 { 410 pHashEntry->uHashPath = uHashPath; 411 pHashEntry->cchPath = (KU16)cchPath; 412 pHashEntry->fAbsolute = fAbsolute; 413 pHashEntry->pFsObj = pFsObj; 414 pHashEntry->enmError = enmError; 415 pHashEntry->pszPath = (const char *)kHlpMemCopy(pHashEntry + 1, pszPath, cchPath + 1); 412 pHashEntry->uHashPath = uHashPath; 413 pHashEntry->cchPath = (KU16)cchPath; 414 pHashEntry->fAbsolute = fAbsolute; 415 pHashEntry->idxMissingGen = (KU8)idxMissingGen; 416 pHashEntry->pFsObj = pFsObj; 417 pHashEntry->enmError = enmError; 418 pHashEntry->pszPath = (const char *)kHlpMemCopy(pHashEntry + 1, pszPath, cchPath + 1); 416 419 if (pFsObj) 417 pHashEntry->uCacheGen = pCache->uGeneration; 420 pHashEntry->uCacheGen = pFsObj->bObjType != KFSOBJ_TYPE_MISSING 421 ? pCache->auGenerations[ pFsObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 422 : pCache->auGenerationsMissing[pFsObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]; 418 423 else if (enmError != KFSLOOKUPERROR_UNSUPPORTED) 419 pHashEntry->uCacheGen = pCache-> uGenerationMissing;424 pHashEntry->uCacheGen = pCache->auGenerationsMissing[idxMissingGen]; 420 425 else 421 426 pHashEntry->uCacheGen = KFSOBJ_CACHE_GEN_IGNORE; … … 444 449 * @param fAbsolute Whether it can be refreshed using an absolute 445 450 * lookup or requires the slow treatment. 451 * @parma idxMissingGen The missing generation index. 446 452 * @param idxHashTab The hash table index of the path. 447 453 * @param enmError The lookup error. 448 454 */ 449 455 static PKFSHASHW kFsCacheCreatePathHashTabEntryW(PKFSCACHE pCache, PKFSOBJ pFsObj, const wchar_t *pwszPath, KU32 cwcPath, 450 KU32 uHashPath, KU32 idxHashTab, BOOL fAbsolute, KFSLOOKUPERROR enmError) 456 KU32 uHashPath, KU32 idxHashTab, BOOL fAbsolute, KU32 idxMissingGen, 457 KFSLOOKUPERROR enmError) 451 458 { 452 459 PKFSHASHW pHashEntry = (PKFSHASHW)kHlpAlloc(sizeof(*pHashEntry) + (cwcPath + 1) * sizeof(wchar_t)); 453 460 if (pHashEntry) 454 461 { 455 pHashEntry->uHashPath = uHashPath; 456 pHashEntry->cwcPath = cwcPath; 457 pHashEntry->fAbsolute = fAbsolute; 458 pHashEntry->pFsObj = pFsObj; 459 pHashEntry->enmError = enmError; 460 pHashEntry->pwszPath = (const wchar_t *)kHlpMemCopy(pHashEntry + 1, pwszPath, (cwcPath + 1) * sizeof(wchar_t)); 462 pHashEntry->uHashPath = uHashPath; 463 pHashEntry->cwcPath = cwcPath; 464 pHashEntry->fAbsolute = fAbsolute; 465 pHashEntry->idxMissingGen = (KU8)idxMissingGen; 466 pHashEntry->pFsObj = pFsObj; 467 pHashEntry->enmError = enmError; 468 pHashEntry->pwszPath = (const wchar_t *)kHlpMemCopy(pHashEntry + 1, pwszPath, (cwcPath + 1) * sizeof(wchar_t)); 461 469 if (pFsObj) 462 pHashEntry->uCacheGen = pCache->uGeneration; 470 pHashEntry->uCacheGen = pFsObj->bObjType != KFSOBJ_TYPE_MISSING 471 ? pCache->auGenerations[ pFsObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 472 : pCache->auGenerationsMissing[pFsObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]; 463 473 else if (enmError != KFSLOOKUPERROR_UNSUPPORTED) 464 pHashEntry->uCacheGen = pCache-> uGenerationMissing;474 pHashEntry->uCacheGen = pCache->auGenerationsMissing[idxMissingGen]; 465 475 else 466 476 pHashEntry->uCacheGen = KFSOBJ_CACHE_GEN_IGNORE; … … 555 565 pObj->u32Magic = KFSOBJ_MAGIC; 556 566 pObj->cRefs = 1; 557 pObj->uCacheGen = bObjType != KFSOBJ_TYPE_MISSING ? pCache->uGeneration : pCache->uGenerationMissing; 567 pObj->uCacheGen = bObjType != KFSOBJ_TYPE_MISSING 568 ? pCache->auGenerations[pParent->Obj.fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 569 : pCache->auGenerationsMissing[pParent->Obj.fFlags & KFSOBJ_F_USE_CUSTOM_GEN]; 558 570 pObj->bObjType = bObjType; 559 571 pObj->fHaveStats = K_FALSE; 560 572 pObj->abUnused[0] = K_FALSE; 561 573 pObj->abUnused[1] = K_FALSE; 562 pObj->fFlags = pParent->Obj.fFlags ;574 pObj->fFlags = pParent->Obj.fFlags & KFSOBJ_F_INHERITED_MASK; 563 575 pObj->pParent = pParent; 564 576 pObj->pUserDataHead = NULL; … … 1502 1514 pDir->fNeedRePopulating = K_FALSE; 1503 1515 if (pDir->Obj.uCacheGen != KFSOBJ_CACHE_GEN_IGNORE) 1504 pDir->Obj.uCacheGen = pCache-> uGeneration;1516 pDir->Obj.uCacheGen = pCache->auGenerations[pDir->Obj.fFlags & KFSOBJ_F_USE_CUSTOM_GEN]; 1505 1517 return K_TRUE; 1506 1518 } … … 1544 1556 && !pDir->fNeedRePopulating 1545 1557 && ( pDir->Obj.uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 1546 || pDir->Obj.uCacheGen == pCache-> uGeneration) )1558 || pDir->Obj.uCacheGen == pCache->auGenerations[pDir->Obj.fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) ) 1547 1559 return K_TRUE; 1548 1560 return kFsCachePopuplateOrRefreshDir(pCache, pDir, penmError ? penmError : &enmIgnored); … … 1590 1602 { 1591 1603 KFSCACHE_LOG(("Parent of missing not written to %s/%s\n", pMissing->pParent->Obj.pszName, pMissing->pszName)); 1592 pMissing->uCacheGen = pCache-> uGenerationMissing;1604 pMissing->uCacheGen = pCache->auGenerationsMissing[pMissing->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]; 1593 1605 } 1594 1606 else … … 1612 1624 * Probably more likely that a missing node stays missing. 1613 1625 */ 1614 pMissing->uCacheGen = pCache-> uGenerationMissing;1626 pMissing->uCacheGen = pCache->auGenerationsMissing[pMissing->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]; 1615 1627 KFSCACHE_LOG(("Still missing %s/%s\n", pMissing->pParent->Obj.pszName, pMissing->pszName)); 1616 1628 } … … 1629 1641 pMissing->pParent->Obj.pszName, pMissing->pszName, bObjType, BasicInfo.FileAttributes)); 1630 1642 pMissing->bObjType = bObjType; 1631 pMissing->uCacheGen = pCache-> uGenerationMissing;1643 pMissing->uCacheGen = pCache->auGenerations[pMissing->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]; 1632 1644 /** 1633 1645 * @todo refresh missing object names when it appears. … … 1799 1811 if (MY_NT_SUCCESS(rcNt)) 1800 1812 { 1801 pObj->uCacheGen = pCache-> uGeneration;1813 pObj->uCacheGen = pCache->auGenerations[pObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]; 1802 1814 fRc = K_TRUE; 1803 1815 } … … 1858 1870 if (MY_NT_SUCCESS(rcNt)) 1859 1871 { 1860 pObj->uCacheGen = pCache-> uGeneration;1872 pObj->uCacheGen = pCache->auGenerations[pObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]; 1861 1873 fRc = K_TRUE; 1862 1874 } … … 2276 2288 * @param penmError Where to return details as to why the lookup 2277 2289 * failed. 2290 * @param ppLastAncestor Where to return the last parent element found 2291 * (referenced) in case of error an path/file not 2292 * found problem. Optional. 2278 2293 */ 2279 2294 PKFSOBJ kFsCacheLookupRelativeToDirA(PKFSCACHE pCache, PKFSDIR pParent, const char *pszPath, KU32 cchPath, 2280 KFSLOOKUPERROR *penmError )2295 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor) 2281 2296 { 2282 2297 /* … … 2284 2299 */ 2285 2300 KU32 off = 0; 2301 if (ppLastAncestor) 2302 *ppLastAncestor = NULL; 2286 2303 for (;;) 2287 2304 { … … 2312 2329 if ( pParent->fPopulated 2313 2330 && ( pParent->Obj.uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2314 || pParent->Obj.uCacheGen == pCache-> uGeneration) )2331 || pParent->Obj.uCacheGen == pCache->auGenerations[pParent->Obj.fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) ) 2315 2332 { /* likely */ } 2316 2333 else if (kFsCachePopuplateOrRefreshDir(pCache, pParent, penmError)) … … 2340 2357 else 2341 2358 *penmError = KFSLOOKUPERROR_PATH_COMP_NOT_FOUND; 2359 if (ppLastAncestor) 2360 *ppLastAncestor = kFsCacheObjRetainInternal(&pParent->Obj); 2342 2361 return NULL; 2343 2362 } … … 2350 2369 if ( pChild->bObjType != KFSOBJ_TYPE_MISSING 2351 2370 || pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2352 || pChild->uCacheGen == pCache-> uGenerationMissing2371 || pChild->uCacheGen == pCache->auGenerationsMissing[pChild->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 2353 2372 || kFsCacheRefreshMissing(pCache, pChild, penmError) ) 2354 2373 { /* likely */ } … … 2367 2386 { 2368 2387 *penmError = KFSLOOKUPERROR_PATH_COMP_NOT_DIR; 2388 if (ppLastAncestor) 2389 *ppLastAncestor = kFsCacheObjRetainInternal(&pParent->Obj); 2369 2390 return NULL; 2370 2391 } 2371 2392 else if ( pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2372 || pChild->uCacheGen == pCache-> uGenerationMissing)2393 || pChild->uCacheGen == pCache->auGenerationsMissing[pChild->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) 2373 2394 { 2374 2395 *penmError = KFSLOOKUPERROR_PATH_COMP_NOT_FOUND; 2396 if (ppLastAncestor) 2397 *ppLastAncestor = kFsCacheObjRetainInternal(&pParent->Obj); 2375 2398 return NULL; 2376 2399 } … … 2378 2401 pParent = (PKFSDIR)pChild; 2379 2402 else 2403 { 2404 if (ppLastAncestor) 2405 *ppLastAncestor = kFsCacheObjRetainInternal(&pParent->Obj); 2380 2406 return NULL; 2407 } 2381 2408 } 2382 2409 … … 2401 2428 * @param penmError Where to return details as to why the lookup 2402 2429 * failed. 2430 * @param ppLastAncestor Where to return the last parent element found 2431 * (referenced) in case of error an path/file not 2432 * found problem. Optional. 2403 2433 */ 2404 2434 PKFSOBJ kFsCacheLookupRelativeToDirW(PKFSCACHE pCache, PKFSDIR pParent, const wchar_t *pwszPath, KU32 cwcPath, 2405 KFSLOOKUPERROR *penmError )2435 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor) 2406 2436 { 2407 2437 /* … … 2409 2439 */ 2410 2440 KU32 off = 0; 2441 if (ppLastAncestor) 2442 *ppLastAncestor = NULL; 2411 2443 for (;;) 2412 2444 { … … 2437 2469 if ( pParent->fPopulated 2438 2470 && ( pParent->Obj.uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2439 || pParent->Obj.uCacheGen == pCache-> uGeneration) )2471 || pParent->Obj.uCacheGen == pCache->auGenerations[pParent->Obj.fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) ) 2440 2472 { /* likely */ } 2441 2473 else if (kFsCachePopuplateOrRefreshDir(pCache, pParent, penmError)) … … 2465 2497 else 2466 2498 *penmError = KFSLOOKUPERROR_PATH_COMP_NOT_FOUND; 2499 if (ppLastAncestor) 2500 *ppLastAncestor = kFsCacheObjRetainInternal(&pParent->Obj); 2467 2501 return NULL; 2468 2502 } … … 2475 2509 if ( pChild->bObjType != KFSOBJ_TYPE_MISSING 2476 2510 || pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2477 || pChild->uCacheGen == pCache-> uGenerationMissing2511 || pChild->uCacheGen == pCache->auGenerationsMissing[pChild->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 2478 2512 || kFsCacheRefreshMissing(pCache, pChild, penmError) ) 2479 2513 { /* likely */ } … … 2492 2526 { 2493 2527 *penmError = KFSLOOKUPERROR_PATH_COMP_NOT_DIR; 2528 if (ppLastAncestor) 2529 *ppLastAncestor = kFsCacheObjRetainInternal(&pParent->Obj); 2494 2530 return NULL; 2495 2531 } 2496 2532 else if ( pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2497 || pChild->uCacheGen == pCache-> uGenerationMissing)2533 || pChild->uCacheGen == pCache->auGenerationsMissing[pChild->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) 2498 2534 { 2499 2535 *penmError = KFSLOOKUPERROR_PATH_COMP_NOT_FOUND; 2536 if (ppLastAncestor) 2537 *ppLastAncestor = kFsCacheObjRetainInternal(&pParent->Obj); 2500 2538 return NULL; 2501 2539 } … … 2503 2541 pParent = (PKFSDIR)pChild; 2504 2542 else 2543 { 2544 if (ppLastAncestor) 2545 *ppLastAncestor = kFsCacheObjRetainInternal(&pParent->Obj); 2505 2546 return NULL; 2547 } 2506 2548 } 2507 2549 … … 2525 2567 * @param penmError Where to return details as to why the lookup 2526 2568 * failed. 2527 */ 2528 static PKFSOBJ kFsCacheLookupAbsoluteA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath, KFSLOOKUPERROR *penmError) 2529 { 2530 PKFSOBJ pChild; 2569 * @param ppLastAncestor Where to return the last parent element found 2570 * (referenced) in case of error an path/file not 2571 * found problem. Optional. 2572 */ 2573 static PKFSOBJ kFsCacheLookupAbsoluteA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath, 2574 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor) 2575 { 2576 PKFSOBJ pRoot; 2531 2577 KU32 cchSlashes; 2532 2578 KU32 offEnd; … … 2545 2591 offEnd = 2; 2546 2592 kHlpAssert(IS_SLASH(pszPath[2])); 2547 p Child= kFswCacheLookupDrive(pCache, toupper(pszPath[0]), penmError);2593 pRoot = kFswCacheLookupDrive(pCache, toupper(pszPath[0]), penmError); 2548 2594 } 2549 2595 else if ( IS_SLASH(pszPath[0]) 2550 2596 && IS_SLASH(pszPath[1]) ) 2551 p Child= kFswCacheLookupUncShareA(pCache, pszPath, &offEnd, penmError);2597 pRoot = kFswCacheLookupUncShareA(pCache, pszPath, &offEnd, penmError); 2552 2598 else 2553 2599 { … … 2555 2601 return NULL; 2556 2602 } 2557 if (p Child)2603 if (pRoot) 2558 2604 { /* likely */ } 2559 2605 else … … 2572 2618 if (offEnd >= cchPath) 2573 2619 { 2574 if ( pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2575 || pChild->uCacheGen == (pChild->bObjType != KFSOBJ_TYPE_MISSING ? pCache->uGeneration : pCache->uGenerationMissing) 2576 || kFsCacheRefreshObj(pCache, pChild, penmError)) 2577 return kFsCacheObjRetainInternal(pChild); 2620 if ( pRoot->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2621 || pRoot->uCacheGen == ( pRoot->bObjType != KFSOBJ_TYPE_MISSING 2622 ? pCache->auGenerations[ pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 2623 : pCache->auGenerationsMissing[pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) 2624 || kFsCacheRefreshObj(pCache, pRoot, penmError)) 2625 return kFsCacheObjRetainInternal(pRoot); 2578 2626 return NULL; 2579 2627 } 2580 2628 2581 2629 /* Check that we've got a valid result and not a cached negative one. */ 2582 if (p Child->bObjType == KFSOBJ_TYPE_DIR)2630 if (pRoot->bObjType == KFSOBJ_TYPE_DIR) 2583 2631 { /* likely */ } 2584 2632 else 2585 2633 { 2586 kHlpAssert(pChild->bObjType == KFSOBJ_TYPE_MISSING); 2587 kHlpAssert(pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE || pChild->uCacheGen == pCache->uGenerationMissing); 2588 return pChild; 2634 kHlpAssert(pRoot->bObjType == KFSOBJ_TYPE_MISSING); 2635 kHlpAssert( pRoot->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2636 || pRoot->uCacheGen == pCache->auGenerationsMissing[pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]); 2637 return pRoot; 2589 2638 } 2590 2639 … … 2593 2642 * remainder of the path starting with it. 2594 2643 */ 2595 return kFsCacheLookupRelativeToDirA(pCache, (PKFSDIR)p Child, &pszPath[offEnd + cchSlashes],2596 cchPath - offEnd - cchSlashes, penmError );2644 return kFsCacheLookupRelativeToDirA(pCache, (PKFSDIR)pRoot, &pszPath[offEnd + cchSlashes], 2645 cchPath - offEnd - cchSlashes, penmError, ppLastAncestor); 2597 2646 } 2598 2647 … … 2612 2661 * @param penmError Where to return details as to why the lookup 2613 2662 * failed. 2614 */ 2615 static PKFSOBJ kFsCacheLookupAbsoluteW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 cwcPath, KFSLOOKUPERROR *penmError) 2663 * @param ppLastAncestor Where to return the last parent element found 2664 * (referenced) in case of error an path/file not 2665 * found problem. Optional. 2666 */ 2667 static PKFSOBJ kFsCacheLookupAbsoluteW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 cwcPath, 2668 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor) 2616 2669 { 2617 2670 PKFSDIR pParent = &pCache->RootDir; 2618 PKFSOBJ p Child;2671 PKFSOBJ pRoot; 2619 2672 KU32 off; 2620 2673 KU32 cwcSlashes; … … 2635 2688 offEnd = 2; 2636 2689 kHlpAssert(IS_SLASH(pwszPath[2])); 2637 p Child= kFswCacheLookupDrive(pCache, toupper(pwszPath[0]), penmError);2690 pRoot = kFswCacheLookupDrive(pCache, toupper(pwszPath[0]), penmError); 2638 2691 } 2639 2692 else if ( IS_SLASH(pwszPath[0]) 2640 2693 && IS_SLASH(pwszPath[1]) ) 2641 p Child= kFswCacheLookupUncShareW(pCache, pwszPath, &offEnd, penmError);2694 pRoot = kFswCacheLookupUncShareW(pCache, pwszPath, &offEnd, penmError); 2642 2695 else 2643 2696 { … … 2645 2698 return NULL; 2646 2699 } 2647 if (p Child)2700 if (pRoot) 2648 2701 { /* likely */ } 2649 2702 else … … 2662 2715 if (offEnd >= cwcPath) 2663 2716 { 2664 if ( pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2665 || pChild->uCacheGen == (pChild->bObjType != KFSOBJ_TYPE_MISSING ? pCache->uGeneration : pCache->uGenerationMissing) 2666 || kFsCacheRefreshObj(pCache, pChild, penmError)) 2667 return kFsCacheObjRetainInternal(pChild); 2717 if ( pRoot->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2718 || pRoot->uCacheGen == (pRoot->bObjType != KFSOBJ_TYPE_MISSING 2719 ? pCache->auGenerations[ pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 2720 : pCache->auGenerationsMissing[pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]) 2721 || kFsCacheRefreshObj(pCache, pRoot, penmError)) 2722 return kFsCacheObjRetainInternal(pRoot); 2668 2723 return NULL; 2669 2724 } 2670 2725 2671 2726 /* Check that we've got a valid result and not a cached negative one. */ 2672 if (p Child->bObjType == KFSOBJ_TYPE_DIR)2727 if (pRoot->bObjType == KFSOBJ_TYPE_DIR) 2673 2728 { /* likely */ } 2674 2729 else 2675 2730 { 2676 kHlpAssert(pChild->bObjType == KFSOBJ_TYPE_MISSING); 2677 kHlpAssert(pChild->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE || pChild->uCacheGen == pCache->uGenerationMissing); 2678 return pChild; 2731 kHlpAssert(pRoot->bObjType == KFSOBJ_TYPE_MISSING); 2732 kHlpAssert( pRoot->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2733 || pRoot->uCacheGen == pCache->auGenerationsMissing[pRoot->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]); 2734 return pRoot; 2679 2735 } 2680 2736 … … 2683 2739 * remainder of the path starting with it. 2684 2740 */ 2685 return kFsCacheLookupRelativeToDirW(pCache, (PKFSDIR)p Child, &pwszPath[offEnd + cwcSlashes],2686 cwcPath - offEnd - cwcSlashes, penmError );2741 return kFsCacheLookupRelativeToDirW(pCache, (PKFSDIR)pRoot, &pwszPath[offEnd + cwcSlashes], 2742 cwcPath - offEnd - cwcSlashes, penmError, ppLastAncestor); 2687 2743 } 2688 2744 … … 2700 2756 * @param penmError Where to return details as to why the lookup 2701 2757 * failed. 2702 */ 2703 static PKFSOBJ kFsCacheLookupSlowA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath, KFSLOOKUPERROR *penmError) 2758 * @param ppLastAncestor Where to return the last parent element found 2759 * (referenced) in case of error an path/file not 2760 * found problem. Optional. 2761 */ 2762 static PKFSOBJ kFsCacheLookupSlowA(PKFSCACHE pCache, const char *pszPath, KU32 cchPath, 2763 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor) 2704 2764 { 2705 2765 /* … … 2714 2774 PKFSOBJ pFsObj; 2715 2775 KFSCACHE_LOG2(("kFsCacheLookupSlowA(%s)\n", pszPath)); 2716 pFsObj = kFsCacheLookupAbsoluteA(pCache, szFull, cchFull, penmError );2776 pFsObj = kFsCacheLookupAbsoluteA(pCache, szFull, cchFull, penmError, ppLastAncestor); 2717 2777 2718 2778 #if 0 /* No need to do this until it's actually queried. */ … … 2749 2809 * @param penmError Where to return details as to why the lookup 2750 2810 * failed. 2751 */ 2752 static PKFSOBJ kFsCacheLookupSlowW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 wcwPath, KFSLOOKUPERROR *penmError) 2811 * @param ppLastAncestor Where to return the last parent element found 2812 * (referenced) in case of error an path/file not 2813 * found problem. Optional. 2814 */ 2815 static PKFSOBJ kFsCacheLookupSlowW(PKFSCACHE pCache, const wchar_t *pwszPath, KU32 wcwPath, 2816 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor) 2753 2817 { 2754 2818 /* … … 2763 2827 PKFSOBJ pFsObj; 2764 2828 KFSCACHE_LOG2(("kFsCacheLookupSlowA(%ls)\n", pwszPath)); 2765 pFsObj = kFsCacheLookupAbsoluteW(pCache, wszFull, cwcFull, penmError );2829 pFsObj = kFsCacheLookupAbsoluteW(pCache, wszFull, cwcFull, penmError, ppLastAncestor); 2766 2830 2767 2831 #if 0 /* No need to do this until it's actually queried. */ … … 2796 2860 static PKFSHASHA kFsCacheRefreshPathA(PKFSCACHE pCache, PKFSHASHA pHashEntry, KU32 idxHashTab) 2797 2861 { 2862 PKFSOBJ pLastAncestor = NULL; 2798 2863 if (!pHashEntry->pFsObj) 2799 2864 { 2800 2865 if (pHashEntry->fAbsolute) 2801 pHashEntry->pFsObj = kFsCacheLookupAbsoluteA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, &pHashEntry->enmError); 2866 pHashEntry->pFsObj = kFsCacheLookupAbsoluteA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 2867 &pHashEntry->enmError, &pLastAncestor); 2802 2868 else 2803 pHashEntry->pFsObj = kFsCacheLookupSlowA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, &pHashEntry->enmError); 2869 pHashEntry->pFsObj = kFsCacheLookupSlowA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 2870 &pHashEntry->enmError, &pLastAncestor); 2804 2871 } 2805 2872 else … … 2816 2883 if (pHashEntry->fAbsolute) 2817 2884 pHashEntry->pFsObj = kFsCacheLookupAbsoluteA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 2818 &pHashEntry->enmError );2885 &pHashEntry->enmError, &pLastAncestor); 2819 2886 else 2820 2887 pHashEntry->pFsObj = kFsCacheLookupSlowA(pCache, pHashEntry->pszPath, pHashEntry->cchPath, 2821 &pHashEntry->enmError );2888 &pHashEntry->enmError, &pLastAncestor); 2822 2889 } 2823 2890 } … … 2830 2897 } 2831 2898 } 2832 pHashEntry->uCacheGen = pCache->uGenerationMissing; 2899 2900 if (pLastAncestor && !pHashEntry->pFsObj) 2901 pHashEntry->idxMissingGen = pLastAncestor->fFlags & KFSOBJ_F_USE_CUSTOM_GEN; 2902 pHashEntry->uCacheGen = !pHashEntry->pFsObj 2903 ? pCache->auGenerationsMissing[pHashEntry->idxMissingGen] 2904 : pHashEntry->pFsObj->bObjType == KFSOBJ_TYPE_MISSING 2905 ? pCache->auGenerationsMissing[pHashEntry->pFsObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 2906 : pCache->auGenerations[ pHashEntry->pFsObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]; 2907 if (pLastAncestor) 2908 kFsCacheObjRelease(pCache, pLastAncestor); 2833 2909 return pHashEntry; 2834 2910 } … … 2845 2921 static PKFSHASHW kFsCacheRefreshPathW(PKFSCACHE pCache, PKFSHASHW pHashEntry, KU32 idxHashTab) 2846 2922 { 2923 PKFSOBJ pLastAncestor = NULL; 2847 2924 if (!pHashEntry->pFsObj) 2848 2925 { 2849 2926 if (pHashEntry->fAbsolute) 2850 pHashEntry->pFsObj = kFsCacheLookupAbsoluteW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, &pHashEntry->enmError); 2927 pHashEntry->pFsObj = kFsCacheLookupAbsoluteW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 2928 &pHashEntry->enmError, &pLastAncestor); 2851 2929 else 2852 pHashEntry->pFsObj = kFsCacheLookupSlowW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, &pHashEntry->enmError); 2930 pHashEntry->pFsObj = kFsCacheLookupSlowW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 2931 &pHashEntry->enmError, &pLastAncestor); 2853 2932 } 2854 2933 else … … 2865 2944 if (pHashEntry->fAbsolute) 2866 2945 pHashEntry->pFsObj = kFsCacheLookupAbsoluteW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 2867 &pHashEntry->enmError );2946 &pHashEntry->enmError, &pLastAncestor); 2868 2947 else 2869 2948 pHashEntry->pFsObj = kFsCacheLookupSlowW(pCache, pHashEntry->pwszPath, pHashEntry->cwcPath, 2870 &pHashEntry->enmError );2949 &pHashEntry->enmError, &pLastAncestor); 2871 2950 } 2872 2951 } … … 2879 2958 } 2880 2959 } 2881 pHashEntry->uCacheGen = pCache->uGenerationMissing; 2960 if (pLastAncestor && !pHashEntry->pFsObj) 2961 pHashEntry->idxMissingGen = pLastAncestor->fFlags & KFSOBJ_F_USE_CUSTOM_GEN; 2962 pHashEntry->uCacheGen = !pHashEntry->pFsObj 2963 ? pCache->auGenerationsMissing[pHashEntry->idxMissingGen] 2964 : pHashEntry->pFsObj->bObjType == KFSOBJ_TYPE_MISSING 2965 ? pCache->auGenerationsMissing[pHashEntry->pFsObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 2966 : pCache->auGenerations[ pHashEntry->pFsObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN]; 2967 if (pLastAncestor) 2968 kFsCacheObjRelease(pCache, pLastAncestor); 2882 2969 return pHashEntry; 2883 2970 } … … 2922 3009 && kHlpMemComp(pHashEntry->pszPath, pchPath, cchPath) == 0) 2923 3010 { 3011 PKFSOBJ pFsObj; 2924 3012 if ( pHashEntry->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 2925 || pHashEntry->uCacheGen == (pHashEntry->pFsObj ? pCache->uGeneration : pCache->uGenerationMissing) 3013 || pHashEntry->uCacheGen == ( (pFsObj = pHashEntry->pFsObj) != NULL 3014 ? pFsObj->bObjType != KFSOBJ_TYPE_MISSING 3015 ? pCache->auGenerations[ pFsObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 3016 : pCache->auGenerationsMissing[pFsObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 3017 : pCache->auGenerationsMissing[pHashEntry->idxMissingGen]) 2926 3018 || (pHashEntry = kFsCacheRefreshPathA(pCache, pHashEntry, idxHashTab)) ) 2927 3019 { … … 2948 3040 PKFSOBJ pFsObj; 2949 3041 KBOOL fAbsolute; 3042 PKFSOBJ pLastAncestor = NULL; 2950 3043 2951 3044 /* Is absolute without any '..' bits? */ … … 2958 3051 && !kFsCacheHasDotDotA(pchPath, cchPath) ) 2959 3052 { 2960 pFsObj = kFsCacheLookupAbsoluteA(pCache, pchPath, cchPath, penmError );3053 pFsObj = kFsCacheLookupAbsoluteA(pCache, pchPath, cchPath, penmError, &pLastAncestor); 2961 3054 fAbsolute = K_TRUE; 2962 3055 } 2963 3056 else 2964 3057 { 2965 pFsObj = kFsCacheLookupSlowA(pCache, pchPath, cchPath, penmError );3058 pFsObj = kFsCacheLookupSlowA(pCache, pchPath, cchPath, penmError, &pLastAncestor); 2966 3059 fAbsolute = K_FALSE; 2967 3060 } … … 2970 3063 && *penmError != KFSLOOKUPERROR_PATH_TOO_LONG) 2971 3064 || *penmError == KFSLOOKUPERROR_UNSUPPORTED ) 2972 kFsCacheCreatePathHashTabEntryA(pCache, pFsObj, pchPath, cchPath, uHashPath, idxHashTab, fAbsolute, *penmError); 3065 kFsCacheCreatePathHashTabEntryA(pCache, pFsObj, pchPath, cchPath, uHashPath, idxHashTab, fAbsolute, 3066 pLastAncestor ? pLastAncestor->bObjType & KFSOBJ_F_USE_CUSTOM_GEN : 0, *penmError); 3067 if (pLastAncestor) 3068 kFsCacheObjRelease(pCache, pLastAncestor); 2973 3069 2974 3070 pCache->cLookups++; … … 3021 3117 && kHlpMemComp(pHashEntry->pwszPath, pwcPath, cwcPath) == 0) 3022 3118 { 3119 PKFSOBJ pFsObj; 3023 3120 if ( pHashEntry->uCacheGen == KFSOBJ_CACHE_GEN_IGNORE 3024 || pHashEntry->uCacheGen == (pHashEntry->pFsObj ? pCache->uGeneration : pCache->uGenerationMissing) 3121 || pHashEntry->uCacheGen == ((pFsObj = pHashEntry->pFsObj) != NULL 3122 ? pFsObj->bObjType != KFSOBJ_TYPE_MISSING 3123 ? pCache->auGenerations[ pFsObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 3124 : pCache->auGenerationsMissing[pFsObj->fFlags & KFSOBJ_F_USE_CUSTOM_GEN] 3125 : pCache->auGenerationsMissing[pHashEntry->idxMissingGen]) 3025 3126 || (pHashEntry = kFsCacheRefreshPathW(pCache, pHashEntry, idxHashTab)) ) 3026 3127 { … … 3047 3148 PKFSOBJ pFsObj; 3048 3149 KBOOL fAbsolute; 3150 PKFSOBJ pLastAncestor = NULL; 3049 3151 3050 3152 /* Is absolute without any '..' bits? */ … … 3057 3159 && !kFsCacheHasDotDotW(pwcPath, cwcPath) ) 3058 3160 { 3059 pFsObj = kFsCacheLookupAbsoluteW(pCache, pwcPath, cwcPath, penmError );3161 pFsObj = kFsCacheLookupAbsoluteW(pCache, pwcPath, cwcPath, penmError, &pLastAncestor); 3060 3162 fAbsolute = K_TRUE; 3061 3163 } 3062 3164 else 3063 3165 { 3064 pFsObj = kFsCacheLookupSlowW(pCache, pwcPath, cwcPath, penmError );3166 pFsObj = kFsCacheLookupSlowW(pCache, pwcPath, cwcPath, penmError, &pLastAncestor); 3065 3167 fAbsolute = K_FALSE; 3066 3168 } … … 3069 3171 && *penmError != KFSLOOKUPERROR_PATH_TOO_LONG) 3070 3172 || *penmError == KFSLOOKUPERROR_UNSUPPORTED ) 3071 kFsCacheCreatePathHashTabEntryW(pCache, pFsObj, pwcPath, cwcPath, uHashPath, idxHashTab, fAbsolute, *penmError); 3173 kFsCacheCreatePathHashTabEntryW(pCache, pFsObj, pwcPath, cwcPath, uHashPath, idxHashTab, fAbsolute, 3174 pLastAncestor ? pLastAncestor->bObjType & KFSOBJ_F_USE_CUSTOM_GEN : 0, *penmError); 3175 if (pLastAncestor) 3176 kFsCacheObjRelease(pCache, pLastAncestor); 3072 3177 3073 3178 pCache->cLookups++; … … 3739 3844 { 3740 3845 kHlpAssert(pCache->u32Magic == KFSOBJ_MAGIC); 3741 pCache-> uGenerationMissing++;3846 pCache->auGenerationsMissing[0]++; 3742 3847 kHlpAssert(pCache->uGenerationMissing < KU32_MAX); 3743 KFSCACHE_LOG(("Invalidate missing %#x\n", pCache-> uGenerationMissing));3744 } 3745 3746 3747 /** 3748 * Invalidate all cache entries of missing files.3848 KFSCACHE_LOG(("Invalidate missing %#x\n", pCache->auGenerationsMissing[0])); 3849 } 3850 3851 3852 /** 3853 * Invalidate all cache entries (regular, custom & missing). 3749 3854 * 3750 3855 * @param pCache The cache. … … 3753 3858 { 3754 3859 kHlpAssert(pCache->u32Magic == KFSOBJ_MAGIC); 3755 pCache->uGenerationMissing++; 3756 kHlpAssert(pCache->uGenerationMissing < KU32_MAX); 3757 pCache->uGeneration++; 3758 kHlpAssert(pCache->uGeneration < KU32_MAX); 3759 KFSCACHE_LOG(("Invalidate all %#x/%#x\n", pCache->uGenerationMissing, pCache->uGeneration)); 3760 3761 } 3762 3860 3861 pCache->auGenerationsMissing[0]++; 3862 kHlpAssert(pCache->auGenerationsMissing[0] < KU32_MAX); 3863 pCache->auGenerationsMissing[1]++; 3864 kHlpAssert(pCache->auGenerationsMissing[1] < KU32_MAX); 3865 3866 pCache->auGenerations[0]++; 3867 kHlpAssert(pCache->auGenerations[0] < KU32_MAX); 3868 pCache->auGenerations[1]++; 3869 kHlpAssert(pCache->auGenerations[1] < KU32_MAX); 3870 3871 KFSCACHE_LOG(("Invalidate all - default: %#x/%#x, custom: %#x/%#x\n", 3872 pCache->auGenerationsMissing[0], pCache->auGenerations[0], 3873 pCache->auGenerationsMissing[1], pCache->auGenerations[1])); 3874 } 3875 3876 3877 /** 3878 * Invalidate all cache entries with custom generation handling set. 3879 * 3880 * @see kFsCacheSetupCustomRevisionForTree, KFSOBJ_F_USE_CUSTOM_GEN 3881 * @param pCache The cache. 3882 */ 3883 void kFsCacheInvalidateCustomMissing(PKFSCACHE pCache) 3884 { 3885 kHlpAssert(pCache->u32Magic == KFSOBJ_MAGIC); 3886 pCache->auGenerationsMissing[1]++; 3887 kHlpAssert(pCache->auGenerationsMissing[1] < KU32_MAX); 3888 KFSCACHE_LOG(("Invalidate missing custom %#x\n", pCache->auGenerationsMissing[1])); 3889 } 3890 3891 3892 /** 3893 * Invalidate all cache entries with custom generation handling set, both 3894 * missing and regular present entries. 3895 * 3896 * @see kFsCacheSetupCustomRevisionForTree, KFSOBJ_F_USE_CUSTOM_GEN 3897 * @param pCache The cache. 3898 */ 3899 void kFsCacheInvalidateCustomBoth(PKFSCACHE pCache) 3900 { 3901 kHlpAssert(pCache->u32Magic == KFSOBJ_MAGIC); 3902 pCache->auGenerations[1]++; 3903 kHlpAssert(pCache->auGenerations[1] < KU32_MAX); 3904 pCache->auGenerationsMissing[1]++; 3905 kHlpAssert(pCache->auGenerationsMissing[1] < KU32_MAX); 3906 KFSCACHE_LOG(("Invalidate both custom %#x/%#x\n", pCache->auGenerationsMissing[1], pCache->auGenerations[1])); 3907 } 3908 3909 3910 3911 /** 3912 * Applies the given flags to all the objects in a tree. 3913 * 3914 * @param pRoot Where to start applying the flag changes. 3915 * @param fAndMask The AND mask. 3916 * @param fOrMask The OR mask. 3917 */ 3918 static void kFsCacheApplyFlagsToTree(PKFSDIR pRoot, KU32 fAndMask, KU32 fOrMask) 3919 { 3920 PKFSOBJ *ppCur = ((PKFSDIR)pRoot)->papChildren; 3921 KU32 cLeft = ((PKFSDIR)pRoot)->cChildren; 3922 while (cLeft-- > 0) 3923 { 3924 PKFSOBJ pCur = *ppCur++; 3925 if (pCur->bObjType != KFSOBJ_TYPE_DIR) 3926 pCur->fFlags = (fAndMask & pCur->fFlags) | fOrMask; 3927 else 3928 kFsCacheApplyFlagsToTree((PKFSDIR)pCur, fAndMask, fOrMask); 3929 } 3930 3931 pRoot->Obj.fFlags = (fAndMask & pRoot->Obj.fFlags) | fOrMask; 3932 } 3933 3934 3935 /** 3936 * Sets up using custom revisioning for the specified directory tree or file. 3937 * 3938 * There are some restrictions of the current implementation: 3939 * - If the root of the sub-tree is ever deleted from the cache (i.e. 3940 * deleted in real life and reflected in the cache), the setting is lost. 3941 * - It is not automatically applied to the lookup paths caches. 3942 * 3943 * @returns K_TRUE on success, K_FALSE on failure. 3944 * @param pCache The cache. 3945 * @param pRoot The root of the subtree. A non-directory is 3946 * fine, like a missing node. 3947 */ 3948 KBOOL kFsCacheSetupCustomRevisionForTree(PKFSCACHE pCache, PKFSOBJ pRoot) 3949 { 3950 if (pRoot) 3951 { 3952 if (pRoot->bObjType == KFSOBJ_TYPE_DIR) 3953 kFsCacheApplyFlagsToTree((PKFSDIR)pRoot, KU32_MAX, KFSOBJ_F_USE_CUSTOM_GEN); 3954 else 3955 pRoot->fFlags |= KFSOBJ_F_USE_CUSTOM_GEN; 3956 return K_TRUE; 3957 } 3958 return K_FALSE; 3959 } 3763 3960 3764 3961 … … 3809 4006 pCache->u32Magic = KFSCACHE_MAGIC; 3810 4007 pCache->fFlags = fFlags; 3811 pCache->uGeneration = KU32_MAX / 2; 3812 pCache->uGenerationMissing = 1; 4008 pCache->auGenerations[0] = KU32_MAX / 4; 4009 pCache->auGenerations[1] = KU32_MAX / 32; 4010 pCache->auGenerationsMissing[0] = KU32_MAX / 256; 4011 pCache->auGenerationsMissing[1] = 1; 3813 4012 pCache->cObjects = 1; 3814 4013 pCache->cbObjects = sizeof(pCache->RootDir) + pCache->RootDir.cHashTab * sizeof(pCache->RootDir.paHashTab[0]); -
trunk/src/lib/nt/kFsCache.h
r2863 r2868 80 80 /** @name KFSOBJ_F_XXX - KFSOBJ::fFlags 81 81 * @{ */ 82 /** Use custom generation. 83 * @remarks This is given the value 1, as we use it as an index into 84 * KFSCACHE::auGenerations, 0 being the default. */ 85 #define KFSOBJ_F_USE_CUSTOM_GEN KU32_C(0x00000001) 86 82 87 /** Whether the file system update the modified timestamp of directories 83 88 * when something is removed from it or added to it. 84 89 * @remarks They say NTFS is the only windows filesystem doing this. */ 85 #define KFSOBJ_F_WORKING_DIR_MTIME KU32_C(0x0000000 1)90 #define KFSOBJ_F_WORKING_DIR_MTIME KU32_C(0x00000002) 86 91 /** NTFS file system volume. */ 87 92 #define KFSOBJ_F_NTFS KU32_C(0x80000000) 93 /** Flags that are automatically inherited. */ 94 #define KFSOBJ_F_INHERITED_MASK KU32_C(0xffffffff) 88 95 /** @} */ 89 96 … … 304 311 /** Set if aboslute path. */ 305 312 KBOOL fAbsolute; 313 /** Index into KFSCACHE:auGenerationsMissing when pFsObj is NULL. */ 314 KU8 idxMissingGen; 306 315 /** The cache generation ID. */ 307 316 KU32 uCacheGen; … … 333 342 /** Set if aboslute path. */ 334 343 KBOOL fAbsolute; 344 /** Index into KFSCACHE:auGenerationsMissing when pFsObj is NULL. */ 345 KU8 idxMissingGen; 335 346 /** The cache generation ID. */ 336 347 KU32 uCacheGen; … … 365 376 KU32 fFlags; 366 377 367 /** The current cache generation for objects that already exists. */ 368 KU32 uGeneration; 369 /** The current cache generation for missing objects, negative results, ++. */ 370 KU32 uGenerationMissing; 378 /** The default and custom cache generations for stuff that exists, indexed by 379 * KFSOBJ_F_USE_CUSTOM_GEN. 380 * 381 * The custom generation can be used to invalidate parts of the file system that 382 * are known to be volatile without triggering refreshing of the more static 383 * parts. Like the 'out' directory in a kBuild setup or a 'TEMP' directory are 384 * expected to change and you need to invalidate the caching of these frequently 385 * to stay on top of things. Whereas the sources, headers, compilers, sdk, 386 * ddks, windows directory and such generally doesn't change all that often. 387 */ 388 KU32 auGenerations[2]; 389 /** The current cache generation for missing objects, negative results, ++. 390 * This comes with a custom variant too. Indexed by KFSOBJ_F_USE_CUSTOM_GEN. */ 391 KU32 auGenerationsMissing[2]; 371 392 372 393 /** Number of cache objects. */ … … 437 458 PKFSOBJ kFsCacheLookupW(PKFSCACHE pCache, const wchar_t *pwszPath, KFSLOOKUPERROR *penmError); 438 459 PKFSOBJ kFsCacheLookupRelativeToDirA(PKFSCACHE pCache, PKFSDIR pParent, const char *pszPath, KU32 cchPath, 439 KFSLOOKUPERROR *penmError );460 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor); 440 461 PKFSOBJ kFsCacheLookupRelativeToDirW(PKFSCACHE pCache, PKFSDIR pParent, const wchar_t *pwszPath, KU32 cwcPath, 441 KFSLOOKUPERROR *penmError );462 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor); 442 463 PKFSOBJ kFsCacheLookupWithLengthA(PKFSCACHE pCache, const char *pchPath, KSIZE cchPath, KFSLOOKUPERROR *penmError); 443 464 PKFSOBJ kFsCacheLookupWithLengthW(PKFSCACHE pCache, const wchar_t *pwcPath, KSIZE cwcPath, KFSLOOKUPERROR *penmError); … … 459 480 PKFSCACHE kFsCacheCreate(KU32 fFlags); 460 481 void kFsCacheDestroy(PKFSCACHE); 461 void kFsCacheInvalidateMissing(PKFSCACHE pFsCache); 462 void kFsCacheInvalidateAll(PKFSCACHE pFsCache); 463 464 #endif 482 void kFsCacheInvalidateMissing(PKFSCACHE pCache); 483 void kFsCacheInvalidateAll(PKFSCACHE pCache); 484 void kFsCacheInvalidateCustomMissing(PKFSCACHE pCache); 485 void kFsCacheInvalidateCustomBoth(PKFSCACHE pCache); 486 KBOOL kFsCacheSetupCustomRevisionForTree(PKFSCACHE pCache, PKFSOBJ pRoot); 487 488 #endif
Note:
See TracChangeset
for help on using the changeset viewer.