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.

1023 lines
30 KiB

  1. /*++
  2. Copyright (c) 1989 - 1998 Microsoft Corporation
  3. Module Name:
  4. exifs.h
  5. Abstract:
  6. This header exports all symbols and definitions shared between
  7. user-mode clients of the Exchange IFS driver and the driver itself.
  8. Notes:
  9. This module has been built and tested only in UNICODE environment
  10. Author:
  11. Rajeev Rajan [RajeevR] 2-Feb-1998
  12. Revision History:
  13. Mike Purtell [MikePurt] 21-Jul-1998
  14. Additions for NSM (Name Space Mapping)
  15. Ramesh Chinta [Rameshc] 01-Jan-2000
  16. Separate version of IFS for Local Store
  17. --*/
  18. #ifndef _EXIFS_H_
  19. #define _EXIFS_H_
  20. // These globals define LOCAL STORE version of the strings
  21. #define LSIFS_DEVICE_NAME_A "LocalStoreIfsDevice"
  22. // The following constant defines the length of the above name.
  23. #define LSIFS_DEVICE_NAME_A_LENGTH (20)
  24. // The following constant defines the path in the ob namespace
  25. #define DD_LSIFS_FS_DEVICE_NAME_U L"\\Device\\LocalStoreDevice"
  26. #define DD_LSIFS_USERMODE_SHADOW_DEV_NAME_U L"\\??\\LocalStoreIfs"
  27. #define DD_LSIFS_USERMODE_DEV_NAME_U L"\\\\.\\LocalStoreIfs"
  28. #define DD_PUBLIC_MDB_SHARE_LSIFS L"\\??\\WebStorage"
  29. #ifdef LOCALSTORE
  30. #define EXIFS_DEVICE_NAME_A LSIFS_DEVICE_NAME_A
  31. // The following constant defines the length of the above name.
  32. #define EXIFS_DEVICE_NAME_A_LENGTH LSIFS_DEVICE_NAME_A_LENGTH
  33. // The following constant defines the path in the ob namespace
  34. #define DD_EXIFS_FS_DEVICE_NAME_U DD_LSIFS_FS_DEVICE_NAME_U
  35. #else // PLATINUM
  36. // Device name for this driver
  37. #define EXIFS_DEVICE_NAME_A "ExchangeIfsDevice"
  38. // The following constant defines the length of the above name.
  39. #define EXIFS_DEVICE_NAME_A_LENGTH (18)
  40. // The following constant defines the path in the ob namespace
  41. #define DD_EXIFS_FS_DEVICE_NAME_U L"\\Device\\ExchangeIfsDevice"
  42. #endif // PLATINUM
  43. #ifndef EXIFS_DEVICE_NAME
  44. #define EXIFS_DEVICE_NAME
  45. //
  46. // The Devicename string required to access the exchange IFS device
  47. // from User-Mode. Clients should use DD_EXIFS_USERMODE_DEV_NAME_U.
  48. //
  49. // WARNING The next two strings must be kept in sync. Change one and you must
  50. // change the other. These strings have been chosen such that they are
  51. // unlikely to coincide with names of other drivers.
  52. //
  53. // NOTE: These definitions MUST be synced with <ifsuser.h>
  54. //
  55. #ifdef LOCALSTORE
  56. #define DD_EXIFS_USERMODE_SHADOW_DEV_NAME_U DD_LSIFS_USERMODE_SHADOW_DEV_NAME_U
  57. #define DD_EXIFS_USERMODE_DEV_NAME_U DD_LSIFS_USERMODE_DEV_NAME_U
  58. #else // PLATINUM
  59. #define DD_EXIFS_USERMODE_SHADOW_DEV_NAME_U L"\\??\\ExchangeIfs"
  60. #define DD_EXIFS_USERMODE_DEV_NAME_U L"\\\\.\\ExchangeIfs"
  61. #endif // PLATINUM
  62. #define DD_EXIFS_USERMODE_WIN9X_DRIVER_NAME "M:\EA"
  63. //
  64. // Prefix needed before <store-name>\<root-name>
  65. //
  66. #define DD_EXIFS_MINIRDR_PREFIX L"\\;E:"
  67. #define DD_EXIFS_MINIRDR_PREFIX_LEN (sizeof(DD_EXIFS_MINIRDR_PREFIX)-2)
  68. #define DD_EXIFS_MINIRDR_PREFIX_PRIVATE L"\\;F:"
  69. #define DD_EXIFS_MINIRDR_PREFIX_SPECIAL L"\\;G:"
  70. #endif // EXIFS_DEVICE_NAME
  71. #define RDBSS_DRIVER_LOAD_STRING L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\Rdbss"
  72. #define STRING_MISC_POOLTAG ('Strg')
  73. #ifdef LOCALSTORE
  74. #define DD_PUBLIC_MDB_SHARE DD_PUBLIC_MDB_SHARE_LSIFS
  75. #else // PLATINUM
  76. #define DD_PUBLIC_MDB_SHARE L"\\??\\BackOfficeStorage"
  77. #endif // PLATINUM
  78. #define DD_MDB_SHARE_PREFIX L"\\??\\"
  79. #define SYSTEM_PARAMETERS L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion"
  80. #define IFS_DEFAULT_TEMP_DIR L"\\??\\C:\\temp\\"
  81. #define IFS_TEMP_DIR_PREFIX L"\\??\\"
  82. #define IFS_TEMP_DIR_POSTFIX L"\\"
  83. //
  84. // BEGIN WARNING WARNING WARNING WARNING
  85. // The following are from the ddk include files and cannot be changed
  86. #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 // from ddk\inc\ntddk.h
  87. #define METHOD_BUFFERED 0
  88. #define FILE_ANY_ACCESS 0
  89. // END WARNING WARNING WARNING WARNING
  90. #define IOCTL_EXIFS_BASE FILE_DEVICE_NETWORK_FILE_SYSTEM
  91. //
  92. // This is a reserved net root name for use by the global UMR.
  93. //
  94. #define DD_EXUMR_NETROOT_NAME L"\\UMR\\CONTROL"
  95. #define DD_EXUMR_ROOT_DIR DD_EXIFS_MINIRDR_PREFIX \
  96. DD_EXUMR_NETROOT_NAME \
  97. L"\\$ROOT_DIR"
  98. #define _EXIFS_CONTROL_CODE(request, method, access) \
  99. CTL_CODE(IOCTL_EXIFS_BASE, request, method, access)
  100. //
  101. // Signatures of structs
  102. //
  103. #define SCATTER_LIST_SIGNATURE (ULONG) 'rtcS'
  104. #define IOCTL_INITROOT_IN_SIGNATURE (ULONG) 'Itri'
  105. #define IOCTL_SPACEGRANT_IN_SIGNATURE (ULONG) 'Icps'
  106. #define IOCTL_TERMROOT_IN_SIGNATURE (ULONG) 'Itrt'
  107. #define IOCTL_QUERYROOT_OUT_SIGNATURE (ULONG) 'Otrq'
  108. #define IOCTL_QUERYSTATS_IN_SIGNATURE (ULONG) 'IyrQ'
  109. #define IOCTL_QUERYSTATS_OUT_SIGNATURE (ULONG) 'OyrQ'
  110. #define IOCTL_SETENDOFFILE_IN_SIGNATURE (ULONG) 'IfoE'
  111. #define IOCTL_ENABLE_UMR_ROOT_IN_SIGNATURE (ULONG) 'rmUE'
  112. #define IOCTL_DIR_CHNG_REPORT_IN_SIGNATURE (ULONG) 'CriD'
  113. #define IOCTL_EXPUNGE_NAME_IN_SIGNATURE (ULONG) 'ExNi'
  114. #define IOCTL_EXPUNGE_NAME_OUT_SIGNATURE (ULONG) 'ExNo'
  115. #define IOCTL_EXIFS_UMRX_ENABLE_NET_ROOT_OUT_SIGNATURE (ULONG) 'banE'
  116. //
  117. // Data Str shared between user-mode clients like the exchange store
  118. // and Exchange IFS driver.
  119. //
  120. #define MAX_FRAGMENTS (ULONG) 8
  121. //
  122. // This limits the size that the scatter list portion of an EA can be.
  123. // 896 entires will take 896*16=>14336 bytes.
  124. // In a 16K request buffer, this leaves about 2k for the other portion of
  125. // the EA of which the filename is the only other variable component.
  126. //
  127. #define MAX_TOTAL_SLIST_FRAGMENTS (ULONG) 896
  128. //
  129. // If MAX_CONSTANT_ALLOCATIONS have been made in a file, IFS will increase
  130. // the allocation assuming that future constant requests will be made.
  131. //
  132. #define MAX_CONSTANT_ALLOCATIONS (1024*4)
  133. //
  134. // A SCATTER_LIST_ENTRY represents a single fragment in a scatter list.
  135. // All offsets are with respect to the underlying NTFS file for a given
  136. // root. If this file is opened with FILE_FLAG_NO_BUFFERING, the
  137. // following assertions must hold:
  138. //
  139. // 1. offsets must be integer multiples of the volume's sector size
  140. // 2. lengths must be integer multiples of the volume's sector size
  141. //
  142. // Checked builds of the driver will ASSERT if these do not hold
  143. //
  144. // NOTE: Since the Offset is a multiple of the sector size which is
  145. // typically 512, the least significant 8 bits are unused. These bits
  146. // can be used for specifying flags on SLE state eg dirty/committed.
  147. // CAUTION: Any use of these bits should be transparent to IFS clients !
  148. //
  149. typedef struct _SCATTER_LIST_ENTRY_
  150. {
  151. //
  152. // 64-bit offset to fragment data
  153. //
  154. LARGE_INTEGER Offset;
  155. //
  156. // length of fragment data
  157. //
  158. ULONG Length;
  159. //
  160. // reserved
  161. //
  162. ULONG ulReserved;
  163. } SCATTER_LIST_ENTRY, *PSCATTER_LIST_ENTRY;
  164. //
  165. // Bit masks for SLE properties
  166. //
  167. #define RX_SLE_STATE_DIRTY 0x00000001
  168. #define RX_SLE_STATE_MASK 0xFFFFFFFFFFFFFF00
  169. #define RX_LONGLONG(x) (x).QuadPart
  170. #define RX_MASKED_LONGLONG(x) ((x).QuadPart & RX_SLE_STATE_MASK)
  171. //
  172. // SCATTER_LIST represents the scatter list. The array of fragments,
  173. // sle, should in most cases be enough to describe data for a single
  174. // IFS file. In extreme cases (eg very large messages), the overflow
  175. // list should be used. This will ensure good page locality in the
  176. // most common case, since this data is stored in the FCB extension.
  177. //
  178. // If NumFragments is <= MAX_FRAGMENTS, overflow should be NULL.
  179. // If NumFragments is > MAX_FRAGMENTS, overflow should be non-NULL and
  180. // should "point" to (NumFragments - MAX_FRAGMENTS) number of
  181. // SCATTER_LIST_ENTRY's.
  182. //
  183. // NOTE: Apps need to set OverflowOffset (relative to start
  184. // of struct) of the overflow fragments. The IFS uses it to point
  185. // to a list of overflow fragments in kernel space.
  186. //
  187. typedef struct _SCATTER_LIST_
  188. {
  189. //
  190. // signature for this struct
  191. //
  192. ULONG Signature;
  193. //
  194. // number of fragments in scatter list
  195. //
  196. ULONG NumFragments;
  197. //
  198. // TotalBytes ie. valid byte range
  199. // NB: used only when scatter-list is available
  200. // at create time. should *not* be used for GetFileSize()..
  201. //
  202. LARGE_INTEGER TotalBytes;
  203. //
  204. // array of scatter-list-entries
  205. //
  206. SCATTER_LIST_ENTRY sle[MAX_FRAGMENTS];
  207. //
  208. // ptr to overflow list
  209. //
  210. //
  211. // ptr to overflow list
  212. //
  213. union {
  214. struct {
  215. //
  216. // offset to overflow frags
  217. //
  218. ULONG OverflowOffset;
  219. //
  220. // len of overflow data
  221. //
  222. ULONG OverflowLen;
  223. }; // user-mode representation
  224. union {
  225. //
  226. // list of overflow frags
  227. //
  228. LIST_ENTRY OverflowListHead;
  229. //
  230. // pointer to object containing overflow frags
  231. //
  232. PVOID OverflowFragments;
  233. }; // kernel-mode representation
  234. };
  235. //
  236. // Flags for properties of the scatter-list
  237. //
  238. ULONG Flags;
  239. } SCATTER_LIST, *PSCATTER_LIST;
  240. #define IFS_SLIST_FLAGS_LARGE_BUFFER 0x00000001
  241. //
  242. // Linked list of scatter-list entries
  243. //
  244. typedef struct _SCATTER_LIST_NODE {
  245. //
  246. // Scatter-List entry
  247. //
  248. SCATTER_LIST_ENTRY Block;
  249. //
  250. // Doubly linked list of blocks
  251. //
  252. LIST_ENTRY NextBlock;
  253. } SCATTER_LIST_NODE, *PSCATTER_LIST_NODE;
  254. #define SCATTER_LIST_CONTAINING_RECORD( x ) CONTAINING_RECORD( x, SCATTER_LIST_NODE, NextBlock )
  255. //
  256. // IFS file extended attributes -
  257. // NtQueryEaFile() will return the extended attributes
  258. // for an IFS file. Currently, the following extended attributes
  259. // are supported (in order) -
  260. //
  261. // 1. "FileName" - WCHAR : name of IFS file (NULL terminated)
  262. // 2. "Commit" - NTSTATUS: STATUS_SUCCESS if committed
  263. // 3. "InstanceID" - ULONG : NET_ROOT ID for validation
  264. // 4. "Checksum" - ULONG : checksum for FILE_FULL_EA_INFORMATION
  265. // 5. "OpenDeadline" - ULONG : time for which ScatterList is valid
  266. // 6. "Properties" - ULONG : persisted message properties
  267. // 7. "ScatterList" - : scatter list for an IFS file
  268. //
  269. // IFS will return values for all attributes in one call.
  270. // Each of the EA values will be QWORD Aligned.
  271. // If the Buffer supplied is not big enough, IFS will
  272. // return STATUS_BUFFER_OVERFLOW.
  273. //
  274. // NOTE: The "Commit" EA is not actually stored. Callers of
  275. // NtQueryEaFile() can ask for this EA in the EaList param.
  276. // QUERYING FOR THIS EA IS AN IMPLICIT REQUEST TO COMMIT
  277. // RESERVED BYTES FOR THIS IFS HANDLE.....!
  278. //
  279. // NtQueryEa() can (optionally) pass in a value for the "Properties" EA
  280. //
  281. // NtCreateFile() notes:
  282. // This API will use all EAs except the "FileName". Semantics:
  283. // "Commit" - STATUS_SUCESSS => Bytes are committed, dont reuse on close.
  284. // "InstanceID" - used to validate handles belonging to a particular
  285. // instance of a root.
  286. // "Checksum" - validate checksum on EA list.
  287. // "OpenDeadline" - validate time deadline on scatter-list. If the
  288. // time deadline has expired, owner of root may reuse this list.
  289. // "Properties" - is set in the FCB extension
  290. // "ScatterList" - describes pages for file being created.
  291. #define EXIFS_EA_NAME_COMMIT "Commit"
  292. #define EXIFS_EA_NAME_INSTANCE_ID "InstanceID"
  293. #define EXIFS_EA_NAME_CHECKSUM "Checksum"
  294. #define EXIFS_EA_NAME_OPEN_DEADLINE "OpenDeadline"
  295. #define EXIFS_EA_NAME_PROPERTIES "Properties"
  296. #define EXIFS_EA_NAME_FILENAME "FileName"
  297. #define EXIFS_EA_NAME_SCATTER_LIST "ScatterList"
  298. #define EXIFS_MAX_EAS 7
  299. #define EXIFS_CHECKSUM_SEED 0xFEEDFEED
  300. #define EXIFS_INVALID_INSTANCE_ID 0xFFFFFFFF
  301. #ifndef LongAlign
  302. #define LongAlign(Ptr) ( \
  303. ((((ULONG_PTR)(Ptr)) + 3) & 0xfffffffc) \
  304. )
  305. #endif
  306. #define EXIFS_EA_LEN_COMMIT \
  307. LongAlign(FIELD_OFFSET( FILE_FULL_EA_INFORMATION, EaName[0] ) + \
  308. sizeof(EXIFS_EA_NAME_COMMIT) + sizeof(ULONG))
  309. #define EXIFS_EA_LEN_INSTANCE_ID \
  310. LongAlign(FIELD_OFFSET( FILE_FULL_EA_INFORMATION, EaName[0] ) + \
  311. sizeof(EXIFS_EA_NAME_INSTANCE_ID) + sizeof(ULONG))
  312. #define EXIFS_EA_LEN_CHECKSUM \
  313. LongAlign(FIELD_OFFSET( FILE_FULL_EA_INFORMATION, EaName[0] ) + \
  314. sizeof(EXIFS_EA_NAME_CHECKSUM) + sizeof(ULONG))
  315. #define EXIFS_EA_LEN_OPEN_DEADLINE \
  316. LongAlign(FIELD_OFFSET( FILE_FULL_EA_INFORMATION, EaName[0] ) + \
  317. sizeof(EXIFS_EA_NAME_OPEN_DEADLINE) + sizeof(ULONG))
  318. #define EXIFS_EA_LEN_PROPERTIES \
  319. LongAlign(FIELD_OFFSET( FILE_FULL_EA_INFORMATION, EaName[0] ) + \
  320. sizeof(EXIFS_EA_NAME_PROPERTIES) + sizeof(ULONG))
  321. #define EXIFS_EA_LEN_FILENAME(len) \
  322. LongAlign(FIELD_OFFSET( FILE_FULL_EA_INFORMATION, EaName[0] ) + \
  323. sizeof(EXIFS_EA_NAME_FILENAME) + LongAlign(len))
  324. #define EXIFS_EA_LEN_SCATTER_LIST(n) \
  325. LongAlign(FIELD_OFFSET( FILE_FULL_EA_INFORMATION, EaName[0] ) + \
  326. sizeof(EXIFS_EA_NAME_SCATTER_LIST) + \
  327. LongAlign(sizeof(SCATTER_LIST) + \
  328. ((n)>MAX_FRAGMENTS?(n)-MAX_FRAGMENTS:0)*sizeof(SCATTER_LIST_ENTRY)))
  329. #define EXIFS_GET_EA_LEN_COMMIT \
  330. LongAlign(FIELD_OFFSET( FILE_GET_EA_INFORMATION, EaName[0] ) + \
  331. sizeof(EXIFS_EA_NAME_COMMIT))
  332. #define EXIFS_GET_EA_LEN_INSTANCE_ID \
  333. LongAlign(FIELD_OFFSET( FILE_GET_EA_INFORMATION, EaName[0] ) + \
  334. sizeof(EXIFS_EA_NAME_INSTANCE_ID))
  335. #define EXIFS_GET_EA_LEN_PROPERTIES \
  336. LongAlign(FIELD_OFFSET( FILE_GET_EA_INFORMATION, EaName[0] ) + \
  337. sizeof(EXIFS_EA_NAME_PROPERTIES))
  338. //
  339. // IOCTL codes supported by Exchange IFS Device.
  340. //
  341. #define IOCTL_CODE_INITIALIZE_ROOT 100
  342. #define IOCTL_CODE_SPACEGRANT_ROOT 101
  343. #define IOCTL_CODE_SPACEREQ_ROOT 102
  344. #define IOCTL_CODE_TERMINATE_ROOT 103
  345. #define IOCTL_CODE_QUERYSTATS_ROOT 104
  346. #define IOCTL_CODE_SETENDOFFILE_ROOT 105
  347. #define IOCTL_CODE_DIR_CHNG_REPORT 106
  348. #define IOCTL_CODE_INITDRIVE 107
  349. #define IOCTL_CODE_EXPUNGE_NAME 108
  350. #define IOCTL_CODE_SETMAP_ROOT 109
  351. #define IOCTL_CODE_RESETMAP_ROOT 110
  352. //
  353. // WIN32 IOCTL codes
  354. //
  355. #define IOCTL_CODE_UMRX_PACKET 150
  356. #define IOCTL_CODE_UMRX_TEARDOWN 151
  357. #define IOCTL_CODE_UMRX_STARTUP 152
  358. #define IOCTL_CODE_UMRX_ENABLE_NET_ROOT 153
  359. #define IOCTL_CODE_UMRX_DISABLE_NET_ROOT 154
  360. //suspend and resume IOCTLS
  361. #define IOCTL_EXIFS_SETMAP_ROOT _EXIFS_CONTROL_CODE(IOCTL_CODE_SETMAP_ROOT, METHOD_NEITHER, FILE_ANY_ACCESS)
  362. #define IOCTL_EXIFS_RESETMAP_ROOT _EXIFS_CONTROL_CODE(IOCTL_CODE_RESETMAP_ROOT, METHOD_NEITHER, FILE_ANY_ACCESS)
  363. //
  364. // Semantics for using an IFS root:
  365. // 1. App gets a handle (exclusive) to the root via
  366. // CreateFile(\Device\ExchangeIfsDevice\{NodeName}\{RootName}).
  367. // This handle should be opened for overlapped I/O.
  368. //
  369. // 2. App calls overlapped DeviceIoControl() with INITIALIZE_ROOT IOCTL.
  370. //
  371. // 3. This will succeed or fail synchronously. If DeviceIoControl()
  372. // returns TRUE, it succeeded. If it returns FALSE, GetLastError() or
  373. // the NTSTATUS from NtDeviceIoControl() is the error code.
  374. // NOTE: If this IOCTL has NOT been made on a root successfully,
  375. // no I/O on this root will succeed.
  376. //
  377. // 3. At this point, the IFS root has no space grants.
  378. // It is expected that the app will make one or more SPACEGRANT_ROOT
  379. // IOCTLs to grant space on this root. Each of these IOCTLs will finish
  380. // synchronously and return semantics are similar to INITIALIZE_ROOT.
  381. //
  382. // 4. An app should also pend an async SPACEREQ_ROOT IOCTL. Usually, this
  383. // will return with ERROR_IO_PENDING. If this later completes with
  384. // NTSTATUS == EXSTATUS_ROOT_NEEDS_SPACE, the app should make a space
  385. // grant (SPACEGRANT_ROOT) and pend another SPACEREQ_ROOT. This will
  386. // happen if IFS runs out of free space blocks on this root. If the IOCTL
  387. // completes with STATUS_SUCCESS, app should NOT pend another IOCTL.
  388. //
  389. // 5. App calls overlapped DeviceIoControl() with TERMINATE_ROOT IOCTL.
  390. // This will complete any async pended IOCTLs. After this call, the root
  391. // starts shutting down. This IOCTL will complete synchronously.
  392. // NOTE: Once terminated, a root cannot be initialized again.
  393. //
  394. // 6. App closes handle to root. Note: Handle to root needs to be kept
  395. // open across life of root. Once the root handle is closed, the IFS
  396. // root has no free space. All of the free space allocated to the
  397. // root before TERMINATE needs to be reclaimed by the app.
  398. // The app can now re-create this root starting at step1.
  399. //
  400. // 7. If the app with an exclusive handle to a root dies, the root will
  401. // be marked 'bad' and new I/Os (including IOCTLs) to this root will
  402. // fail. Over time, outstanding handles on this root will go away and
  403. // eventually the root will die. At this point, an app can re-create
  404. // the root starting at step 1.
  405. //
  406. //
  407. // IOCTL to initialize a net root. This results in creating an entry
  408. // in the RootMapTable. There is one entry in this table for every
  409. // secondary NTFS file managed by the IFS driver.
  410. // NOTE: IFS will attempt to get an exclusive handle to the underlying
  411. // file. This ensures that all operations on the underlying file are
  412. // done through IFS.
  413. //
  414. // Following is the IOCTL definition and associated structs.
  415. //
  416. #define IOCTL_EXIFS_INITIALIZE_ROOT _EXIFS_CONTROL_CODE(IOCTL_CODE_INITIALIZE_ROOT, METHOD_NEITHER, FILE_ANY_ACCESS)
  417. //
  418. // InBuffer struct
  419. //
  420. typedef struct _IOCTL_INITROOT_IN
  421. {
  422. //
  423. // Signature for this struct
  424. //
  425. ULONG Signature;
  426. //
  427. // Underlying Ntfs filename for this root.
  428. // Length is the size in bytes of the name.
  429. // Offset should be from the start of this struct.
  430. //
  431. USHORT NtfsFileNameLength;
  432. USHORT NtfsFileNameOffset;
  433. //
  434. // Flags to control access to Ntfs file
  435. //
  436. ULONG NtfsFlags;
  437. //
  438. // Allocation unit for this root. Min is 4K
  439. //
  440. ULONG AllocationUnit;
  441. //
  442. // root InstanceID
  443. //
  444. ULONG InstanceID;
  445. } IOCTL_INITROOT_IN, *PIOCTL_INITROOT_IN;
  446. typedef struct _IOCTL_INITROOT_IN_EX
  447. {
  448. IOCTL_INITROOT_IN InitRoot;
  449. WCHAR RootName[MAX_PATH];
  450. }IOCTL_INITROOT_IN_EX, *PIOCTL_INITROOT_IN_EX;
  451. //
  452. // IOCTL to grant space to an initialized net root.
  453. // Following is the IOCTL definition and associated structs.
  454. //
  455. #define IOCTL_EXIFS_SPACEGRANT_ROOT _EXIFS_CONTROL_CODE(IOCTL_CODE_SPACEGRANT_ROOT, METHOD_NEITHER, FILE_ANY_ACCESS)
  456. //
  457. // Free space is granted in chunks. The root owner decides
  458. // what the maximum chunk size is.
  459. //
  460. #define MAX_EXIFS_FREEBLOCK_SIZE 0x100000
  461. //
  462. // Default chunk size
  463. //
  464. #define EXIFS_DEFAULT_CHUNK_SIZE 0x40000
  465. //
  466. // MAXIMUM file size allowed by IFS
  467. //
  468. #define EXIFS_MAXIMUM_FILESIZE 0x7FFFFFFF
  469. //
  470. // InBuffer struct
  471. //
  472. typedef struct _IOCTL_SPACEGRANT_IN
  473. {
  474. //
  475. // Signature for this struct
  476. //
  477. ULONG Signature;
  478. //
  479. // Scatter-list of free space - must be last
  480. //
  481. SCATTER_LIST FreeSpaceList;
  482. } IOCTL_SPACEGRANT_IN, *PIOCTL_SPACEGRANT_IN;
  483. typedef struct _IOCTL_SPACEGRANT_IN_EX
  484. {
  485. //
  486. // Signature for this struct
  487. //
  488. ULONG Signature;
  489. WCHAR RootName[MAX_PATH];
  490. SCATTER_LIST *W9xFreeSpaceList;
  491. } IOCTL_SPACEGRANT_IN_EX, *PIOCTL_SPACEGRANT_IN_EX;
  492. //
  493. // IOCTL to allow IFS to request space on an initialized net root.
  494. // Following is the IOCTL definition and associated structs.
  495. //
  496. #define IOCTL_EXIFS_SPACEREQ_ROOT _EXIFS_CONTROL_CODE(IOCTL_CODE_SPACEREQ_ROOT, METHOD_NEITHER, FILE_ANY_ACCESS)
  497. typedef struct _IOCTL_SPACEREQ_ROOT_IN
  498. {
  499. WCHAR RootName[MAX_PATH];
  500. }IOCTL_SPACEREQ_ROOT_IN, *PIOCTL_SPACEREQ_ROOT_IN;
  501. //
  502. // IOCTL to terminate a net root. This results in deleting an entry
  503. // in the RootMapTable. There is one entry in this table for every
  504. // secondary NTFS file managed by the IFS driver. Following is the IOCTL
  505. // definition and associated structs.
  506. //
  507. #define IOCTL_EXIFS_TERMINATE_ROOT _EXIFS_CONTROL_CODE(IOCTL_CODE_TERMINATE_ROOT, METHOD_BUFFERED, FILE_ANY_ACCESS)
  508. //
  509. // InBuffer struct
  510. //
  511. typedef struct _IOCTL_TERMROOT_IN
  512. {
  513. //
  514. // Signature for this struct
  515. //
  516. ULONG Signature;
  517. //
  518. // Mode of shutdown
  519. //
  520. ULONG Mode;
  521. } IOCTL_TERMROOT_IN, *PIOCTL_TERMROOT_IN;
  522. typedef struct _IOCTL_TERMROOT_IN_EX
  523. {
  524. IOCTL_TERMROOT_IN TermRoot;
  525. WCHAR RootName[MAX_PATH];
  526. } IOCTL_TERMROOT_IN_EX, *PIOCTL_TERMROOT_IN_EX;
  527. #if 0
  528. //
  529. // IOCTL to query a net root for current free space. Currently, NYI.
  530. // The goal for this is to allow app to retrieve fragmented free lists
  531. // in order to defrag.
  532. // Following is the IOCTL definition and associated structs.
  533. //
  534. #define IOCTL_EXIFS_QUERY_ROOT _EXIFS_CONTROL_CODE(IOCTL_CODE_QUERY_ROOT, METHOD_BUFFERED, FILE_ANY_ACCESS)
  535. //
  536. // OutBuffer struct
  537. //
  538. typedef struct _IOCTL_QUERYROOT_OUT
  539. {
  540. //
  541. // Signature for this struct
  542. //
  543. ULONG Signature;
  544. //
  545. // Return code
  546. //
  547. NTSTATUS IoctlStatus;
  548. //
  549. // Free space list for this root
  550. //
  551. SCATTER_LIST FreeSpaceList;
  552. } IOCTL_QUERYROOT_OUT, *PIOCTL_QUERYROOT_OUT;
  553. #endif
  554. //
  555. // IOCTL to query stats for a net root.
  556. //
  557. #define IOCTL_EXIFS_QUERYSTATS_ROOT _EXIFS_CONTROL_CODE(IOCTL_CODE_QUERYSTATS_ROOT, METHOD_BUFFERED, FILE_ANY_ACCESS)
  558. #define IOCTL_QUERYSTATS_FILENAME L"\\$PERFMON$"
  559. //
  560. // Statistics for a net root
  561. //
  562. typedef struct _EXIFS_NETROOT_STATS {
  563. //
  564. // Number of Creates
  565. //
  566. ULONG NumberOfCreates;
  567. //
  568. // Number of Opens
  569. //
  570. ULONG NumberOfOpens;
  571. //
  572. // Number of Collapsed Opens
  573. //
  574. ULONG NumberOfCollapsedOpens;
  575. //
  576. // Number of IRP Reads
  577. //
  578. ULONG NumberOfIrpReads;
  579. //
  580. // Number of MDL Reads
  581. //
  582. ULONG NumberOfMdlReads;
  583. //
  584. // Number of Writes
  585. //
  586. ULONG NumberOfWrites;
  587. //
  588. // Number of Close
  589. //
  590. ULONG NumberOfClose;
  591. //
  592. // Number of FCB close
  593. //
  594. ULONG NumberOfFCBClose;
  595. //
  596. // Total Bytes Read
  597. //
  598. LARGE_INTEGER TotalBytesRead;
  599. //
  600. // Total Bytes Written
  601. //
  602. LARGE_INTEGER TotalBytesWritten;
  603. //
  604. // Reserved Bytes ie on primary free list
  605. //
  606. LARGE_INTEGER ReservedBytes;
  607. //
  608. // Orphaned Bytes ie on secondary free list
  609. // Total Available Bytes = ReservedBytes + OrphanedBytes
  610. //
  611. LARGE_INTEGER OrphanedBytes;
  612. } EXIFS_NETROOT_STATS, *PEXIFS_NETROOT_STATS;
  613. //
  614. // Cheap stats do not cause locks to be acquired.
  615. // Other modes may need locks.
  616. //
  617. #define EXIFS_QUERYSTATS_CHEAP 1
  618. #define EXIFS_QUERYSTATS_MEDIUM 2
  619. #define EXIFS_QUERYSTATS_ALL 3
  620. //
  621. // InBuffer struct
  622. //
  623. typedef struct _IOCTL_QUERYSTATS_IN
  624. {
  625. //
  626. // Signature for this struct
  627. //
  628. ULONG Signature;
  629. //
  630. // Granularity of stats
  631. //
  632. ULONG Granularity;
  633. WCHAR RootName[MAX_PATH];
  634. } IOCTL_QUERYSTATS_IN, *PIOCTL_QUERYSTATS_IN;
  635. //
  636. // OutBuffer struct
  637. //
  638. typedef struct _IOCTL_QUERYSTATS_OUT
  639. {
  640. //
  641. // Signature for this struct
  642. //
  643. ULONG Signature;
  644. //
  645. // Return code
  646. //
  647. NTSTATUS IoctlStatus;
  648. //
  649. // Stats data
  650. //
  651. EXIFS_NETROOT_STATS RootStats;
  652. } IOCTL_QUERYSTATS_OUT, *PIOCTL_QUERYSTATS_OUT;
  653. //
  654. // IOCTL to set end of file (truncate or extend) for root underlying file.
  655. // It is callers responsibility to zero extended length when extending.
  656. //
  657. #define IOCTL_EXIFS_SETENDOFFILE_ROOT _EXIFS_CONTROL_CODE(IOCTL_CODE_SETENDOFFILE_ROOT, METHOD_BUFFERED, FILE_ANY_ACCESS)
  658. //
  659. // InBuffer struct
  660. //
  661. typedef struct _IOCTL_SETENDOFFILE_IN
  662. {
  663. //
  664. // Signature for this struct
  665. //
  666. ULONG Signature;
  667. //
  668. // New EOF
  669. //
  670. LARGE_INTEGER EndOfFile;
  671. } IOCTL_SETENDOFFILE_IN, *PIOCTL_SETENDOFFILE_IN;
  672. typedef struct _IOCTL_SETENDOFFILE_IN_EX
  673. {
  674. IOCTL_SETENDOFFILE_IN SetEndOfFile;
  675. WCHAR RootName[MAX_PATH];
  676. } IOCTL_SETENDOFFILE_IN_EX, *PIOCTL_SETENDOFFILE_IN_EX;
  677. //
  678. // IOCTL to send down reports about changes in directories that exifs.sys doesn't
  679. // know about.
  680. //
  681. #define IOCTL_EXIFS_DIR_CHNG_REPORT _EXIFS_CONTROL_CODE(IOCTL_CODE_DIR_CHNG_REPORT, METHOD_BUFFERED, FILE_ANY_ACCESS)
  682. //
  683. // InBuffer struct
  684. //
  685. typedef struct _IOCTL_DIR_CHNG_REPORT_IN
  686. {
  687. //
  688. // Signature for this struct
  689. //
  690. ULONG Signature;
  691. //
  692. // Action
  693. //
  694. ULONG ulAction;
  695. //
  696. // FilterMatch
  697. //
  698. ULONG ulFilterMatch;
  699. //
  700. // Path length (bytes)
  701. //
  702. ULONG cbPath;
  703. //
  704. // Path (unicode)
  705. //
  706. WCHAR rgwchPath[1];
  707. } IOCTL_DIR_CHNG_REPORT_IN, *PIOCTL_DIR_CHNG_REPORT_IN;
  708. //
  709. // IOCTL to send request to close and unlock namespace
  710. //
  711. #define IOCTL_EXIFS_EXPUNGE_NAME _EXIFS_CONTROL_CODE( IOCTL_CODE_EXPUNGE_NAME, METHOD_BUFFERED, FILE_ANY_ACCESS )
  712. //
  713. // InBuffer struct
  714. //
  715. typedef struct _IOCTL_EXPUNGE_NAME_IN
  716. {
  717. //
  718. // Signature for this struct
  719. //
  720. ULONG Signature;
  721. //
  722. // Path length (bytes)
  723. //
  724. ULONG cbPath;
  725. //
  726. // Path (unicode)
  727. //
  728. WCHAR rgwchPath[ 1 ];
  729. } IOCTL_EXPUNGE_NAME_IN, *PIOCTL_EXPUNGE_NAME_IN;
  730. //
  731. // OutBuffer struct
  732. //
  733. typedef struct _IOCTL_EXPUNGE_NAME_OUT
  734. {
  735. //
  736. // Signature for this struct
  737. //
  738. ULONG Signature;
  739. //
  740. // Status of operation
  741. //
  742. NTSTATUS Status;
  743. } IOCTL_EXPUNGE_NAME_OUT, *PIOCTL_EXPUNGE_NAME_OUT;
  744. //
  745. // IOCTLs for UMR piece -
  746. // 1. UMRX_PACKET IOCTLs will be pended for WORK requests/responses. These
  747. // need to be pended on the Root\WIN32ROOT\$ namespace. The net root
  748. // needs to have been initialized already.
  749. //
  750. // 2. TEARDOWN IOCTL will be sent when the UMR engine on the root needs to
  751. // be shutdown. This should be done before the root is terminated.
  752. // NOTE: process shutdown is auto-detected by the UMR engine.
  753. //
  754. // 3. STARTUP IOCTL will allow worker threads to queue up on the UMRX's KQUEUE
  755. // It complements the TEARDOWN IOCTL
  756. //
  757. // 4. ENABLE_NET_ROOT IOCTL allows win32 usermode requests to be made from the
  758. // netroot that this ioctl is being done on.
  759. //
  760. // 5. DISABLE_NET_ROOT IOCTL disallows win32 usermode requests to be made form the
  761. // newroot that this ioctl is done on. Once the call to DeviceIoControl() returns
  762. // there will be no more user mode requests made on that net root.
  763. //
  764. #define IOCTL_EXIFS_UMRX_PACKET _EXIFS_CONTROL_CODE(IOCTL_CODE_UMRX_PACKET, METHOD_BUFFERED, FILE_ANY_ACCESS)
  765. #define IOCTL_EXIFS_UMRX_TEARDOWN _EXIFS_CONTROL_CODE(IOCTL_CODE_UMRX_TEARDOWN, METHOD_BUFFERED, FILE_ANY_ACCESS)
  766. #define IOCTL_EXIFS_UMRX_STARTUP _EXIFS_CONTROL_CODE(IOCTL_CODE_UMRX_STARTUP, METHOD_BUFFERED, FILE_ANY_ACCESS)
  767. //
  768. // When enabling NetRoot's we get the current version number the netroot has squirreled away from when Jet initialized it !
  769. //
  770. #define IOCTL_EXIFS_UMRX_ENABLE_NET_ROOT _EXIFS_CONTROL_CODE(IOCTL_CODE_UMRX_ENABLE_NET_ROOT, METHOD_BUFFERED, FILE_ANY_ACCESS)
  771. typedef struct _IOCTL_EXIFS_UMRX_ENABLE_NET_ROOT_OUT
  772. {
  773. //
  774. // Signature for this structre !
  775. //
  776. ULONG Signature ;
  777. //
  778. // Version of the netroot that should, be put in future open requests !
  779. //
  780. ULONG InstanceId ;
  781. //
  782. // Pointer to the netroot that should be put in future open responses !
  783. //
  784. ULONG NetRootPointer ;
  785. //
  786. // Save jets allocation size
  787. //
  788. ULONG AllocationUnit;
  789. } IOCTL_EXIFS_UMRX_ENABLE_NET_ROOT_OUT, *PIOCTL_EXIFS_UMRX_ENABLE_NET_ROOT_OUT ;
  790. #define IOCTL_EXIFS_UMRX_DISABLE_NET_ROOT _EXIFS_CONTROL_CODE(IOCTL_CODE_UMRX_DISABLE_NET_ROOT, METHOD_BUFFERED, FILE_ANY_ACCESS)
  791. //
  792. // IMPORTANT NOTE :
  793. //
  794. // IOCTL_WIN32_FILENAME is EXACTLY 8 characters long because we will OVERWRITE
  795. // it in the filenames that we put in the FCB. We will replace the 'IN32ROOT'
  796. // portion with the hexadecimal version id coming off of the netroot for the
  797. // particular file.
  798. // Why ? Because this will cause dead FCB's to not hurt users across MDB Start/Stops
  799. //
  800. #define IOCTL_WIN32_FILENAME_START L"\\W"
  801. #define IOCTL_WIN32_FILENAME L"\\WIN32ROOT"
  802. #define WIN32_PREFIX_LEN (sizeof(IOCTL_WIN32_FILENAME)-sizeof(WCHAR))
  803. #define WIN32_DIGIT_LEN (sizeof(IOCTL_WIN32_FILENAME) - sizeof(IOCTL_WIN32_FILENAME_START))
  804. #define IOCTL_WIN32_UMRX_NAME L"\\WIN32ROOT\\$"
  805. #define UMRX_PREFIX_LEN (sizeof(IOCTL_WIN32_UMRX_NAME)-2)
  806. #define IFSWIN32SIGNATURE 'WIN3'
  807. #define IFSJETSIGNATURE 'AJET'
  808. typedef struct _IFS_CREATE_RESPONSE_
  809. {
  810. DWORD Signature;
  811. NTSTATUS Status;
  812. ULONG EaLength;
  813. HANDLE hResponseContext;
  814. PWSTR pEaSysBuffer;
  815. PWSTR Win32Name;
  816. }IFS_CREATE_RESPONSE, *PIFS_CREATE_RESPONSE;
  817. #define IOCTL_EXIFS_REGISTER_UMR 200
  818. typedef struct _SETEA_INFORMATION_
  819. {
  820. PVOID EaBuffer;
  821. ULONG EaLength;
  822. WCHAR FcbName[MAX_PATH * sizeof(WCHAR)];
  823. }IOCTL_SETEA_INFORMATION_IN, *PIOCTL_SETEA_INFORMATION_IN;
  824. #define IOCTL_CODE_SET_EA 900
  825. #define IOCTL_EXIFS_SET_EA _EXIFS_CONTROL_CODE(IOCTL_CODE_SET_EA, METHOD_BUFFERED, FILE_ANY_ACCESS)
  826. typedef struct _GETEA_INFORMATION_
  827. {
  828. PVOID EaBuffer;
  829. ULONG EaLength;
  830. WCHAR FcbName[MAX_PATH];
  831. }IOCTL_GETEA_INFORMATION_IN, *PIOCTL_GETEA_INFORMATION_IN;
  832. #define IOCTL_CODE_QUERY_EA 1000
  833. #define IOCTL_EXIFS_QUERY_EA _EXIFS_CONTROL_CODE(IOCTL_CODE_QUERY_EA, METHOD_BUFFERED, FILE_ANY_ACCESS)
  834. #endif // _EXIFS_H_