Source code of Windows XP (NT5)
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.

224 lines
6.2 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. #if 0
  67. #define RX_PREFIXTABLELOCK_ARGS ,__FILE__,__LINE__
  68. #define RX_PREFIXTABLELOCK_PARAMS ,PSZ FileName,ULONG LineNumber
  69. #else
  70. #define RX_PREFIXTABLELOCK_ARGS
  71. #define RX_PREFIXTABLELOCK_PARAMS
  72. #endif
  73. #define RxAcquirePrefixTableLockShared(pPrefixTable,Wait) \
  74. RxpAcquirePrefixTableLockShared((pPrefixTable),(Wait),TRUE RX_PREFIXTABLELOCK_ARGS)
  75. #define RxAcquirePrefixTableLockExclusive(pPrefixTable,Wait) \
  76. RxpAcquirePrefixTableLockExclusive((pPrefixTable),(Wait),TRUE RX_PREFIXTABLELOCK_ARGS)
  77. #define RxReleasePrefixTableLock(pPrefixTable) \
  78. RxpReleasePrefixTableLock((pPrefixTable),TRUE RX_PREFIXTABLELOCK_ARGS)
  79. extern BOOLEAN
  80. RxpAcquirePrefixTableLockShared(
  81. PRX_PREFIX_TABLE pTable,
  82. BOOLEAN Wait,
  83. BOOLEAN ProcessBufferingStateChangeRequests RX_PREFIXTABLELOCK_PARAMS);
  84. extern BOOLEAN
  85. RxpAcquirePrefixTableLockExclusive(
  86. PRX_PREFIX_TABLE pTable,
  87. BOOLEAN Wait,
  88. BOOLEAN ProcessBufferingStateChangeRequests RX_PREFIXTABLELOCK_PARAMS);
  89. extern VOID
  90. RxExclusivePrefixTableLockToShared(PRX_PREFIX_TABLE pTable);
  91. extern VOID
  92. RxpReleasePrefixTableLock(
  93. PRX_PREFIX_TABLE pTable,
  94. BOOLEAN ProcessBufferingStateChangeRequests RX_PREFIXTABLELOCK_PARAMS);
  95. #define RxIsPrefixTableLockExclusive(PTABLE) ExIsResourceAcquiredExclusiveLite(&(PTABLE)->TableLock)
  96. #define RxIsPrefixTableLockAcquired(PTABLE) ( ExIsResourceAcquiredSharedLite(&(PTABLE)->TableLock) || \
  97. ExIsResourceAcquiredExclusiveLite(&(PTABLE)->TableLock) )
  98. VOID
  99. RxInitializePrefixTable(
  100. IN OUT PRX_PREFIX_TABLE ThisTable,
  101. IN ULONG TableSize OPTIONAL, //0=>use default
  102. IN BOOLEAN CaseInsensitiveMatch
  103. );
  104. VOID
  105. RxFinalizePrefixTable(
  106. IN OUT PRX_PREFIX_TABLE ThisTable
  107. );
  108. //
  109. // Rx form of a table entry.
  110. typedef struct _RX_PREFIX_ENTRY {
  111. NODE_TYPE_CODE NodeTypeCode; // Normal Header for Refcounted Structure
  112. NODE_BYTE_SIZE NodeByteSize;
  113. USHORT CaseInsensitiveLength; //the initial part of the name that is always case insensitive
  114. USHORT Spare1;
  115. //UNICODE_PREFIX_TABLE_ENTRY TableEntry; // Actual table linkage
  116. ULONG SavedHashValue;
  117. LIST_ENTRY HashLinks;
  118. LIST_ENTRY MemberQLinks; // queue of the set members
  119. UNICODE_STRING Prefix; // Name of the entry
  120. PULONG ContainerRefCount; // Pointer to the reference count of the container
  121. PVOID ContainingRecord; // don't know the parent type...nor do all callers!
  122. // thus, i need this backptr.
  123. PVOID Context; // some space that alternate table routines can use
  124. RX_CONNECTION_ID ConnectionId; // Used for controlled multiplexing
  125. } RX_PREFIX_ENTRY, *PRX_PREFIX_ENTRY;
  126. //
  127. // Rx form of name table. wraps in a lock and a queue. Originally, this implementation used the prefix tables
  128. // in Rtl which don't allow an empty string entry. so, we special case this.
  129. #define RX_PREFIX_TABLE_DEFAULT_LENGTH 32
  130. typedef
  131. PVOID
  132. (*PRX_TABLE_LOOKUPNAME) (
  133. IN PRX_PREFIX_TABLE ThisTable,
  134. IN PUNICODE_STRING CanonicalName,
  135. OUT PUNICODE_STRING RemainingName
  136. );
  137. typedef
  138. PRX_PREFIX_ENTRY
  139. (*PRX_TABLE_INSERTENTRY) (
  140. IN OUT PRX_PREFIX_TABLE ThisTable,
  141. IN OUT PRX_PREFIX_ENTRY ThisEntry
  142. );
  143. typedef
  144. VOID
  145. (*PRX_TABLE_REMOVEENTRY) (
  146. IN OUT PRX_PREFIX_TABLE ThisTable,
  147. IN OUT PRX_PREFIX_ENTRY Entry
  148. );
  149. typedef struct _RX_PREFIX_TABLE {
  150. NODE_TYPE_CODE NodeTypeCode; // Normal Header
  151. NODE_BYTE_SIZE NodeByteSize;
  152. ULONG Version; // version stamp changes on each insertion/removal
  153. LIST_ENTRY MemberQueue; // queue of the inserted names
  154. ERESOURCE TableLock; // Resource used to control table access
  155. PRX_PREFIX_ENTRY TableEntryForNull; // PrefixEntry for the Null string
  156. BOOLEAN CaseInsensitiveMatch;
  157. BOOLEAN IsNetNameTable; //we may act differently for this....esp for debug!
  158. ULONG TableSize;
  159. #if DBG
  160. ULONG Lookups;
  161. ULONG FailedLookups;
  162. ULONG Considers;
  163. ULONG Compares;
  164. #endif
  165. LIST_ENTRY HashBuckets[RX_PREFIX_TABLE_DEFAULT_LENGTH];
  166. } RX_PREFIX_TABLE, *PRX_PREFIX_TABLE;
  167. #endif // _RXPREFIX_