Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

307 lines
6.8 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. prefix.h
  5. Abstract:
  6. This module defines the data structures that enable the RDBSS to use the prefix package
  7. to catalog its server and netroot names. For the moment, file/directory names use the same stuff.
  8. Author:
  9. Joe Linn (JoeLinn) 8-8-94
  10. Revision History:
  11. --*/
  12. #ifndef _RXPREFIX_
  13. #define _RXPREFIX_
  14. // this stuff is implemented in prefix.c
  15. /*
  16. The current implementation uses a table that has as components:
  17. 1) a prefix table
  18. 2) a queue
  19. 3) a version
  20. 4) a lock
  21. You use the lock in the normal way: shared to lookup; eclusive to change. the version changes
  22. eith each change. The reason that we have the queue is that the prefix table package allows
  23. caller to be enumerating at a time..... the Q/version approach allows multiple guys at a time.
  24. The Q could be used as a faster lookup for filenames but the prefix table is definitely the
  25. right thing for netroots.
  26. */
  27. typedef struct _RX_CONNECTION_ID {
  28. union {
  29. ULONG SessionID;
  30. LUID Luid;
  31. };
  32. } RX_CONNECTION_ID, *PRX_CONNECTION_ID;
  33. ULONG
  34. RxTableComputeHashValue (
  35. IN PUNICODE_STRING Name
  36. );
  37. PVOID
  38. RxPrefixTableLookupName (
  39. IN PRX_PREFIX_TABLE ThisTable,
  40. IN PUNICODE_STRING CanonicalName,
  41. OUT PUNICODE_STRING RemainingName,
  42. IN PRX_CONNECTION_ID ConnectionId
  43. );
  44. PRX_PREFIX_ENTRY
  45. RxPrefixTableInsertName (
  46. IN OUT PRX_PREFIX_TABLE ThisTable,
  47. IN OUT PRX_PREFIX_ENTRY ThisEntry,
  48. IN PVOID Container,
  49. IN PULONG ContainerRefCount,
  50. IN USHORT CaseInsensitiveLength,
  51. IN PRX_CONNECTION_ID ConnectionId
  52. );
  53. VOID
  54. RxRemovePrefixTableEntry (
  55. IN OUT PRX_PREFIX_TABLE ThisTable,
  56. IN OUT PRX_PREFIX_ENTRY Entry
  57. );
  58. VOID
  59. RxDereferenceEntryContainer (
  60. IN OUT PRX_PREFIX_ENTRY Entry,
  61. IN PRX_PREFIX_TABLE PrefixTable
  62. );
  63. BOOLEAN
  64. RxIsNameTableEmpty (
  65. IN PRX_PREFIX_TABLE ThisTable
  66. );
  67. VOID
  68. RxInitializePrefixTable (
  69. IN OUT PRX_PREFIX_TABLE ThisTable,
  70. IN ULONG TableSize OPTIONAL,
  71. IN BOOLEAN CaseInsensitiveMatch
  72. );
  73. VOID
  74. RxFinalizePrefixTable (
  75. IN OUT PRX_PREFIX_TABLE ThisTable
  76. );
  77. //
  78. // Rx form of a table entry.
  79. //
  80. typedef struct _RX_PREFIX_ENTRY {
  81. //
  82. // Normal Header for Refcounted Structure
  83. //
  84. NODE_TYPE_CODE NodeTypeCode;
  85. NODE_BYTE_SIZE NodeByteSize;
  86. //
  87. // the initial part of the name that is always case insensitive
  88. //
  89. USHORT CaseInsensitiveLength;
  90. USHORT Spare1;
  91. ULONG SavedHashValue;
  92. LIST_ENTRY HashLinks;
  93. //
  94. // queue of the set members
  95. //
  96. LIST_ENTRY MemberQLinks;
  97. //
  98. // Name of the entry
  99. //
  100. UNICODE_STRING Prefix;
  101. //
  102. // Pointer to the reference count of the container
  103. //
  104. PULONG ContainerRefCount;
  105. //
  106. // don't know the parent type...nor do all callers!
  107. // thus, i need this backptr.
  108. //
  109. PVOID ContainingRecord;
  110. //
  111. // some space that alternate table routines can use
  112. //
  113. PVOID Context;
  114. //
  115. // Used for controlled multiplexing
  116. //
  117. RX_CONNECTION_ID ConnectionId;
  118. } RX_PREFIX_ENTRY, *PRX_PREFIX_ENTRY;
  119. //
  120. // Rx form of name table. wraps in a lock and a queue. Originally, this implementation used the prefix tables
  121. // in Rtl which don't allow an empty string entry. so, we special case this.
  122. //
  123. #define RX_PREFIX_TABLE_DEFAULT_LENGTH 32
  124. typedef
  125. PVOID
  126. (*PRX_TABLE_LOOKUPNAME) (
  127. IN PRX_PREFIX_TABLE ThisTable,
  128. IN PUNICODE_STRING CanonicalName,
  129. OUT PUNICODE_STRING RemainingName
  130. );
  131. typedef
  132. PRX_PREFIX_ENTRY
  133. (*PRX_TABLE_INSERTENTRY) (
  134. IN OUT PRX_PREFIX_TABLE ThisTable,
  135. IN OUT PRX_PREFIX_ENTRY ThisEntry
  136. );
  137. typedef
  138. VOID
  139. (*PRX_TABLE_REMOVEENTRY) (
  140. IN OUT PRX_PREFIX_TABLE ThisTable,
  141. IN OUT PRX_PREFIX_ENTRY Entry
  142. );
  143. typedef struct _RX_PREFIX_TABLE {
  144. //
  145. // Normal Header
  146. //
  147. NODE_TYPE_CODE NodeTypeCode;
  148. NODE_BYTE_SIZE NodeByteSize;
  149. //
  150. // version stamp changes on each insertion/removal
  151. //
  152. ULONG Version;
  153. //
  154. // queue of the inserted names
  155. //
  156. LIST_ENTRY MemberQueue;
  157. //
  158. // Resource used to control table access
  159. //
  160. ERESOURCE TableLock;
  161. //
  162. // PrefixEntry for the Null string
  163. //
  164. PRX_PREFIX_ENTRY TableEntryForNull;
  165. BOOLEAN CaseInsensitiveMatch;
  166. //
  167. // we may act differently for this....esp for debug!
  168. //
  169. BOOLEAN IsNetNameTable;
  170. ULONG TableSize;
  171. #if DBG
  172. ULONG Lookups;
  173. ULONG FailedLookups;
  174. ULONG Considers;
  175. ULONG Compares;
  176. #endif
  177. LIST_ENTRY HashBuckets[RX_PREFIX_TABLE_DEFAULT_LENGTH];
  178. } RX_PREFIX_TABLE, *PRX_PREFIX_TABLE;
  179. #if 0
  180. #define RxAcquirePrefixTableLockShared(PrefixTable,Wait) \
  181. RxpAcquirePrefixTableLockShared((PrefixTable),(Wait),TRUE, __FILE__,__LINE__ )
  182. #define RxAcquirePrefixTableLockExclusive(PrefixTable,Wait) \
  183. RxpAcquirePrefixTableLockExclusive((PrefixTable),(Wait),TRUE, __FILE__,__LINE__ )
  184. #define RxReleasePrefixTableLock(PrefixTable) \
  185. RxpReleasePrefixTableLock((PrefixTable),TRUE, __FILE__,__LINE__ )
  186. extern
  187. BOOLEAN
  188. RxpAcquirePrefixTableLockShared (
  189. PRX_PREFIX_TABLE pTable,
  190. BOOLEAN Wait,
  191. BOOLEAN ProcessBufferingStateChangeRequests,
  192. PSZ FileName,
  193. ULONG LineNumber );
  194. extern
  195. BOOLEAN
  196. RxpAcquirePrefixTableLockExclusive (
  197. PRX_PREFIX_TABLE pTable,
  198. BOOLEAN Wait,
  199. BOOLEAN ProcessBufferingStateChangeRequests,
  200. PSZ FileName,
  201. ULONG LineNumber
  202. );
  203. extern
  204. VOID
  205. RxpReleasePrefixTableLock (
  206. PRX_PREFIX_TABLE pTable,
  207. BOOLEAN ProcessBufferingStateChangeRequests,
  208. PSZ FileName,
  209. ULONG LineNumber
  210. );
  211. #else
  212. #define RxAcquirePrefixTableLockShared(TABLE,WAIT) ExAcquireResourceSharedLite( &(TABLE)->TableLock, (WAIT) )
  213. #define RxAcquirePrefixTableLockExclusive(TABLE,WAIT) ExAcquireResourceExclusiveLite( &(TABLE)->TableLock, (WAIT) )
  214. #define RxReleasePrefixTableLock(TABLE) ExReleaseResourceLite( &(TABLE)->TableLock )
  215. #endif
  216. extern
  217. VOID
  218. RxExclusivePrefixTableLockToShared (
  219. PRX_PREFIX_TABLE Table
  220. );
  221. #define RxIsPrefixTableLockExclusive(TABLE) ExIsResourceAcquiredExclusiveLite(&(TABLE)->TableLock)
  222. #define RxIsPrefixTableLockAcquired(TABLE) ( ExIsResourceAcquiredSharedLite(&(TABLE)->TableLock) || \
  223. ExIsResourceAcquiredExclusiveLite(&(TABLE)->TableLock) )
  224. #endif // _RXPREFIX_