Changeset 3167 for trunk/src/kmk/dir-nt-bird.c
- Timestamp:
- Mar 20, 2018, 10:47:25 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/dir-nt-bird.c
r3140 r3167 38 38 # include <glob.h> 39 39 #endif 40 40 #include <assert.h> 41 41 42 42 #include "nt_fullpath.h" /* for the time being - will be implemented here later on. */ … … 80 80 * from the sources. */ 81 81 static KBOOL g_fFsCacheIsUsingCustomRevision = K_FALSE; 82 /** The ID of the main thread. We currently only let it access the cache. */ 83 static DWORD g_idMainThread = 0; 82 84 83 85 84 86 void hash_init_directories(void) 85 87 { 88 g_idMainThread = GetCurrentThreadId(); 86 89 g_pFsCache = kFsCacheCreate(0); 87 90 if (g_pFsCache) … … 110 113 KFSLOOKUPERROR enmError; 111 114 PKFSOBJ pDirObj = kFsCacheLookupA(g_pFsCache, pszDir, &enmError); 115 assert(GetCurrentThreadId() == g_idMainThread); 112 116 if (pDirObj) 113 117 { 118 114 119 if (pDirObj->bObjType == KFSOBJ_TYPE_DIR) 115 120 { … … 145 150 int file_exists_p(const char *pszPath) 146 151 { 152 int fRc; 153 if (GetCurrentThreadId() == g_idMainThread) 154 { 155 KFSLOOKUPERROR enmError; 156 PKFSOBJ pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError); 157 if (pPathObj) 158 { 159 fRc = pPathObj->bObjType != KFSOBJ_TYPE_MISSING; 160 kFsCacheObjRelease(g_pFsCache, pPathObj); 161 } 162 else 163 fRc = 0; 164 } 165 else 166 fRc = GetFileAttributesA(pszPath) != INVALID_FILE_ATTRIBUTES; 167 return fRc; 168 } 169 170 171 /** 172 * Just a way for vpath.c to get a correctly cased path, I think. 173 * 174 * @returns Directory path in string cache. 175 * @param pszDir The directory. 176 */ 177 const char *dir_name(const char *pszDir) 178 { 179 char szTmp[MAX_PATH]; 180 assert(GetCurrentThreadId() == g_idMainThread); 181 nt_fullpath(pszDir, szTmp, sizeof(szTmp)); 182 return strcache_add(szTmp); 183 } 184 185 186 /** 187 * Makes future file_impossible_p calls return 1 for pszPath. 188 */ 189 void file_impossible(const char *pszPath) 190 { 191 KFSLOOKUPERROR enmError; 192 PKFSOBJ pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError); 193 assert(GetCurrentThreadId() == g_idMainThread); 194 if (pPathObj) 195 { 196 kFsCacheObjAddUserData(g_pFsCache, pPathObj, KMK_DIR_NT_IMPOSSIBLE_KEY, sizeof(KFSUSERDATA)); 197 kFsCacheObjRelease(g_pFsCache, pPathObj); 198 } 199 } 200 201 /** 202 * Makes future file_impossible_p calls return 1 for pszPath. 203 */ 204 int file_impossible_p(const char *pszPath) 205 { 147 206 int fRc; 148 207 KFSLOOKUPERROR enmError; 149 208 PKFSOBJ pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError); 209 assert(GetCurrentThreadId() == g_idMainThread); 150 210 if (pPathObj) 151 211 { 152 fRc = pPathObj->bObjType != KFSOBJ_TYPE_MISSING;212 fRc = kFsCacheObjGetUserData(g_pFsCache, pPathObj, KMK_DIR_NT_IMPOSSIBLE_KEY) != NULL; 153 213 kFsCacheObjRelease(g_pFsCache, pPathObj); 154 214 } … … 160 220 161 221 /** 162 * Just a way for vpath.c to get a correctly cased path, I think.163 *164 * @returns Directory path in string cache.165 * @param pszDir The directory.166 */167 const char *dir_name(const char *pszDir)168 {169 char szTmp[MAX_PATH];170 nt_fullpath(pszDir, szTmp, sizeof(szTmp));171 return strcache_add(szTmp);172 }173 174 175 /**176 * Makes future file_impossible_p calls return 1 for pszPath.177 */178 void file_impossible(const char *pszPath)179 {180 KFSLOOKUPERROR enmError;181 PKFSOBJ pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError);182 if (pPathObj)183 {184 kFsCacheObjAddUserData(g_pFsCache, pPathObj, KMK_DIR_NT_IMPOSSIBLE_KEY, sizeof(KFSUSERDATA));185 kFsCacheObjRelease(g_pFsCache, pPathObj);186 }187 }188 189 /**190 * Makes future file_impossible_p calls return 1 for pszPath.191 */192 int file_impossible_p(const char *pszPath)193 {194 int fRc;195 KFSLOOKUPERROR enmError;196 PKFSOBJ pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError);197 if (pPathObj)198 {199 fRc = kFsCacheObjGetUserData(g_pFsCache, pPathObj, KMK_DIR_NT_IMPOSSIBLE_KEY) != NULL;200 kFsCacheObjRelease(g_pFsCache, pPathObj);201 }202 else203 fRc = 0;204 return fRc;205 }206 207 208 /**209 222 * opendir for glob. 210 223 * … … 216 229 KFSLOOKUPERROR enmError; 217 230 PKFSOBJ pDirObj = kFsCacheLookupA(g_pFsCache, pszDir, &enmError); 231 assert(GetCurrentThreadId() == g_idMainThread); 218 232 if (pDirObj) 219 233 { … … 244 258 KMKNTOPENDIR *pDir = (KMKNTOPENDIR *)pvDir; 245 259 KU32 const cChildren = pDir->pDir->cChildren; 260 assert(GetCurrentThreadId() == g_idMainThread); 246 261 while (pDir->idxNext < cChildren) 247 262 { … … 307 322 { 308 323 KMKNTOPENDIR *pDir = (KMKNTOPENDIR *)pvDir; 324 assert(GetCurrentThreadId() == g_idMainThread); 309 325 kFsCacheObjRelease(g_pFsCache, &pDir->pDir->Obj); 310 326 pDir->pDir = NULL; … … 324 340 KFSLOOKUPERROR enmError; 325 341 PKFSOBJ pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError); 342 assert(GetCurrentThreadId() == g_idMainThread); 326 343 /** @todo follow symlinks vs. on symlink! */ 327 344 if (pPathObj) … … 352 369 KFSLOOKUPERROR enmError; 353 370 PKFSOBJ pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError); 371 assert(GetCurrentThreadId() == g_idMainThread); 354 372 if (pPathObj) 355 373 { … … 384 402 KFSLOOKUPERROR enmError; 385 403 PKFSOBJ pDirObj = kFsCacheLookupA(g_pFsCache, pszDir, &enmError); 404 assert(GetCurrentThreadId() == g_idMainThread); 386 405 if (pDirObj) 387 406 { … … 403 422 void dir_setup_glob(glob_t *pGlob) 404 423 { 424 assert(GetCurrentThreadId() == g_idMainThread); 405 425 pGlob->gl_opendir = dir_glob_opendir; 406 426 pGlob->gl_readdir = dir_glob_readdir; … … 465 485 KFSLOOKUPERROR enmError; 466 486 PKFSOBJ pPathObj = kFsCacheLookupA(g_pFsCache, pszPath, &enmError); 487 assert(GetCurrentThreadId() == g_idMainThread); 467 488 if (pPathObj) 468 489 { … … 558 579 /* Currently a little expensive, so just hit the file system once the 559 580 jobs starts comming in. */ 581 assert(GetCurrentThreadId() == g_idMainThread); 560 582 if (g_cInvalidates == 0) 561 583 { … … 589 611 void dir_cache_invalid_after_job(void) 590 612 { 613 assert(GetCurrentThreadId() == g_idMainThread); 591 614 g_cInvalidates++; 592 615 if (g_fFsCacheIsUsingCustomRevision) … … 603 626 void dir_cache_invalid_all(void) 604 627 { 628 assert(GetCurrentThreadId() == g_idMainThread); 605 629 g_cInvalidates++; 606 630 kFsCacheInvalidateAll(g_pFsCache); … … 614 638 void dir_cache_invalid_missing(void) 615 639 { 640 assert(GetCurrentThreadId() == g_idMainThread); 616 641 g_cInvalidates++; 617 642 kFsCacheInvalidateAll(g_pFsCache); … … 625 650 void dir_cache_invalid_volatile(void) 626 651 { 652 assert(GetCurrentThreadId() == g_idMainThread); 627 653 g_cInvalidates++; 628 654 if (g_fFsCacheIsUsingCustomRevision) … … 644 670 KFSLOOKUPERROR enmError; 645 671 PKFSOBJ pObj = kFsCacheLookupA(g_pFsCache, pszDir, &enmError); 672 assert(GetCurrentThreadId() == g_idMainThread); 646 673 if (pObj) 647 674 { … … 670 697 int dir_cache_deleted_directory(const char *pszDir) 671 698 { 699 assert(GetCurrentThreadId() == g_idMainThread); 672 700 if (kFsCacheInvalidateDeletedDirectoryA(g_pFsCache, pszDir)) 673 701 return 0; … … 678 706 int kmk_builtin_dircache(int argc, char **argv, char **envp) 679 707 { 708 assert(GetCurrentThreadId() == g_idMainThread); 680 709 if (argc >= 2) 681 710 {
Note:
See TracChangeset
for help on using the changeset viewer.