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.

184 lines
5.2 KiB

  1. /*++ BUILD Version: 0003 // Increment this if a change has global effects
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. persist.h
  5. Abstract:
  6. This module defines the header for data blocks maintained by the
  7. SMB server in it's persistent handle state file that is associated with
  8. persistent-handle enabled shares.
  9. Author:
  10. Andy Herron (andyhe) 3-Nov-1999
  11. Revision History:
  12. --*/
  13. #ifndef _SRVPERSIST_
  14. #define _SRVPERSIST_
  15. typedef enum _PERSISTENT_OPERATION {
  16. PersistentFreeSpace,
  17. PersistentConnection,
  18. PersistentSession,
  19. PersistentUserName,
  20. PersistentFileOpen,
  21. PersistentByteLock
  22. } PERSISTENT_OPERATION, *PPERSISTENT_OPERATION;
  23. typedef enum _PERSISTENT_STATE {
  24. PersistentStateFreed,
  25. PersistentStateActive,
  26. PersistentStateInError,
  27. PersistentStateClosed
  28. } PERSISTENT_STATE, *PPERSISTENT_STATE;
  29. //
  30. // Types of blocks that are saved in the persistent state file are as follows:
  31. //
  32. // Share block - single one at offset 0 in the file
  33. // Connection - one per connection that has persistent handles
  34. // Session - one per session that has persistent handles
  35. // PersistentFile - one per file that is opened persistently
  36. // ByteRangeLock - one per byte range lock that is held on persistent file
  37. //
  38. typedef struct _PERSISTENT_FILE_HEADER {
  39. ULONG ConsistencyCheck;
  40. ULONG FileSize;
  41. ULONG HeaderSize;
  42. ULONG RecordSize;
  43. ULONG NumberOfRecords;
  44. LARGE_INTEGER ServerStartTime;
  45. LARGE_INTEGER CreateTime;
  46. LARGE_INTEGER TimeClosed;
  47. BOOLEAN ClosedCleanly;
  48. } PERSISTENT_FILE_HEADER, *PPERSISTENT_FILE_HEADER;
  49. //
  50. // The following structures map out the specific types of persistent records
  51. // we have in the state file. We lay them out this way rather than just
  52. // as sub-structures within the PERSISTENT_RECORD structure so that we can
  53. // accurately guage how big the largest substructure is for the SID records.
  54. //
  55. typedef struct _PERSISTENT_CONNECTION {
  56. ULONG ClientId; // shared with client
  57. PCONNECTION Connection; // actual pointer back to our connection
  58. BOOLEAN DirectHostIpx;
  59. union {
  60. ULONG ClientIPAddress;
  61. TDI_ADDRESS_IPX IpxAddress;
  62. };
  63. CHAR OemClientMachineName[COMPUTER_NAME_LENGTH+1];
  64. };
  65. typedef struct _PERSISTENT_SESSION {
  66. ULONG ClientId;
  67. PSESSION Session;
  68. ULONG SessionNumber; // sent to client during session setup
  69. LARGE_INTEGER CreateTime; // ditto
  70. USHORT Uid; // ditto
  71. LARGE_INTEGER LogOffTime; // for forced logoff
  72. LARGE_INTEGER KickOffTime; // for forced logoff
  73. ULONG UserNameRecord; // offset to record for this user's name
  74. };
  75. typedef struct _PERSISTENT_OPEN {
  76. ULONG ClientId;
  77. ULONG SessionNumber;
  78. PRFCB Rfcb;
  79. ULONG PersistentFileId;
  80. LARGE_INTEGER FileReferenceNumber; // instead of file name
  81. LARGE_INTEGER UsnValue; // ensure correct file
  82. BOOLEAN CompatibilityOpen; // from MFCB
  83. ULONG OpenFileAttributes; // from MFCB
  84. ULONG FileMode; // from LFCB
  85. ULONG JobId; // from LFCB
  86. CLONG FcbOpenCount; // from RFCB
  87. USHORT Fid; // from RFCB
  88. USHORT Pid; // from RFCB
  89. USHORT Tid; // tree ID for this open
  90. ACCESS_MASK GrantedAccess; // from RFCB
  91. ULONG ShareAccess; // from RFCB
  92. OPLOCK_STATE OplockState; // from RFCB
  93. };
  94. typedef struct _PERSISTENT_BYTELOCK {
  95. ULONG ClientId;
  96. PBYTELOCK ByteLock;
  97. ULONG PersistentFileId;
  98. LARGE_INTEGER LockOffset;
  99. LARGE_INTEGER LockLength;
  100. BOOLEAN Exclusive;
  101. };
  102. #define LARGEST_PERSISTENT_RECORD _PERSISTENT_OPEN
  103. #define PERSISTENT_USER_NAME_BUFFER_LENGTH ( sizeof( struct LARGEST_PERSISTENT_RECORD ) - (3 * sizeof(ULONG)) )
  104. typedef struct _PERSISTENT_USER_NAME {
  105. //
  106. // we store the user's name and domain name in a series of records,
  107. // though typically it should fit in one.
  108. //
  109. ULONG RecordLength; // number of valid bytes in Buffer
  110. ULONG ContinuationRecord; // offset within file to next part of SID, 0 if at end
  111. UCHAR Buffer[ PERSISTENT_USER_NAME_BUFFER_LENGTH ];
  112. };
  113. //
  114. // These are the records we log to the state file. They're all the same
  115. // length to make processing more efficient.
  116. //
  117. typedef struct _PERSISTENT_RECORD {
  118. ULONG PersistConsistencyCheck; // must be first dword
  119. ULONG PersistIndex;
  120. PERSISTENT_STATE PersistState;
  121. PERSISTENT_OPERATION PersistOperation;
  122. union {
  123. struct _PERSISTENT_CONNECTION Connection;
  124. struct _PERSISTENT_SESSION Session;
  125. struct _PERSISTENT_OPEN FileOpen;
  126. struct _PERSISTENT_BYTELOCK ByteLock;
  127. struct _PERSISTENT_USER_NAME UserName;
  128. };
  129. } PERSISTENT_RECORD, *PPERSISTENT_RECORD;
  130. #endif // #ifndef _SRVPERSIST