source: trunk/src/lib/nt/kFsCache.h

Last change on this file was 3381, checked in by bird, 5 years ago

kFsCache: Account of race between us reading a directory and someone changing it, requiring re-reading the directory till at least 10ms has passed since the last direction change.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 22.8 KB
RevLine 
[2831]1/* $Id: kFsCache.h 3381 2020-06-12 11:36:10Z bird $ */
2/** @file
[2853]3 * kFsCache.c - NT directory content cache.
[2831]4 */
5
6/*
7 * Copyright (c) 2016 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
8 *
[2851]9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
[2831]15 *
[2851]16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
[2831]18 *
[2851]19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * IN THE SOFTWARE.
[2831]26 *
[2851]27 * Alternatively, the content of this file may be used under the terms of the
28 * GPL version 2 or later, or LGPL version 2.1 or later.
[2831]29 */
30
[2853]31#ifndef ___lib_nt_kFsCache_h___
32#define ___lib_nt_kFsCache_h___
[2831]33
[2853]34
[2831]35#include <k/kHlp.h>
[2851]36#include "ntstat.h"
[2853]37#ifndef NDEBUG
38# include <stdarg.h>
39#endif
[2851]40
[2831]41
[2851]42/** @def KFSCACHE_CFG_UTF16
43 * Whether to compile in the UTF-16 names support. */
44#define KFSCACHE_CFG_UTF16 1
45/** @def KFSCACHE_CFG_SHORT_NAMES
46 * Whether to compile in the short name support. */
47#define KFSCACHE_CFG_SHORT_NAMES 1
48/** @def KFSCACHE_CFG_PATH_HASH_TAB_SIZE
49 * Size of the path hash table. */
[2930]50#define KFSCACHE_CFG_PATH_HASH_TAB_SIZE 99991
[2851]51/** The max length paths we consider. */
52#define KFSCACHE_CFG_MAX_PATH 1024
53/** The max ANSI name length. */
54#define KFSCACHE_CFG_MAX_ANSI_NAME (256*3 + 16)
55/** The max UTF-16 name length. */
56#define KFSCACHE_CFG_MAX_UTF16_NAME (256*2 + 16)
[3184]57/** Enables locking of the cache and thereby making it thread safe. */
58#define KFSCACHE_CFG_LOCKING 1
[2833]59
60
[2851]61
62/** Special KFSOBJ::uCacheGen number indicating that it does not apply. */
[2853]63#define KFSOBJ_CACHE_GEN_IGNORE KU32_MAX
[2851]64
[2833]65
[2851]66/** @name KFSOBJ_TYPE_XXX - KFSOBJ::bObjType
67 * @{ */
68/** Directory, type KFSDIR. */
69#define KFSOBJ_TYPE_DIR KU8_C(0x01)
70/** Regular file - type KFSOBJ. */
71#define KFSOBJ_TYPE_FILE KU8_C(0x02)
72/** Other file - type KFSOBJ. */
73#define KFSOBJ_TYPE_OTHER KU8_C(0x03)
74/** Caching of a negative result - type KFSOBJ.
75 * @remarks We will allocate enough space for the largest cache node, so this
76 * can metamorph into any other object should it actually turn up. */
77#define KFSOBJ_TYPE_MISSING KU8_C(0x04)
78///** Invalidated entry flag. */
79//#define KFSOBJ_TYPE_F_INVALID KU8_C(0x20)
80/** @} */
[2833]81
[2851]82/** @name KFSOBJ_F_XXX - KFSOBJ::fFlags
83 * @{ */
[2868]84 /** Use custom generation.
85 * @remarks This is given the value 1, as we use it as an index into
86 * KFSCACHE::auGenerations, 0 being the default. */
87#define KFSOBJ_F_USE_CUSTOM_GEN KU32_C(0x00000001)
88
[2851]89/** Whether the file system update the modified timestamp of directories
90 * when something is removed from it or added to it.
91 * @remarks They say NTFS is the only windows filesystem doing this. */
[2868]92#define KFSOBJ_F_WORKING_DIR_MTIME KU32_C(0x00000002)
[2851]93/** NTFS file system volume. */
94#define KFSOBJ_F_NTFS KU32_C(0x80000000)
[2868]95/** Flags that are automatically inherited. */
96#define KFSOBJ_F_INHERITED_MASK KU32_C(0xffffffff)
[2851]97/** @} */
[2833]98
[2834]99
[2851]100#define IS_ALPHA(ch) ( ((ch) >= 'A' && (ch) <= 'Z') || ((ch) >= 'a' && (ch) <= 'z') )
101#define IS_SLASH(ch) ((ch) == '\\' || (ch) == '/')
[2836]102
103
[2853]104
105
[2855]106/** Pointer to a cache. */
107typedef struct KFSCACHE *PKFSCACHE;
[2851]108/** Pointer to a core object. */
109typedef struct KFSOBJ *PKFSOBJ;
110/** Pointer to a directory object. */
111typedef struct KFSDIR *PKFSDIR;
112/** Pointer to a directory hash table entry. */
113typedef struct KFSOBJHASH *PKFSOBJHASH;
[2831]114
[2851]115
[2831]116
[2855]117/** Pointer to a user data item. */
118typedef struct KFSUSERDATA *PKFSUSERDATA;
[2851]119/**
[2855]120 * User data item associated with a cache node.
121 */
122typedef struct KFSUSERDATA
123{
124 /** Pointer to the next piece of user data. */
125 PKFSUSERDATA pNext;
126 /** The key identifying this user. */
127 KUPTR uKey;
128 /** The destructor. */
129 void (*pfnDestructor)(PKFSCACHE pCache, PKFSOBJ pObj, PKFSUSERDATA pData);
130} KFSUSERDATA;
131
132
133/**
[2967]134 * Storage for name strings for the unlikely event that they should grow in
135 * length after the KFSOBJ was created.
136 */
137typedef struct KFSOBJNAMEALLOC
138{
139 /** Size of the allocation. */
140 KU32 cb;
141 /** The space for names. */
142 char abSpace[1];
143} KFSOBJNAMEALLOC;
144/** Name growth allocation. */
145typedef KFSOBJNAMEALLOC *PKFSOBJNAMEALLOC;
146
147
148/**
[2851]149 * Base cache node.
150 */
151typedef struct KFSOBJ
[2831]152{
[2851]153 /** Magic value (KFSOBJ_MAGIC). */
154 KU32 u32Magic;
[2831]155 /** Number of references. */
[2851]156 KU32 volatile cRefs;
[2853]157 /** The cache generation, see KFSOBJ_CACHE_GEN_IGNORE. */
[2851]158 KU32 uCacheGen;
159 /** The object type, KFSOBJ_TYPE_XXX. */
160 KU8 bObjType;
161 /** Set if the Stats member is valid, clear if not. */
162 KBOOL fHaveStats;
[3362]163 /** Internal debug field for counting path hash references.
164 * @internal */
165 KU8 cPathHashRefs;
166 /** Index into KFSCACHE::auUserData. */
167 KU8 idxUserDataLock;
[2851]168 /** Flags, KFSOBJ_F_XXX. */
169 KU32 fFlags;
[2831]170
[2930]171 /** Hash value of the name inserted into the parent hash table.
172 * This is 0 if not inserted. Names are only hashed and inserted as they are
173 * first found thru linear searching of its siblings, and which name it is
174 * dependens on the lookup function (W or A) and whether the normal name or
175 * short name seems to have matched.
176 *
177 * @note It was ruled out as too much work to hash and track all four names,
178 * so instead this minimalist approach was choosen in stead. */
179 KU32 uNameHash;
180 /** Pointer to the next child with the same name hash value. */
181 PKFSOBJ pNextNameHash;
[2851]182 /** Pointer to the parent (directory).
183 * This is only NULL for a root. */
184 PKFSDIR pParent;
[2831]185
[2851]186 /** The directory name. (Allocated after the structure.) */
187 const char *pszName;
188 /** The length of pszName. */
189 KU16 cchName;
190 /** The length of the parent path (up to where pszName starts).
191 * @note This is valuable when constructing an absolute path to this node by
192 * means of the parent pointer (no need for recursion). */
193 KU16 cchParent;
194#ifdef KFSCACHE_CFG_UTF16
195 /** The length of pwszName (in wchar_t's). */
196 KU16 cwcName;
197 /** The length of the parent UTF-16 path (in wchar_t's).
198 * @note This is valuable when constructing an absolute path to this node by
199 * means of the parent pointer (no need for recursion). */
200 KU16 cwcParent;
201 /** The UTF-16 object name. (Allocated after the structure.) */
202 const wchar_t *pwszName;
203#endif
[2832]204
[2851]205#ifdef KFSCACHE_CFG_SHORT_NAMES
206 /** The short object name. (Allocated after the structure, could be same
207 * as pszName.) */
208 const char *pszShortName;
209 /** The length of pszShortName. */
210 KU16 cchShortName;
211 /** The length of the short parent path (up to where pszShortName starts). */
212 KU16 cchShortParent;
213# ifdef KFSCACHE_CFG_UTF16
214 /** The length of pwszShortName (in wchar_t's). */
215 KU16 cwcShortName;
216 /** The length of the short parent UTF-16 path (in wchar_t's). */
217 KU16 cwcShortParent;
218 /** The UTF-16 short object name. (Allocated after the structure, possibly
219 * same as pwszName.) */
220 const wchar_t *pwszShortName;
221# endif
222#endif
[2832]223
[2967]224 /** Allocation for handling name length increases. */
225 PKFSOBJNAMEALLOC pNameAlloc;
226
[2855]227 /** Pointer to the first user data item */
228 PKFSUSERDATA pUserDataHead;
229
[2851]230 /** Stats - only valid when fHaveStats is set. */
231 BirdStat_T Stats;
232} KFSOBJ;
[2832]233
[2851]234/** The magic for a KFSOBJ structure (Thelonious Sphere Monk). */
235#define KFSOBJ_MAGIC KU32_C(0x19171010)
[2832]236
237
[2851]238/**
239 * Directory node in the cache.
240 */
241typedef struct KFSDIR
[2833]242{
[2851]243 /** The core object information. */
244 KFSOBJ Obj;
[2833]245
[2851]246 /** Child objects. */
247 PKFSOBJ *papChildren;
[2833]248 /** The number of child objects. */
249 KU32 cChildren;
[2863]250 /** The allocated size of papChildren. */
251 KU32 cChildrenAllocated;
[2833]252
[2930]253 /** Pointer to the child hash table. */
254 PKFSOBJ *papHashTab;
255 /** The mask shift of the hash table.
256 * Hash table size is a power of two, this is the size minus one.
257 *
258 * @remarks The hash table is optional and populated by lookup hits. The
259 * assumption being that a lookup is repeated and will choose a good
260 * name to hash on. We've got up to 4 different hashes, so this
261 * was the easy way out. */
262 KU32 fHashTabMask;
[2833]263
[2851]264 /** Handle to the directory (we generally keep it open). */
[2856]265#ifndef DECLARE_HANDLE
266 KUPTR hDir;
267#else
[2851]268 HANDLE hDir;
[2856]269#endif
[2851]270 /** The device number we queried/inherited when opening it. */
271 KU64 uDevNo;
[2833]272
[2859]273 /** The last write time sampled the last time the directory was refreshed.
274 * @remarks May differ from st_mtim because it will be updated when the
275 * parent directory is refreshed. */
276 KI64 iLastWrite;
[3381]277 /** The time that iLastWrite was read. */
278 KI64 iLastPopulated;
[2859]279
[2851]280 /** Set if populated. */
281 KBOOL fPopulated;
[2862]282 /** Set if it needs re-populated. */
283 KBOOL fNeedRePopulating;
[2851]284} KFSDIR;
[2833]285
[2851]286
287/**
288 * Lookup errors.
289 */
290typedef enum KFSLOOKUPERROR
291{
292 /** Lookup was a success. */
293 KFSLOOKUPERROR_SUCCESS = 0,
294 /** A path component was not found. */
295 KFSLOOKUPERROR_PATH_COMP_NOT_FOUND,
296 /** A path component is not a directory. */
297 KFSLOOKUPERROR_PATH_COMP_NOT_DIR,
298 /** The final path entry is not a directory (trailing slash). */
299 KFSLOOKUPERROR_NOT_DIR,
300 /** Not found. */
301 KFSLOOKUPERROR_NOT_FOUND,
302 /** The path is too long. */
303 KFSLOOKUPERROR_PATH_TOO_LONG,
[3372]304 /** The path is too short. */
305 KFSLOOKUPERROR_PATH_TOO_SHORT,
[2851]306 /** Unsupported path type. */
307 KFSLOOKUPERROR_UNSUPPORTED,
308 /** We're out of memory. */
309 KFSLOOKUPERROR_OUT_OF_MEMORY,
310
311 /** Error opening directory. */
312 KFSLOOKUPERROR_DIR_OPEN_ERROR,
313 /** Error reading directory. */
314 KFSLOOKUPERROR_DIR_READ_ERROR,
315 /** UTF-16 to ANSI conversion error. */
316 KFSLOOKUPERROR_ANSI_CONVERSION_ERROR,
317 /** ANSI to UTF-16 conversion error. */
318 KFSLOOKUPERROR_UTF16_CONVERSION_ERROR,
319 /** Internal error. */
320 KFSLOOKUPERROR_INTERNAL_ERROR
321} KFSLOOKUPERROR;
322
323
[2833]324/** Pointer to an ANSI path hash table entry. */
[2851]325typedef struct KFSHASHA *PKFSHASHA;
[2833]326/**
327 * ANSI file system path hash table entry.
328 * The path hash table allows us to skip parsing and walking a path.
329 */
[2851]330typedef struct KFSHASHA
[2833]331{
[2835]332 /** Next entry with the same hash table slot. */
[2851]333 PKFSHASHA pNext;
[2833]334 /** Path hash value. */
335 KU32 uHashPath;
336 /** The path length. */
[2859]337 KU16 cchPath;
338 /** Set if aboslute path. */
339 KBOOL fAbsolute;
[2868]340 /** Index into KFSCACHE:auGenerationsMissing when pFsObj is NULL. */
341 KU8 idxMissingGen;
[2851]342 /** The cache generation ID. */
343 KU32 uCacheGen;
344 /** The lookup error (when pFsObj is NULL). */
345 KFSLOOKUPERROR enmError;
[2833]346 /** The path. (Allocated after the structure.) */
347 const char *pszPath;
[2851]348 /** Pointer to the matching FS object.
349 * This is NULL for negative path entries? */
350 PKFSOBJ pFsObj;
351} KFSHASHA;
[2833]352
353
[2851]354#ifdef KFSCACHE_CFG_UTF16
[2833]355/** Pointer to an UTF-16 path hash table entry. */
[2851]356typedef struct KFSHASHW *PKFSHASHW;
[2833]357/**
358 * UTF-16 file system path hash table entry. The path hash table allows us
359 * to skip parsing and walking a path.
360 */
[2851]361typedef struct KFSHASHW
[2833]362{
[2835]363 /** Next entry with the same hash table slot. */
[2851]364 PKFSHASHW pNext;
[2833]365 /** Path hash value. */
366 KU32 uHashPath;
367 /** The path length (in wchar_t units). */
[2859]368 KU16 cwcPath;
369 /** Set if aboslute path. */
370 KBOOL fAbsolute;
[2868]371 /** Index into KFSCACHE:auGenerationsMissing when pFsObj is NULL. */
372 KU8 idxMissingGen;
[2851]373 /** The cache generation ID. */
374 KU32 uCacheGen;
375 /** The lookup error (when pFsObj is NULL). */
376 KFSLOOKUPERROR enmError;
[2833]377 /** The path. (Allocated after the structure.) */
378 const wchar_t *pwszPath;
[2851]379 /** Pointer to the matching FS object.
380 * This is NULL for negative path entries? */
381 PKFSOBJ pFsObj;
382} KFSHASHW;
383#endif
[2833]384
385
[3184]386/** @def KFSCACHE_LOCK
387 * Locks the cache exclusively. */
388/** @def KFSCACHE_UNLOCK
389 * Counterpart to KFSCACHE_LOCK. */
[3362]390/** @def KFSCACHE_OBJUSERDATA_LOCK
391 * Locks the user data list of an object exclusively. */
392/** @def KFSCACHE_OBJUSERDATA_UNLOCK
393 * Counterpart to KFSCACHE_OBJUSERDATA_LOCK. */
[3184]394#ifdef KFSCACHE_CFG_LOCKING
395# define KFSCACHE_LOCK(a_pCache) EnterCriticalSection(&(a_pCache)->u.CritSect)
396# define KFSCACHE_UNLOCK(a_pCache) LeaveCriticalSection(&(a_pCache)->u.CritSect)
[3362]397# define KFSCACHE_OBJUSERDATA_LOCK(a_pCache, a_pObj) do { \
398 KU8 idxUserDataLock = (a_pObj)->idxUserDataLock; \
399 if (idxUserDataLock != KU8_MAX) \
400 { /* likely */ } \
401 else \
402 idxUserDataLock = kFsCacheObjGetUserDataLockIndex(a_pCache, a_pObj); \
403 idxUserDataLock &= (KU8)(K_ELEMENTS((a_pCache)->auUserDataLocks) - 1); \
404 EnterCriticalSection(&(a_pCache)->auUserDataLocks[idxUserDataLock].CritSect); \
405 } while (0)
406# define KFSCACHE_OBJUSERDATA_UNLOCK(a_pCache, a_pObj) \
407 LeaveCriticalSection(&(a_pCache)->auUserDataLocks[(a_pObj)->idxUserDataLock & (K_ELEMENTS((a_pCache)->auUserDataLocks) - 1)].CritSect)
[3184]408#else
409# define KFSCACHE_LOCK(a_pCache) do { } while (0)
410# define KFSCACHE_UNLOCK(a_pCache) do { } while (0)
[3362]411# define KFSCACHE_OBJUSERDATA_LOCK(a_pCache, a_pObj) do { } while (0)
412# define KFSCACHE_OBJUSERDATA_UNLOCK(a_pCache, a_pObj) do { } while (0)
[3184]413#endif
414
415
[2851]416/** @name KFSCACHE_F_XXX
417 * @{ */
418/** Whether to cache missing directory entries (KFSOBJ_TYPE_MISSING). */
419#define KFSCACHE_F_MISSING_OBJECTS KU32_C(0x00000001)
420/** Whether to cache missing paths. */
421#define KFSCACHE_F_MISSING_PATHS KU32_C(0x00000002)
422/** @} */
[2835]423
[2851]424
[2835]425/**
[2851]426 * Directory cache instance.
[2835]427 */
[2851]428typedef struct KFSCACHE
[2835]429{
[2851]430 /** Magic value (KFSCACHE_MAGIC). */
431 KU32 u32Magic;
432 /** Cache flags. */
433 KU32 fFlags;
[2835]434
[2868]435 /** The default and custom cache generations for stuff that exists, indexed by
436 * KFSOBJ_F_USE_CUSTOM_GEN.
437 *
438 * The custom generation can be used to invalidate parts of the file system that
439 * are known to be volatile without triggering refreshing of the more static
440 * parts. Like the 'out' directory in a kBuild setup or a 'TEMP' directory are
441 * expected to change and you need to invalidate the caching of these frequently
442 * to stay on top of things. Whereas the sources, headers, compilers, sdk,
443 * ddks, windows directory and such generally doesn't change all that often.
444 */
445 KU32 auGenerations[2];
446 /** The current cache generation for missing objects, negative results, ++.
447 * This comes with a custom variant too. Indexed by KFSOBJ_F_USE_CUSTOM_GEN. */
448 KU32 auGenerationsMissing[2];
[2835]449
[2851]450 /** Number of cache objects. */
451 KSIZE cObjects;
452 /** Memory occupied by the cache object structures. */
453 KSIZE cbObjects;
454 /** Number of lookups. */
455 KSIZE cLookups;
456 /** Number of hits in the path hash tables. */
457 KSIZE cPathHashHits;
458 /** Number of hits walking the file system hierarchy. */
459 KSIZE cWalkHits;
[2930]460 /** Number of child searches. */
461 KSIZE cChildSearches;
462 /** Number of cChildLookups resolved thru hash table hits. */
463 KSIZE cChildHashHits;
464 /** The number of child hash tables. */
465 KSIZE cChildHashTabs;
466 /** The sum of all child hash table sizes. */
467 KSIZE cChildHashEntriesTotal;
468 /** Number of children inserted into the hash tables. */
469 KSIZE cChildHashed;
[2967]470 /** Number of collisions in the child hash tables. */
[2930]471 KSIZE cChildHashCollisions;
[2967]472 /** Number times a object name changed. */
473 KSIZE cNameChanges;
474 /** Number times a object name grew and needed KFSOBJNAMEALLOC.
475 * (Subset of cNameChanges) */
476 KSIZE cNameGrowths;
[2836]477
[2851]478 /** The root directory. */
479 KFSDIR RootDir;
[2836]480
[3184]481#ifdef KFSCACHE_CFG_LOCKING
482 union
483 {
484# ifdef _WINBASE_
485 CRITICAL_SECTION CritSect;
486# endif
487 KU64 abPadding[2 * 4 + 4 * sizeof(void *)];
[3362]488 }
489 /** Critical section protecting the cache. */
490 u,
491 /** Critical section protecting the pUserDataHead of objects.
492 * @note Array size must be a power of two. */
493 auUserDataLocks[8];
494 /** The next auUserData index. */
495 KU8 idxUserDataNext;
[3184]496#endif
497
[2851]498 /** File system hash table for ANSI filename strings. */
499 PKFSHASHA apAnsiPaths[KFSCACHE_CFG_PATH_HASH_TAB_SIZE];
500 /** Number of paths in the apAnsiPaths hash table. */
501 KSIZE cAnsiPaths;
502 /** Number of collisions in the apAnsiPaths hash table. */
503 KSIZE cAnsiPathCollisions;
504 /** Amount of memory used by the path entries. */
505 KSIZE cbAnsiPaths;
[2836]506
[2851]507#ifdef KFSCACHE_CFG_UTF16
508 /** Number of paths in the apUtf16Paths hash table. */
509 KSIZE cUtf16Paths;
510 /** Number of collisions in the apUtf16Paths hash table. */
511 KSIZE cUtf16PathCollisions;
512 /** Amount of memory used by the UTF-16 path entries. */
513 KSIZE cbUtf16Paths;
514 /** File system hash table for UTF-16 filename strings. */
515 PKFSHASHW apUtf16Paths[KFSCACHE_CFG_PATH_HASH_TAB_SIZE];
516#endif
517} KFSCACHE;
[2834]518
[2851]519/** Magic value for KFSCACHE::u32Magic (Jon Batiste). */
520#define KFSCACHE_MAGIC KU32_C(0x19861111)
[2834]521
522
[2853]523/** @def KW_LOG
524 * Generic logging.
525 * @param a Argument list for kFsCacheDbgPrintf */
[3199]526#if 1 /*def NDEBUG - enable when needed! */
[2853]527# define KFSCACHE_LOG(a) do { } while (0)
[2836]528#else
[2853]529# define KFSCACHE_LOG(a) kFsCacheDbgPrintf a
530void kFsCacheDbgPrintfV(const char *pszFormat, va_list va);
531void kFsCacheDbgPrintf(const char *pszFormat, ...);
[2836]532#endif
[2835]533
[2836]534
[2857]535KBOOL kFsCacheDirEnsurePopuplated(PKFSCACHE pCache, PKFSDIR pDir, KFSLOOKUPERROR *penmError);
[2853]536KBOOL kFsCacheDirAddChild(PKFSCACHE pCache, PKFSDIR pParent, PKFSOBJ pChild, KFSLOOKUPERROR *penmError);
537PKFSOBJ kFsCacheCreateObject(PKFSCACHE pCache, PKFSDIR pParent,
538 char const *pszName, KU16 cchName, wchar_t const *pwszName, KU16 cwcName,
[2851]539#ifdef KFSCACHE_CFG_SHORT_NAMES
[2853]540 char const *pszShortName, KU16 cchShortName, wchar_t const *pwszShortName, KU16 cwcShortName,
[2851]541#endif
[2853]542 KU8 bObjType, KFSLOOKUPERROR *penmError);
543PKFSOBJ kFsCacheCreateObjectW(PKFSCACHE pCache, PKFSDIR pParent, wchar_t const *pwszName, KU32 cwcName,
[2851]544#ifdef KFSCACHE_CFG_SHORT_NAMES
[2853]545 wchar_t const *pwszShortName, KU32 cwcShortName,
[2851]546#endif
[2853]547 KU8 bObjType, KFSLOOKUPERROR *penmError);
548PKFSOBJ kFsCacheLookupA(PKFSCACHE pCache, const char *pszPath, KFSLOOKUPERROR *penmError);
549PKFSOBJ kFsCacheLookupW(PKFSCACHE pCache, const wchar_t *pwszPath, KFSLOOKUPERROR *penmError);
[2912]550PKFSOBJ kFsCacheLookupRelativeToDirA(PKFSCACHE pCache, PKFSDIR pParent, const char *pszPath, KU32 cchPath, KU32 fFlags,
[2868]551 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor);
[2912]552PKFSOBJ kFsCacheLookupRelativeToDirW(PKFSCACHE pCache, PKFSDIR pParent, const wchar_t *pwszPath, KU32 cwcPath, KU32 fFlags,
[2868]553 KFSLOOKUPERROR *penmError, PKFSOBJ *ppLastAncestor);
[2861]554PKFSOBJ kFsCacheLookupWithLengthA(PKFSCACHE pCache, const char *pchPath, KSIZE cchPath, KFSLOOKUPERROR *penmError);
555PKFSOBJ kFsCacheLookupWithLengthW(PKFSCACHE pCache, const wchar_t *pwcPath, KSIZE cwcPath, KFSLOOKUPERROR *penmError);
[2858]556PKFSOBJ kFsCacheLookupNoMissingA(PKFSCACHE pCache, const char *pszPath, KFSLOOKUPERROR *penmError);
557PKFSOBJ kFsCacheLookupNoMissingW(PKFSCACHE pCache, const wchar_t *pwszPath, KFSLOOKUPERROR *penmError);
[2833]558
[2912]559/** @name KFSCACHE_LOOKUP_F_XXX - lookup flags
560 * @{ */
561/** No inserting new cache entries.
562 * This effectively prevent directories from being repopulated too. */
563#define KFSCACHE_LOOKUP_F_NO_INSERT KU32_C(1)
564/** No refreshing cache entries. */
565#define KFSCACHE_LOOKUP_F_NO_REFRESH KU32_C(2)
566/** @} */
[2858]567
[2853]568KU32 kFsCacheObjRelease(PKFSCACHE pCache, PKFSOBJ pObj);
[2945]569KU32 kFsCacheObjReleaseTagged(PKFSCACHE pCache, PKFSOBJ pObj, const char *pszWhere);
570#ifndef NDEBUG /* enable to debug object release. */
571# define kFsCacheObjRelease(a_pCache, a_pObj) kFsCacheObjReleaseTagged(a_pCache, a_pObj, __FUNCTION__)
572#endif
[2853]573KU32 kFsCacheObjRetain(PKFSOBJ pObj);
[2858]574PKFSUSERDATA kFsCacheObjAddUserData(PKFSCACHE pCache, PKFSOBJ pObj, KUPTR uKey, KSIZE cbUserData);
575PKFSUSERDATA kFsCacheObjGetUserData(PKFSCACHE pCache, PKFSOBJ pObj, KUPTR uKey);
[3362]576KU8 kFsCacheObjGetUserDataLockIndex(PKFSCACHE pCache, PKFSOBJ pObj);
[2858]577KBOOL kFsCacheObjGetFullPathA(PKFSOBJ pObj, char *pszPath, KSIZE cbPath, char chSlash);
578KBOOL kFsCacheObjGetFullPathW(PKFSOBJ pObj, wchar_t *pwszPath, KSIZE cwcPath, wchar_t wcSlash);
579KBOOL kFsCacheObjGetFullShortPathA(PKFSOBJ pObj, char *pszPath, KSIZE cbPath, char chSlash);
580KBOOL kFsCacheObjGetFullShortPathW(PKFSOBJ pObj, wchar_t *pwszPath, KSIZE cwcPath, wchar_t wcSlash);
[2833]581
[2861]582KBOOL kFsCacheFileSimpleOpenReadClose(PKFSCACHE pCache, PKFSOBJ pFileObj, KU64 offStart, void *pvBuf, KSIZE cbToRead);
583
[2853]584PKFSCACHE kFsCacheCreate(KU32 fFlags);
585void kFsCacheDestroy(PKFSCACHE);
[2868]586void kFsCacheInvalidateMissing(PKFSCACHE pCache);
587void kFsCacheInvalidateAll(PKFSCACHE pCache);
[3359]588void kFsCacheInvalidateAllAndCloseDirs(PKFSCACHE pCache, KBOOL fIncludingRoot);
[2868]589void kFsCacheInvalidateCustomMissing(PKFSCACHE pCache);
590void kFsCacheInvalidateCustomBoth(PKFSCACHE pCache);
591KBOOL kFsCacheSetupCustomRevisionForTree(PKFSCACHE pCache, PKFSOBJ pRoot);
[2912]592KBOOL kFsCacheInvalidateDeletedDirectoryA(PKFSCACHE pCache, const char *pszDir);
[2833]593
[2851]594#endif
Note: See TracBrowser for help on using the repository browser.