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.

1776 lines
49 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation
  4. //
  5. // File: fastio.c
  6. //
  7. // Contents: Routines to implement Fast IO
  8. //
  9. // Classes:
  10. //
  11. // Functions:
  12. //
  13. // History: 8/11/93 Milans created
  14. //
  15. //-----------------------------------------------------------------------------
  16. #include "dfsprocs.h"
  17. #include "fsctrl.h"
  18. #include "fastio.h"
  19. #include "fcbsup.h"
  20. #define Dbg (DEBUG_TRACE_FASTIO)
  21. BOOLEAN
  22. DfsFastIoCheckIfPossible (
  23. FILE_OBJECT *pFileObject,
  24. LARGE_INTEGER *pOffset,
  25. ULONG Length,
  26. BOOLEAN fWait,
  27. ULONG LockKey,
  28. BOOLEAN fCheckForRead,
  29. IO_STATUS_BLOCK *pIoStatusBlock,
  30. DEVICE_OBJECT *DeviceObject
  31. );
  32. BOOLEAN
  33. DfsFastIoRead(
  34. IN struct _FILE_OBJECT *FileObject,
  35. IN PLARGE_INTEGER FileOffset,
  36. IN ULONG Length,
  37. IN BOOLEAN Wait,
  38. IN ULONG LockKey,
  39. OUT PVOID Buffer,
  40. OUT PIO_STATUS_BLOCK IoStatus,
  41. DEVICE_OBJECT *DeviceObject
  42. );
  43. BOOLEAN
  44. DfsFastIoWrite(
  45. IN struct _FILE_OBJECT *FileObject,
  46. IN PLARGE_INTEGER FileOffset,
  47. IN ULONG Length,
  48. IN BOOLEAN Wait,
  49. IN ULONG LockKey,
  50. IN PVOID Buffer,
  51. OUT PIO_STATUS_BLOCK IoStatus,
  52. DEVICE_OBJECT *DeviceObject
  53. );
  54. BOOLEAN
  55. DfsFastIoQueryBasicInfo(
  56. IN struct _FILE_OBJECT *FileObject,
  57. IN BOOLEAN Wait,
  58. OUT PFILE_BASIC_INFORMATION Buffer,
  59. OUT PIO_STATUS_BLOCK IoStatus,
  60. DEVICE_OBJECT *DeviceObject
  61. );
  62. BOOLEAN
  63. DfsFastIoQueryStandardInfo(
  64. IN struct _FILE_OBJECT *FileObject,
  65. IN BOOLEAN Wait,
  66. OUT PFILE_STANDARD_INFORMATION Buffer,
  67. OUT PIO_STATUS_BLOCK IoStatus,
  68. DEVICE_OBJECT *DeviceObject
  69. );
  70. BOOLEAN
  71. DfsFastIoLock(
  72. IN struct _FILE_OBJECT *FileObject,
  73. IN PLARGE_INTEGER FileOffset,
  74. IN PLARGE_INTEGER Length,
  75. PEPROCESS ProcessId,
  76. ULONG Key,
  77. BOOLEAN FailImmediately,
  78. BOOLEAN ExclusiveLock,
  79. OUT PIO_STATUS_BLOCK IoStatus,
  80. DEVICE_OBJECT *DeviceObject
  81. );
  82. BOOLEAN
  83. DfsFastIoUnlockSingle(
  84. IN struct _FILE_OBJECT *FileObject,
  85. IN PLARGE_INTEGER FileOffset,
  86. IN PLARGE_INTEGER Length,
  87. PEPROCESS ProcessId,
  88. ULONG Key,
  89. OUT PIO_STATUS_BLOCK IoStatus,
  90. DEVICE_OBJECT *DeviceObject
  91. );
  92. BOOLEAN
  93. DfsFastIoUnlockAll(
  94. IN struct _FILE_OBJECT *FileObject,
  95. PEPROCESS ProcessId,
  96. OUT PIO_STATUS_BLOCK IoStatus,
  97. DEVICE_OBJECT *DeviceObject
  98. );
  99. BOOLEAN
  100. DfsFastIoUnlockAllByKey(
  101. IN struct _FILE_OBJECT *FileObject,
  102. PVOID ProcessId,
  103. ULONG Key,
  104. OUT PIO_STATUS_BLOCK IoStatus,
  105. DEVICE_OBJECT *DeviceObject
  106. );
  107. BOOLEAN
  108. DfsFastIoDeviceControl(
  109. IN struct _FILE_OBJECT *FileObject,
  110. IN BOOLEAN Wait,
  111. IN PVOID InputBuffer OPTIONAL,
  112. IN ULONG InputBufferLength,
  113. OUT PVOID OutputBuffer OPTIONAL,
  114. IN ULONG OutputBufferLength,
  115. IN ULONG IoControlCode,
  116. OUT PIO_STATUS_BLOCK IoStatus,
  117. DEVICE_OBJECT *DeviceObject);
  118. VOID
  119. DfsFastIoDetachDevice(
  120. IN PDEVICE_OBJECT SourceDevice,
  121. IN PDEVICE_OBJECT TargetDevice);
  122. BOOLEAN
  123. DfsFastIoQueryNetworkOpenInfo(
  124. IN PFILE_OBJECT FileObject,
  125. IN BOOLEAN Wait,
  126. OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
  127. OUT PIO_STATUS_BLOCK IoStatus,
  128. IN PDEVICE_OBJECT DeviceObject);
  129. BOOLEAN
  130. DfsFastIoMdlRead(
  131. IN PFILE_OBJECT FileObject,
  132. IN PLARGE_INTEGER FileOffset,
  133. IN ULONG Length,
  134. IN ULONG LockKey,
  135. OUT PMDL *MdlChain,
  136. OUT PIO_STATUS_BLOCK IoStatus,
  137. IN PDEVICE_OBJECT DeviceObject);
  138. BOOLEAN
  139. DfsFastIoMdlReadComplete(
  140. IN PFILE_OBJECT FileObject,
  141. IN PMDL MdlChain,
  142. IN PDEVICE_OBJECT DeviceObject
  143. );
  144. BOOLEAN
  145. DfsFastIoPrepareMdlWrite(
  146. IN PFILE_OBJECT FileObject,
  147. IN PLARGE_INTEGER FileOffset,
  148. IN ULONG Length,
  149. IN ULONG LockKey,
  150. OUT PMDL *MdlChain,
  151. OUT PIO_STATUS_BLOCK IoStatus,
  152. IN PDEVICE_OBJECT DeviceObject
  153. );
  154. BOOLEAN
  155. DfsFastIoMdlWriteComplete(
  156. IN PFILE_OBJECT FileObject,
  157. IN PLARGE_INTEGER FileOffset,
  158. IN PMDL MdlChain,
  159. IN PDEVICE_OBJECT DeviceObject
  160. );
  161. BOOLEAN
  162. DfsFastIoReadCompressed(
  163. IN PFILE_OBJECT FileObject,
  164. IN PLARGE_INTEGER FileOffset,
  165. IN ULONG Length,
  166. IN ULONG LockKey,
  167. OUT PVOID Buffer,
  168. OUT PMDL *MdlChain,
  169. OUT PIO_STATUS_BLOCK IoStatus,
  170. OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
  171. IN ULONG CompressedDataInfoLength,
  172. IN PDEVICE_OBJECT DeviceObject
  173. );
  174. BOOLEAN
  175. DfsFastIoWriteCompressed(
  176. IN PFILE_OBJECT FileObject,
  177. IN PLARGE_INTEGER FileOffset,
  178. IN ULONG Length,
  179. IN ULONG LockKey,
  180. IN PVOID Buffer,
  181. OUT PMDL *MdlChain,
  182. OUT PIO_STATUS_BLOCK IoStatus,
  183. IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
  184. IN ULONG CompressedDataInfoLength,
  185. IN PDEVICE_OBJECT DeviceObject);
  186. BOOLEAN
  187. DfsFastIoMdlReadCompleteCompressed(
  188. IN PFILE_OBJECT FileObject,
  189. IN PMDL MdlChain,
  190. IN PDEVICE_OBJECT DeviceObject);
  191. BOOLEAN
  192. DfsFastIoMdlWriteCompleteCompressed(
  193. IN PFILE_OBJECT FileObject,
  194. IN PLARGE_INTEGER FileOffset,
  195. IN PMDL MdlChain,
  196. IN PDEVICE_OBJECT DeviceObject);
  197. PFAST_IO_DISPATCH
  198. DfsFastIoLookup(
  199. IN FILE_OBJECT *pFileObject,
  200. IN DEVICE_OBJECT *DeviceObject,
  201. IN PDEVICE_OBJECT *targetVdo);
  202. NTSTATUS
  203. DfsPreAcquireForSectionSynchronization(
  204. IN PFS_FILTER_CALLBACK_DATA Data,
  205. OUT PVOID *CompletionContext);
  206. NTSTATUS
  207. DfsPreReleaseForSectionSynchronization(
  208. IN PFS_FILTER_CALLBACK_DATA Data,
  209. OUT PVOID *CompletionContext);
  210. NTSTATUS
  211. DfsPreAcquireForModWrite(
  212. IN PFS_FILTER_CALLBACK_DATA Data,
  213. OUT PVOID *CompletionContext);
  214. NTSTATUS
  215. DfsPreReleaseForModWrite(
  216. IN PFS_FILTER_CALLBACK_DATA Data,
  217. OUT PVOID *CompletionContext);
  218. NTSTATUS
  219. DfsPreAcquireForCcFlush(
  220. IN PFS_FILTER_CALLBACK_DATA Data,
  221. OUT PVOID *CompletionContext);
  222. NTSTATUS
  223. DfsPreReleaseForCcFlush(
  224. IN PFS_FILTER_CALLBACK_DATA Data,
  225. OUT PVOID *CompletionContext);
  226. #ifdef ALLOC_PRAGMA
  227. #pragma alloc_text( PAGE, DfsFastIoCheckIfPossible )
  228. #pragma alloc_text( PAGE, DfsFastIoRead )
  229. #pragma alloc_text( PAGE, DfsFastIoWrite )
  230. #pragma alloc_text( PAGE, DfsFastIoQueryBasicInfo )
  231. #pragma alloc_text( PAGE, DfsFastIoQueryStandardInfo )
  232. #pragma alloc_text( PAGE, DfsFastIoLock )
  233. #pragma alloc_text( PAGE, DfsFastIoUnlockSingle )
  234. #pragma alloc_text( PAGE, DfsFastIoUnlockAll )
  235. #pragma alloc_text( PAGE, DfsFastIoUnlockAllByKey )
  236. #pragma alloc_text( PAGE, DfsFastIoDeviceControl )
  237. #pragma alloc_text( PAGE, DfsFastIoDetachDevice )
  238. #pragma alloc_text( PAGE, DfsFastIoQueryNetworkOpenInfo )
  239. #pragma alloc_text( PAGE, DfsFastIoMdlRead )
  240. #pragma alloc_text( PAGE, DfsFastIoMdlReadComplete )
  241. #pragma alloc_text( PAGE, DfsFastIoPrepareMdlWrite )
  242. #pragma alloc_text( PAGE, DfsFastIoMdlWriteComplete )
  243. #pragma alloc_text( PAGE, DfsFastIoReadCompressed )
  244. #pragma alloc_text( PAGE, DfsFastIoWriteCompressed )
  245. #pragma alloc_text( PAGE, DfsFastIoMdlReadCompleteCompressed )
  246. #pragma alloc_text( PAGE, DfsFastIoMdlWriteCompleteCompressed )
  247. #pragma alloc_text( PAGE, DfsFastIoLookup )
  248. #pragma alloc_text( PAGE, DfsPreAcquireForSectionSynchronization )
  249. #pragma alloc_text( PAGE, DfsPreReleaseForSectionSynchronization )
  250. #pragma alloc_text( PAGE, DfsPreAcquireForModWrite )
  251. #pragma alloc_text( PAGE, DfsPreReleaseForModWrite )
  252. #pragma alloc_text( PAGE, DfsPreAcquireForCcFlush )
  253. #pragma alloc_text( PAGE, DfsPreReleaseForCcFlush )
  254. #endif // ALLOC_PRAGMA
  255. //
  256. // Note: We don't register the 6 Acquire/Release FastIo Dispatches here
  257. // because we filter this operations through the FsFilterCallback interface
  258. // which allows DFS to interop better with file system filters.
  259. //
  260. FAST_IO_DISPATCH FastIoDispatch =
  261. {
  262. sizeof(FAST_IO_DISPATCH),
  263. DfsFastIoCheckIfPossible, // CheckForFastIo
  264. DfsFastIoRead, // FastIoRead
  265. DfsFastIoWrite, // FastIoWrite
  266. DfsFastIoQueryBasicInfo, // FastIoQueryBasicInfo
  267. DfsFastIoQueryStandardInfo, // FastIoQueryStandardInfo
  268. DfsFastIoLock, // FastIoLock
  269. DfsFastIoUnlockSingle, // FastIoUnlockSingle
  270. DfsFastIoUnlockAll, // FastIoUnlockAll
  271. DfsFastIoUnlockAllByKey, // FastIoUnlockAllByKey
  272. NULL, // FastIoDeviceControl
  273. NULL, // AcquireFileForNtCreateSection
  274. NULL, // ReleaseFileForNtCreateSection
  275. DfsFastIoDetachDevice, // FastIoDetachDevice
  276. DfsFastIoQueryNetworkOpenInfo, // FastIoQueryNetworkOpenInfo
  277. NULL, // AcquireForModWrite
  278. DfsFastIoMdlRead, // MdlRead
  279. DfsFastIoMdlReadComplete, // MdlReadComplete
  280. DfsFastIoPrepareMdlWrite, // PrepareMdlWrite
  281. DfsFastIoMdlWriteComplete, // MdlWriteComplete
  282. DfsFastIoReadCompressed, // FastIoReadCompressed
  283. DfsFastIoWriteCompressed, // FastIoWriteCompressed
  284. DfsFastIoMdlReadCompleteCompressed, // MdlReadCompleteCompressed
  285. DfsFastIoMdlWriteCompleteCompressed,// MdlWriteCompleteCompressed
  286. NULL, // FastIoQueryOpen
  287. NULL, // ReleaseForModWrite
  288. NULL, // AcquireForCcFlush
  289. NULL, // ReleaseForCcFlush
  290. };
  291. //
  292. // NOTE: Dfs has been changed to use the FsFilter interfaces to intercept the
  293. // Acquire/Release calls traditionally supported via the FastIo path
  294. // to provide better file system filter driver support.
  295. //
  296. // By hooking these operations via the FsFilter interfaces, Dfs is able
  297. // to propogate the additional information provided through these
  298. // interfaces to file system filters as it redirects the operation to
  299. // a different driver stack (such as the device stack for
  300. // LanmanRedirector or WebDavRedirector).
  301. //
  302. // This also provides a more consistent interface for these
  303. // Acquire/Release operations for file system filter drivers. With Dfs
  304. // supporting this interface, filters will only get called through the
  305. // FsFilter interfaces for these operations on both local and remote
  306. // file systems.
  307. //
  308. FS_FILTER_CALLBACKS FsFilterCallbacks =
  309. {
  310. sizeof( FS_FILTER_CALLBACKS ),
  311. 0,
  312. DfsPreAcquireForSectionSynchronization, // PreAcquireForSectionSynchronization
  313. NULL, // PostAcquireForSectionSynchronization
  314. DfsPreReleaseForSectionSynchronization, // PreReleaseForSectionSynchronization
  315. NULL, // PostReleaseForSectionSynchronization
  316. DfsPreAcquireForCcFlush, // PreAcquireForCcFlush
  317. NULL, // PostAcquireForCcFlush
  318. DfsPreReleaseForCcFlush, // PreReleaseForCcFlush
  319. NULL, // PostReleaseForCcFlush
  320. DfsPreAcquireForModWrite, // PreAcquireForModWrite
  321. NULL, // PostAcquireForModWrite
  322. DfsPreReleaseForModWrite, // PreReleaseForModWrite
  323. NULL // PostReleaseForModWrite
  324. };
  325. //
  326. // Macro to see if a PFAST_IO_DISPATCH has a particular field
  327. //
  328. #define IS_VALID_INDEX(pfio, e) \
  329. ((pfio != NULL) && \
  330. (pfio->SizeOfFastIoDispatch >= \
  331. (offsetof(FAST_IO_DISPATCH, e) + sizeof(PVOID))) && \
  332. (pfio->e != NULL) \
  333. )
  334. //+----------------------------------------------------------------------------
  335. //
  336. // Function: DfsFastIoLookup
  337. //
  338. // Synopsis: Given a file object, this routine will locate the fast IO
  339. // dispatch table for the underlying provider
  340. //
  341. // Arguments:
  342. //
  343. // Returns:
  344. //
  345. //-----------------------------------------------------------------------------
  346. PFAST_IO_DISPATCH
  347. DfsFastIoLookup(
  348. IN FILE_OBJECT *pFileObject,
  349. IN DEVICE_OBJECT *DeviceObject,
  350. OUT PDEVICE_OBJECT *targetVdo)
  351. {
  352. PFAST_IO_DISPATCH pFastIoTable;
  353. *targetVdo = NULL;
  354. DfsDbgTrace(+1, Dbg, "DfsFastIoLookup: Entered\n", 0);
  355. if (DeviceObject->DeviceType == FILE_DEVICE_DFS) {
  356. //
  357. // In this case we now need to do an DFS_FCB Lookup to figure out where to
  358. // go from here.
  359. //
  360. TYPE_OF_OPEN TypeOfOpen;
  361. PDFS_VCB Vcb;
  362. PDFS_FCB Fcb;
  363. TypeOfOpen = DfsDecodeFileObject( pFileObject, &Vcb, &Fcb);
  364. DfsDbgTrace(0, Dbg, "Fcb = %08lx\n", Fcb);
  365. if (TypeOfOpen == RedirectedFileOpen) {
  366. //
  367. // In this case the target device is in the Fcb itself.
  368. //
  369. *targetVdo = Fcb->TargetDevice;
  370. pFastIoTable = (*targetVdo)->DriverObject->FastIoDispatch;
  371. DfsDbgTrace(0,Dbg, "DfsFastIoLookup: DvObj: %08lx",DeviceObject);
  372. DfsDbgTrace(0, Dbg, "TargetVdo %08lx\n", *targetVdo);
  373. DfsDbgTrace(-1,Dbg, "DfsFastIoLookup: Exit-> %08lx\n",pFastIoTable );
  374. return(pFastIoTable);
  375. } else {
  376. //
  377. // This can happen for opens against mup device, so its legal
  378. // to return NULL here. Dont assert (bug 422334)
  379. //
  380. DfsDbgTrace( 0, Dbg, "DfsFastIoLookup: TypeOfOpen = %s\n",
  381. ( (TypeOfOpen == UnopenedFileObject) ? "UnopenedFileObject":
  382. (TypeOfOpen == LogicalRootDeviceOpen) ? "LogicalRootDeviceOpen":
  383. "???") );
  384. DfsDbgTrace(-1,Dbg, "DfsFastIoLookup: Exit -> %08lx\n", NULL );
  385. return(NULL);
  386. }
  387. } else if (DeviceObject->DeviceType == FILE_DEVICE_DFS_FILE_SYSTEM) {
  388. DfsDbgTrace(0, Dbg, "DfsFastIoLookup: Dfs File System\n", 0);
  389. return( NULL );
  390. } else {
  391. //
  392. // This is an unknown device object type and we dont know what to do
  393. //
  394. DfsDbgTrace(-1,Dbg, "DfsFastIoLookup: Exit -> %08lx\n", NULL );
  395. return(NULL);
  396. }
  397. }
  398. //+----------------------------------------------------------------------------
  399. //
  400. // Function: DfsFastIoCheckIfPossible
  401. //
  402. // Synopsis:
  403. //
  404. // Arguments:
  405. //
  406. // Returns:
  407. //
  408. //-----------------------------------------------------------------------------
  409. BOOLEAN
  410. DfsFastIoCheckIfPossible (
  411. FILE_OBJECT *pFileObject,
  412. LARGE_INTEGER *pOffset,
  413. ULONG Length,
  414. BOOLEAN fWait,
  415. ULONG LockKey,
  416. BOOLEAN fCheckForRead,
  417. IO_STATUS_BLOCK *pIoStatusBlock,
  418. PDEVICE_OBJECT DeviceObject)
  419. {
  420. PFAST_IO_DISPATCH pFastIoTable;
  421. PDEVICE_OBJECT targetVdo;
  422. BOOLEAN fPossible;
  423. DfsDbgTrace(+1, Dbg, "DfsFastIoCheckIfPossible Enter \n", 0);
  424. pFastIoTable = DfsFastIoLookup(pFileObject, DeviceObject, &targetVdo);
  425. if ( IS_VALID_INDEX(pFastIoTable, FastIoCheckIfPossible) ) {
  426. fPossible = pFastIoTable->FastIoCheckIfPossible(
  427. pFileObject,
  428. pOffset,
  429. Length,
  430. fWait,
  431. LockKey,
  432. fCheckForRead,
  433. pIoStatusBlock,
  434. targetVdo);
  435. } else {
  436. fPossible = FALSE;
  437. }
  438. DfsDbgTrace(-1, Dbg, "DfsFastIoCheckIfPossible Exit \n", 0);
  439. return(fPossible);
  440. }
  441. //+----------------------------------------------------------------------------
  442. //
  443. // Function: DfsFastIoRead
  444. //
  445. // Synopsis:
  446. //
  447. // Arguments:
  448. //
  449. // Returns:
  450. //
  451. //-----------------------------------------------------------------------------
  452. BOOLEAN
  453. DfsFastIoRead(
  454. IN PFILE_OBJECT FileObject,
  455. IN PLARGE_INTEGER FileOffset,
  456. IN ULONG Length,
  457. IN BOOLEAN Wait,
  458. IN ULONG LockKey,
  459. OUT PVOID Buffer,
  460. OUT PIO_STATUS_BLOCK IoStatus,
  461. PDEVICE_OBJECT DeviceObject
  462. )
  463. {
  464. PFAST_IO_DISPATCH pFastIoTable;
  465. PDEVICE_OBJECT targetVdo;
  466. BOOLEAN fPossible;
  467. DfsDbgTrace(+1, Dbg, "DfsFastIoRead Enter \n", 0);
  468. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  469. if ( IS_VALID_INDEX(pFastIoTable, FastIoRead) ) {
  470. fPossible = pFastIoTable->FastIoRead(
  471. FileObject,
  472. FileOffset,
  473. Length,
  474. Wait,
  475. LockKey,
  476. Buffer,
  477. IoStatus,
  478. targetVdo);
  479. } else {
  480. fPossible = FALSE;
  481. }
  482. DfsDbgTrace(-1, Dbg, "DfsFastIoRead Exit \n", 0);
  483. return(fPossible);
  484. }
  485. //+----------------------------------------------------------------------------
  486. //
  487. // Function: DfsFastIoWrite
  488. //
  489. // Synopsis:
  490. //
  491. // Arguments:
  492. //
  493. // Returns:
  494. //
  495. //-----------------------------------------------------------------------------
  496. BOOLEAN
  497. DfsFastIoWrite(
  498. IN PFILE_OBJECT FileObject,
  499. IN PLARGE_INTEGER FileOffset,
  500. IN ULONG Length,
  501. IN BOOLEAN Wait,
  502. IN ULONG LockKey,
  503. IN PVOID Buffer,
  504. OUT PIO_STATUS_BLOCK IoStatus,
  505. PDEVICE_OBJECT DeviceObject
  506. )
  507. {
  508. PFAST_IO_DISPATCH pFastIoTable;
  509. PDEVICE_OBJECT targetVdo;
  510. BOOLEAN fPossible;
  511. DfsDbgTrace(+1, Dbg, "DfsFastIoWrite Enter \n", 0);
  512. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  513. if ( IS_VALID_INDEX(pFastIoTable, FastIoWrite) ) {
  514. fPossible = pFastIoTable->FastIoWrite(
  515. FileObject,
  516. FileOffset,
  517. Length,
  518. Wait,
  519. LockKey,
  520. Buffer,
  521. IoStatus,
  522. targetVdo);
  523. } else {
  524. fPossible = FALSE;
  525. }
  526. DfsDbgTrace(-1, Dbg, "DfsFastIoWrite Exit \n", 0);
  527. return(fPossible);
  528. }
  529. //+----------------------------------------------------------------------------
  530. //
  531. // Function: DfsFastIoQueryBasicInfo
  532. //
  533. // Synopsis:
  534. //
  535. // Arguments:
  536. //
  537. // Returns:
  538. //
  539. //-----------------------------------------------------------------------------
  540. BOOLEAN
  541. DfsFastIoQueryBasicInfo(
  542. IN PFILE_OBJECT FileObject,
  543. IN BOOLEAN Wait,
  544. OUT PFILE_BASIC_INFORMATION Buffer,
  545. OUT PIO_STATUS_BLOCK IoStatus,
  546. PDEVICE_OBJECT DeviceObject)
  547. {
  548. PFAST_IO_DISPATCH pFastIoTable;
  549. PDEVICE_OBJECT targetVdo;
  550. BOOLEAN fPossible;
  551. DfsDbgTrace(+1, Dbg, "DfsFastIoQueryBasicInfo Enter \n", 0);
  552. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  553. if ( IS_VALID_INDEX(pFastIoTable, FastIoQueryBasicInfo) ) {
  554. fPossible = pFastIoTable->FastIoQueryBasicInfo(
  555. FileObject,
  556. Wait,
  557. Buffer,
  558. IoStatus,
  559. targetVdo);
  560. } else {
  561. fPossible = FALSE;
  562. }
  563. DfsDbgTrace(-1, Dbg, "DfsFastIoQueryBasicInfo Exit \n", 0);
  564. return(fPossible);
  565. }
  566. //+----------------------------------------------------------------------------
  567. //
  568. // Function: DfsFastIoQueryStandardInfo
  569. //
  570. // Synopsis:
  571. //
  572. // Arguments:
  573. //
  574. // Returns:
  575. //
  576. //-----------------------------------------------------------------------------
  577. BOOLEAN
  578. DfsFastIoQueryStandardInfo(
  579. IN PFILE_OBJECT FileObject,
  580. IN BOOLEAN Wait,
  581. OUT PFILE_STANDARD_INFORMATION Buffer,
  582. OUT PIO_STATUS_BLOCK IoStatus,
  583. PDEVICE_OBJECT DeviceObject)
  584. {
  585. PFAST_IO_DISPATCH pFastIoTable;
  586. PDEVICE_OBJECT targetVdo;
  587. BOOLEAN fPossible;
  588. DfsDbgTrace(+1, Dbg, "DfsFastIoQueryStandardInfo Enter \n", 0);
  589. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  590. if ( IS_VALID_INDEX(pFastIoTable, FastIoQueryStandardInfo) ) {
  591. fPossible = pFastIoTable->FastIoQueryStandardInfo(
  592. FileObject,
  593. Wait,
  594. Buffer,
  595. IoStatus,
  596. targetVdo);
  597. } else {
  598. fPossible = FALSE;
  599. }
  600. DfsDbgTrace(-1, Dbg, "DfsFastIoQueryStandardInfo Exit \n", 0);
  601. return(fPossible);
  602. }
  603. //+----------------------------------------------------------------------------
  604. //
  605. // Function: DfsFastIoLock
  606. //
  607. // Synopsis:
  608. //
  609. // Arguments:
  610. //
  611. // Returns:
  612. //
  613. //-----------------------------------------------------------------------------
  614. BOOLEAN
  615. DfsFastIoLock(
  616. IN PFILE_OBJECT FileObject,
  617. IN PLARGE_INTEGER FileOffset,
  618. IN PLARGE_INTEGER Length,
  619. PEPROCESS ProcessId,
  620. ULONG Key,
  621. BOOLEAN FailImmediately,
  622. BOOLEAN ExclusiveLock,
  623. OUT PIO_STATUS_BLOCK IoStatus,
  624. PDEVICE_OBJECT DeviceObject
  625. )
  626. {
  627. PFAST_IO_DISPATCH pFastIoTable;
  628. PDEVICE_OBJECT targetVdo;
  629. BOOLEAN fPossible;
  630. DfsDbgTrace(+1, Dbg, "DfsFastIoLock Enter \n", 0);
  631. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  632. if ( IS_VALID_INDEX(pFastIoTable, FastIoLock) ) {
  633. fPossible = pFastIoTable->FastIoLock(
  634. FileObject,
  635. FileOffset,
  636. Length,
  637. ProcessId,
  638. Key,
  639. FailImmediately,
  640. ExclusiveLock,
  641. IoStatus,
  642. targetVdo);
  643. } else {
  644. fPossible = FALSE;
  645. }
  646. DfsDbgTrace(-1, Dbg, "DfsFastIoLock Exit \n", 0);
  647. return(fPossible);
  648. }
  649. //+----------------------------------------------------------------------------
  650. //
  651. // Function: DfsFastIoUnlockSingle
  652. //
  653. // Synopsis:
  654. //
  655. // Arguments:
  656. //
  657. // Returns:
  658. //
  659. //-----------------------------------------------------------------------------
  660. BOOLEAN
  661. DfsFastIoUnlockSingle(
  662. IN PFILE_OBJECT FileObject,
  663. IN PLARGE_INTEGER FileOffset,
  664. IN PLARGE_INTEGER Length,
  665. PEPROCESS ProcessId,
  666. ULONG Key,
  667. OUT PIO_STATUS_BLOCK IoStatus,
  668. PDEVICE_OBJECT DeviceObject)
  669. {
  670. PFAST_IO_DISPATCH pFastIoTable;
  671. PDEVICE_OBJECT targetVdo;
  672. BOOLEAN fPossible;
  673. DfsDbgTrace(+1, Dbg, "DfsFastIoUnlockSingle Enter \n", 0);
  674. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  675. if ( IS_VALID_INDEX(pFastIoTable, FastIoUnlockSingle) ) {
  676. fPossible = pFastIoTable->FastIoUnlockSingle(
  677. FileObject,
  678. FileOffset,
  679. Length,
  680. ProcessId,
  681. Key,
  682. IoStatus,
  683. targetVdo);
  684. } else {
  685. fPossible = FALSE;
  686. }
  687. DfsDbgTrace(-1, Dbg, "DfsFastIoUnlockSingle Exit \n", 0);
  688. return(fPossible);
  689. }
  690. //+----------------------------------------------------------------------------
  691. //
  692. // Function: DfsFastIoUnlockAll
  693. //
  694. // Synopsis:
  695. //
  696. // Arguments:
  697. //
  698. // Returns:
  699. //
  700. //-----------------------------------------------------------------------------
  701. BOOLEAN
  702. DfsFastIoUnlockAll(
  703. IN PFILE_OBJECT FileObject,
  704. PEPROCESS ProcessId,
  705. OUT PIO_STATUS_BLOCK IoStatus,
  706. PDEVICE_OBJECT DeviceObject
  707. )
  708. {
  709. PFAST_IO_DISPATCH pFastIoTable;
  710. PDEVICE_OBJECT targetVdo;
  711. BOOLEAN fPossible;
  712. DfsDbgTrace(+1, Dbg, "DfsFastIoUnlockAll Enter \n", 0);
  713. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  714. if ( IS_VALID_INDEX(pFastIoTable, FastIoUnlockAll) ) {
  715. fPossible = pFastIoTable->FastIoUnlockAll(
  716. FileObject,
  717. ProcessId,
  718. IoStatus,
  719. targetVdo);
  720. } else {
  721. fPossible = FALSE;
  722. }
  723. DfsDbgTrace(-1, Dbg, "DfsFastIoUnlockAll Exit \n", 0);
  724. return(fPossible);
  725. }
  726. //+----------------------------------------------------------------------------
  727. //
  728. // Function: FastIoUnlockAllByKey
  729. //
  730. // Synopsis:
  731. //
  732. // Arguments:
  733. //
  734. // Returns:
  735. //
  736. //-----------------------------------------------------------------------------
  737. BOOLEAN
  738. DfsFastIoUnlockAllByKey(
  739. IN PFILE_OBJECT FileObject,
  740. PVOID ProcessId,
  741. ULONG Key,
  742. OUT PIO_STATUS_BLOCK IoStatus,
  743. PDEVICE_OBJECT DeviceObject
  744. )
  745. {
  746. PFAST_IO_DISPATCH pFastIoTable;
  747. PDEVICE_OBJECT targetVdo;
  748. BOOLEAN fPossible;
  749. DfsDbgTrace(+1, Dbg, "DfsFastIoUnlockAllByKey Enter \n", 0);
  750. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  751. if ( IS_VALID_INDEX(pFastIoTable, FastIoUnlockAllByKey) ) {
  752. fPossible = pFastIoTable->FastIoUnlockAllByKey(
  753. FileObject,
  754. ProcessId,
  755. Key,
  756. IoStatus,
  757. targetVdo);
  758. } else {
  759. fPossible = FALSE;
  760. }
  761. DfsDbgTrace(-1, Dbg, "DfsFastIoUnlockAllByKey Exit \n", 0);
  762. return(fPossible);
  763. }
  764. //+----------------------------------------------------------------------------
  765. //
  766. // Function: DfsFastIoDeviceControl
  767. //
  768. // Synopsis:
  769. //
  770. // Arguments:
  771. //
  772. // Returns:
  773. //
  774. //-----------------------------------------------------------------------------
  775. BOOLEAN
  776. DfsFastIoDeviceControl(
  777. IN PFILE_OBJECT FileObject,
  778. IN BOOLEAN Wait,
  779. IN PVOID InputBuffer OPTIONAL,
  780. IN ULONG InputBufferLength,
  781. OUT PVOID OutputBuffer OPTIONAL,
  782. IN ULONG OutputBufferLength,
  783. IN ULONG IoControlCode,
  784. OUT PIO_STATUS_BLOCK IoStatus,
  785. PDEVICE_OBJECT DeviceObject
  786. )
  787. {
  788. PFAST_IO_DISPATCH pFastIoTable;
  789. PDEVICE_OBJECT targetVdo;
  790. BOOLEAN fPossible;
  791. TYPE_OF_OPEN TypeOfOpen;
  792. PDFS_VCB Vcb;
  793. PDFS_FCB Fcb;
  794. DfsDbgTrace(+1, Dbg, "DfsFastIoDeviceControl Enter \n", 0);
  795. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  796. if ( IS_VALID_INDEX(pFastIoTable, FastIoDeviceControl) ) {
  797. fPossible = pFastIoTable->FastIoDeviceControl(
  798. FileObject,
  799. Wait,
  800. InputBuffer,
  801. InputBufferLength,
  802. OutputBuffer,
  803. OutputBufferLength,
  804. IoControlCode,
  805. IoStatus,
  806. targetVdo);
  807. } else {
  808. fPossible = FALSE;
  809. }
  810. DfsDbgTrace(-1, Dbg, "DfsFastIoDeviceControl Exit \n", 0);
  811. return(fPossible);
  812. }
  813. //+----------------------------------------------------------------------------
  814. //
  815. // Function: DfsFastIoDetachDevice, public
  816. //
  817. // Synopsis: This routine is a different from the rest of the fast io
  818. // routines. It is called when a device object is being deleted,
  819. // and that device object has an attached device. The semantics
  820. // of this routine are "You attached to a device object that now
  821. // needs to be deleted; please detach from the said device
  822. // object."
  823. //
  824. // Arguments: [SourceDevice] -- Our device, the one that we created to
  825. // attach ourselves to the target device.
  826. // [TargetDevice] -- Their device, the one that we are attached
  827. // to.
  828. //
  829. // Returns: Nothing - we must succeed.
  830. //
  831. //-----------------------------------------------------------------------------
  832. VOID
  833. DfsFastIoDetachDevice(
  834. IN PDEVICE_OBJECT SourceDevice,
  835. IN PDEVICE_OBJECT TargetDevice)
  836. {
  837. NOTHING;
  838. }
  839. BOOLEAN
  840. DfsFastIoQueryNetworkOpenInfo(
  841. IN PFILE_OBJECT FileObject,
  842. IN BOOLEAN Wait,
  843. OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
  844. OUT PIO_STATUS_BLOCK IoStatus,
  845. IN PDEVICE_OBJECT DeviceObject)
  846. {
  847. PFAST_IO_DISPATCH pFastIoTable;
  848. PDEVICE_OBJECT targetVdo;
  849. BOOLEAN fPossible;
  850. DfsDbgTrace(+1, Dbg, "DfsFastIoQueryNetworkOpenInfo Enter \n", 0);
  851. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  852. if ( IS_VALID_INDEX(pFastIoTable, FastIoQueryNetworkOpenInfo) ) {
  853. fPossible = pFastIoTable->FastIoQueryNetworkOpenInfo(
  854. FileObject,
  855. Wait,
  856. Buffer,
  857. IoStatus,
  858. targetVdo);
  859. } else {
  860. fPossible = FALSE;
  861. IoStatus->Status = STATUS_NOT_SUPPORTED;
  862. }
  863. DfsDbgTrace(-1, Dbg, "DfsFastIoQueryNetworkOpenInfo Exit \n", 0);
  864. return( fPossible );
  865. }
  866. BOOLEAN
  867. DfsFastIoMdlRead(
  868. IN PFILE_OBJECT FileObject,
  869. IN PLARGE_INTEGER FileOffset,
  870. IN ULONG Length,
  871. IN ULONG LockKey,
  872. OUT PMDL *MdlChain,
  873. OUT PIO_STATUS_BLOCK IoStatus,
  874. IN PDEVICE_OBJECT DeviceObject)
  875. {
  876. PFAST_IO_DISPATCH pFastIoTable;
  877. PDEVICE_OBJECT targetVdo;
  878. BOOLEAN fPossible;
  879. DfsDbgTrace(+1, Dbg, "DfsFastIoMdlRead Enter \n", 0);
  880. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  881. if ( IS_VALID_INDEX(pFastIoTable, MdlRead) ) {
  882. fPossible = pFastIoTable->MdlRead(
  883. FileObject,
  884. FileOffset,
  885. Length,
  886. LockKey,
  887. MdlChain,
  888. IoStatus,
  889. targetVdo);
  890. } else {
  891. fPossible = FsRtlMdlReadDev(
  892. FileObject,
  893. FileOffset,
  894. Length,
  895. LockKey,
  896. MdlChain,
  897. IoStatus,
  898. targetVdo);
  899. }
  900. DfsDbgTrace(-1, Dbg, "DfsFastIoMdlRead Exit \n", 0);
  901. return( fPossible );
  902. }
  903. BOOLEAN
  904. DfsFastIoMdlReadComplete(
  905. IN PFILE_OBJECT FileObject,
  906. IN PMDL MdlChain,
  907. IN PDEVICE_OBJECT DeviceObject
  908. )
  909. {
  910. PFAST_IO_DISPATCH pFastIoTable;
  911. PDEVICE_OBJECT targetVdo;
  912. BOOLEAN fResult;
  913. DfsDbgTrace(+1, Dbg, "DfsFastIoMdlReadComplete Enter \n", 0);
  914. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  915. if ( IS_VALID_INDEX(pFastIoTable, MdlReadComplete) ) {
  916. fResult = pFastIoTable->MdlReadComplete(
  917. FileObject,
  918. MdlChain,
  919. targetVdo);
  920. } else {
  921. fResult = FsRtlMdlReadCompleteDev(
  922. FileObject,
  923. MdlChain,
  924. targetVdo);
  925. }
  926. DfsDbgTrace(-1, Dbg, "DfsFastIoMdlReadComplete Exit \n", 0);
  927. return( fResult );
  928. }
  929. BOOLEAN
  930. DfsFastIoPrepareMdlWrite(
  931. IN PFILE_OBJECT FileObject,
  932. IN PLARGE_INTEGER FileOffset,
  933. IN ULONG Length,
  934. IN ULONG LockKey,
  935. OUT PMDL *MdlChain,
  936. OUT PIO_STATUS_BLOCK IoStatus,
  937. IN PDEVICE_OBJECT DeviceObject)
  938. {
  939. PFAST_IO_DISPATCH pFastIoTable;
  940. PDEVICE_OBJECT targetVdo;
  941. BOOLEAN fPossible;
  942. DfsDbgTrace(+1, Dbg, "DfsFastIoPrepareMdlWrite Enter \n", 0);
  943. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  944. if ( IS_VALID_INDEX(pFastIoTable, PrepareMdlWrite) ) {
  945. fPossible = pFastIoTable->PrepareMdlWrite(
  946. FileObject,
  947. FileOffset,
  948. Length,
  949. LockKey,
  950. MdlChain,
  951. IoStatus,
  952. targetVdo);
  953. } else {
  954. fPossible = FsRtlPrepareMdlWriteDev(
  955. FileObject,
  956. FileOffset,
  957. Length,
  958. LockKey,
  959. MdlChain,
  960. IoStatus,
  961. targetVdo);
  962. }
  963. DfsDbgTrace(-1, Dbg, "DfsFastIoPrepareMdlWrite Exit \n", 0);
  964. return( fPossible );
  965. }
  966. BOOLEAN
  967. DfsFastIoMdlWriteComplete(
  968. IN PFILE_OBJECT FileObject,
  969. IN PLARGE_INTEGER FileOffset,
  970. IN PMDL MdlChain,
  971. IN PDEVICE_OBJECT DeviceObject
  972. )
  973. {
  974. PFAST_IO_DISPATCH pFastIoTable;
  975. PDEVICE_OBJECT targetVdo;
  976. BOOLEAN fResult;
  977. DfsDbgTrace(+1, Dbg, "DfsFastIoMdlWriteComplete Enter \n", 0);
  978. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  979. if ( IS_VALID_INDEX(pFastIoTable, MdlWriteComplete) ) {
  980. fResult = pFastIoTable->MdlWriteComplete(
  981. FileObject,
  982. FileOffset,
  983. MdlChain,
  984. targetVdo);
  985. } else {
  986. fResult = FsRtlMdlWriteCompleteDev(
  987. FileObject,
  988. FileOffset,
  989. MdlChain,
  990. targetVdo);
  991. }
  992. DfsDbgTrace(-1, Dbg, "DfsFastIoMdlWriteComplete Exit \n", 0);
  993. return( fResult );
  994. }
  995. BOOLEAN
  996. DfsFastIoReadCompressed(
  997. IN PFILE_OBJECT FileObject,
  998. IN PLARGE_INTEGER FileOffset,
  999. IN ULONG Length,
  1000. IN ULONG LockKey,
  1001. OUT PVOID Buffer,
  1002. OUT PMDL *MdlChain,
  1003. OUT PIO_STATUS_BLOCK IoStatus,
  1004. OUT struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
  1005. IN ULONG CompressedDataInfoLength,
  1006. IN PDEVICE_OBJECT DeviceObject)
  1007. {
  1008. PFAST_IO_DISPATCH pFastIoTable;
  1009. PDEVICE_OBJECT targetVdo;
  1010. BOOLEAN fPossible;
  1011. DfsDbgTrace(+1, Dbg, "DfsFastIoReadCompressed Enter \n", 0);
  1012. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  1013. if ( IS_VALID_INDEX(pFastIoTable, FastIoReadCompressed) ) {
  1014. fPossible = pFastIoTable->FastIoReadCompressed(
  1015. FileObject,
  1016. FileOffset,
  1017. Length,
  1018. LockKey,
  1019. Buffer,
  1020. MdlChain,
  1021. IoStatus,
  1022. CompressedDataInfo,
  1023. CompressedDataInfoLength,
  1024. targetVdo);
  1025. } else {
  1026. fPossible = FALSE;
  1027. IoStatus->Status = STATUS_NOT_SUPPORTED;
  1028. }
  1029. DfsDbgTrace(-1, Dbg, "DfsFastIoReadCompressed Exit \n", 0);
  1030. return( fPossible );
  1031. }
  1032. BOOLEAN
  1033. DfsFastIoWriteCompressed(
  1034. IN PFILE_OBJECT FileObject,
  1035. IN PLARGE_INTEGER FileOffset,
  1036. IN ULONG Length,
  1037. IN ULONG LockKey,
  1038. IN PVOID Buffer,
  1039. OUT PMDL *MdlChain,
  1040. OUT PIO_STATUS_BLOCK IoStatus,
  1041. IN struct _COMPRESSED_DATA_INFO *CompressedDataInfo,
  1042. IN ULONG CompressedDataInfoLength,
  1043. IN PDEVICE_OBJECT DeviceObject)
  1044. {
  1045. PFAST_IO_DISPATCH pFastIoTable;
  1046. PDEVICE_OBJECT targetVdo;
  1047. BOOLEAN fPossible;
  1048. DfsDbgTrace(+1, Dbg, "DfsFastIoWriteCompressed Enter \n", 0);
  1049. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  1050. if ( IS_VALID_INDEX(pFastIoTable, FastIoWriteCompressed) ) {
  1051. fPossible = pFastIoTable->FastIoWriteCompressed(
  1052. FileObject,
  1053. FileOffset,
  1054. Length,
  1055. LockKey,
  1056. Buffer,
  1057. MdlChain,
  1058. IoStatus,
  1059. CompressedDataInfo,
  1060. CompressedDataInfoLength,
  1061. targetVdo);
  1062. } else {
  1063. fPossible = FALSE;
  1064. IoStatus->Status = STATUS_NOT_SUPPORTED;
  1065. }
  1066. DfsDbgTrace(-1, Dbg, "DfsFastIoWriteCompressed Exit \n", 0);
  1067. return( fPossible );
  1068. }
  1069. BOOLEAN
  1070. DfsFastIoMdlReadCompleteCompressed(
  1071. IN PFILE_OBJECT FileObject,
  1072. IN PMDL MdlChain,
  1073. IN PDEVICE_OBJECT DeviceObject)
  1074. {
  1075. PFAST_IO_DISPATCH pFastIoTable;
  1076. PDEVICE_OBJECT targetVdo;
  1077. BOOLEAN fResult;
  1078. DfsDbgTrace(+1, Dbg, "DfsFastIoMdlReadCompleteCompressed Enter \n", 0);
  1079. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  1080. if ( IS_VALID_INDEX(pFastIoTable, MdlReadCompleteCompressed) ) {
  1081. fResult = pFastIoTable->MdlReadCompleteCompressed(
  1082. FileObject,
  1083. MdlChain,
  1084. targetVdo);
  1085. } else {
  1086. fResult = FALSE;
  1087. }
  1088. DfsDbgTrace(-1, Dbg, "DfsFastIoMdlReadCompleteCompressed Exit \n", 0);
  1089. return( fResult );
  1090. }
  1091. BOOLEAN
  1092. DfsFastIoMdlWriteCompleteCompressed(
  1093. IN PFILE_OBJECT FileObject,
  1094. IN PLARGE_INTEGER FileOffset,
  1095. IN PMDL MdlChain,
  1096. IN PDEVICE_OBJECT DeviceObject)
  1097. {
  1098. PFAST_IO_DISPATCH pFastIoTable;
  1099. PDEVICE_OBJECT targetVdo;
  1100. BOOLEAN fResult;
  1101. DfsDbgTrace(+1, Dbg, "DfsFastIoMdlWriteCompleteCompressed Enter \n", 0);
  1102. pFastIoTable = DfsFastIoLookup(FileObject, DeviceObject, &targetVdo);
  1103. if ( IS_VALID_INDEX(pFastIoTable, MdlWriteCompleteCompressed) ) {
  1104. fResult = pFastIoTable->MdlWriteCompleteCompressed(
  1105. FileObject,
  1106. FileOffset,
  1107. MdlChain,
  1108. targetVdo);
  1109. } else {
  1110. fResult = FALSE;
  1111. }
  1112. DfsDbgTrace(-1, Dbg, "DfsFastIoMdlWriteCompleteCompressed Exit \n", 0);
  1113. return( fResult );
  1114. }
  1115. //+----------------------------------------------------------------------------
  1116. //
  1117. // Function: DfsPreAcquireForSectionSynchronization
  1118. //
  1119. // Synopsis: This is the equivalent to FastIoAcquireFileForNtCreateSection.
  1120. // Dfs receives this callback through the FsFilter interfaces
  1121. // of the FsRtl package in the kernel.
  1122. //
  1123. // This is the time to do the work necessary to synchronize
  1124. // for memory-mapped section creation. If this operation
  1125. // should be redirected to an underlying FS, the parameters will
  1126. // be changed accordingly so that the operation is redirect when
  1127. // this callback returns.
  1128. //
  1129. // Arguments: [Data] -- The structure that contains the relevent parameters
  1130. // to this operation, like the FileObject and DeviceObject.
  1131. // [CompletionContext] - Provides a pointer for a context to be
  1132. // past from the pre to post operation. Since Dfs
  1133. // does not need a post operation, this parameter is not
  1134. // used.
  1135. //
  1136. // Returns: STATUS_SUCCESS
  1137. //
  1138. //-----------------------------------------------------------------------------
  1139. NTSTATUS
  1140. DfsPreAcquireForSectionSynchronization(
  1141. IN PFS_FILTER_CALLBACK_DATA Data,
  1142. OUT PVOID *CompletionContext)
  1143. {
  1144. PDEVICE_OBJECT targetVdo;
  1145. PFSRTL_COMMON_FCB_HEADER header;
  1146. PDFS_FCB pFcb;
  1147. UNREFERENCED_PARAMETER( CompletionContext );
  1148. DfsFastIoLookup( Data->FileObject, Data->DeviceObject, &targetVdo );
  1149. pFcb = DfsLookupFcb(Data->FileObject);
  1150. //
  1151. // If we've got a valid pFcb and pFcb->FileObject, we need to switch
  1152. // this operation to the other device stack and file object.
  1153. //
  1154. if (targetVdo != NULL &&
  1155. pFcb != NULL &&
  1156. pFcb->FileObject != NULL) {
  1157. IoSetTopLevelIrp( (PIRP) FSRTL_FSP_TOP_LEVEL_IRP );
  1158. Data->FileObject = pFcb->FileObject;
  1159. Data->DeviceObject = targetVdo;
  1160. } else if ((header = Data->FileObject->FsContext) && header->Resource) {
  1161. IoSetTopLevelIrp( (PIRP) FSRTL_FSP_TOP_LEVEL_IRP );
  1162. ExAcquireResourceExclusiveLite( header->Resource, TRUE );
  1163. } else {
  1164. NOTHING;
  1165. }
  1166. return STATUS_SUCCESS;
  1167. }
  1168. //+----------------------------------------------------------------------------
  1169. //
  1170. // Function: DfsPreReleaseForSectionSynchronization
  1171. //
  1172. // Synopsis: This is the equivalent to FastIoReleaseFileForNtCreateSection.
  1173. // Dfs receives this callback through the FsFilter interfaces
  1174. // of the FsRtl package in the kernel.
  1175. //
  1176. // This is the time to do the work necessary to end the
  1177. // synchronization operations taken to create a memory-mapped
  1178. // section. If this operation should be redirected to an
  1179. // underlying FS, the parameters will be changed accordingly so
  1180. // that the operation is redirect when this callback returns.
  1181. //
  1182. // Arguments: [Data] -- The structure that contains the relevent parameters
  1183. // to this operation, like the FileObject and DeviceObject.
  1184. // [CompletionContext] - Provides a pointer for a context to be
  1185. // past from the pre to post operation. Since Dfs
  1186. // does not need a post operation, this parameter is not
  1187. // used.
  1188. //
  1189. // Returns: STATUS_SUCCESS
  1190. //
  1191. //-----------------------------------------------------------------------------
  1192. NTSTATUS
  1193. DfsPreReleaseForSectionSynchronization(
  1194. IN PFS_FILTER_CALLBACK_DATA Data,
  1195. OUT PVOID *CompletionContext)
  1196. {
  1197. PDEVICE_OBJECT targetVdo;
  1198. PFSRTL_COMMON_FCB_HEADER header;
  1199. PDFS_FCB pFcb;
  1200. UNREFERENCED_PARAMETER( CompletionContext );
  1201. DfsFastIoLookup( Data->FileObject, Data->DeviceObject, &targetVdo );
  1202. pFcb = DfsLookupFcb(Data->FileObject);
  1203. if (targetVdo != NULL &&
  1204. pFcb != NULL &&
  1205. pFcb->FileObject != NULL) {
  1206. IoSetTopLevelIrp( (PIRP) NULL );
  1207. Data->DeviceObject = targetVdo;
  1208. } else if ((header = Data->FileObject->FsContext) && header->Resource) {
  1209. IoSetTopLevelIrp( (PIRP) NULL );
  1210. ExReleaseResourceLite( header->Resource );
  1211. } else {
  1212. NOTHING;
  1213. }
  1214. return STATUS_SUCCESS;
  1215. }
  1216. //+----------------------------------------------------------------------------
  1217. //
  1218. // Function: DfsPreAcquireForModWrite
  1219. //
  1220. // Synopsis: This is the equivalent to FastIoAcquireForModWrite.
  1221. // Dfs receives this callback through the FsFilter interfaces
  1222. // of the FsRtl package in the kernel.
  1223. //
  1224. // This is the time to do the work necessary to synchronize
  1225. // for modified page writer operations. If this operation
  1226. // should be redirected to an underlying FS, the parameters will
  1227. // be changed accordingly so that the operation is redirect when
  1228. // this callback returns.
  1229. //
  1230. // Arguments: [Data] -- The structure that contains the relevent parameters
  1231. // to this operation, like the FileObject and DeviceObject.
  1232. // [CompletionContext] - Provides a pointer for a context to be
  1233. // past from the pre to post operation. Since Dfs
  1234. // does not need a post operation, this parameter is not
  1235. // used.
  1236. //
  1237. // Returns: STATUS_SUCCESS or STATUS_INVALID_DEVICE_REQUEST for default
  1238. // behavior.
  1239. //
  1240. //-----------------------------------------------------------------------------
  1241. NTSTATUS
  1242. DfsPreAcquireForModWrite(
  1243. IN PFS_FILTER_CALLBACK_DATA Data,
  1244. OUT PVOID *CompletionContext)
  1245. {
  1246. PDEVICE_OBJECT targetVdo;
  1247. NTSTATUS status;
  1248. UNREFERENCED_PARAMETER( CompletionContext );
  1249. DfsDbgTrace(+1, Dbg, "DfsPreAcquireForModWrite Enter \n", 0);
  1250. DfsFastIoLookup(Data->FileObject, Data->DeviceObject, &targetVdo);
  1251. if (targetVdo != NULL) {
  1252. Data->DeviceObject = targetVdo;
  1253. status = STATUS_SUCCESS;
  1254. } else {
  1255. //
  1256. // The lazy write called us because we had the dispatch routine for
  1257. // AcquireFileForModWrite, but the underlying FS did not. So, we
  1258. // return this particular error so that the lazy write knows exactly
  1259. // what happened, and can take the default action.
  1260. //
  1261. status = STATUS_INVALID_DEVICE_REQUEST;
  1262. }
  1263. DfsDbgTrace(-1, Dbg, "DfsPreAcquireForModWrite Exit \n", 0);
  1264. return( status );
  1265. }
  1266. //+----------------------------------------------------------------------------
  1267. //
  1268. // Function: DfsPreReleaseForModWrite
  1269. //
  1270. // Synopsis: This is the equivalent to FastIoReleaseForModWrite.
  1271. // Dfs receives this callback through the FsFilter interfaces
  1272. // of the FsRtl package in the kernel.
  1273. //
  1274. // This is the time to do the work necessary to end the
  1275. // synchronization operations taken to prepare for the modified
  1276. // page writer to do its work. If this operation should be
  1277. // redirected to an underlying FS, the parameters will be changed
  1278. // accordingly so that the operation is redirect when this callback
  1279. // returns.
  1280. //
  1281. // Arguments: [Data] -- The structure that contains the relevent parameters
  1282. // to this operation, like the FileObject and DeviceObject.
  1283. // [CompletionContext] - Provides a pointer for a context to be
  1284. // past from the pre to post operation. Since Dfs
  1285. // does not need a post operation, this parameter is not
  1286. // used.
  1287. //
  1288. // Returns: STATUS_SUCCESS or STATUS_INVALID_DEVICE_REQUEST for default
  1289. // actions.
  1290. //
  1291. //-----------------------------------------------------------------------------
  1292. NTSTATUS
  1293. DfsPreReleaseForModWrite(
  1294. IN PFS_FILTER_CALLBACK_DATA Data,
  1295. OUT PVOID *CompletionContext)
  1296. {
  1297. PDEVICE_OBJECT targetVdo;
  1298. NTSTATUS status;
  1299. UNREFERENCED_PARAMETER( CompletionContext );
  1300. DfsDbgTrace(+1, Dbg, "DfsPreReleaseForModWrite Enter \n", 0);
  1301. DfsFastIoLookup(Data->FileObject, Data->DeviceObject, &targetVdo);
  1302. if (targetVdo != NULL) {
  1303. Data->DeviceObject = targetVdo;
  1304. status = STATUS_SUCCESS;
  1305. } else {
  1306. //
  1307. // The lazy write called us because we had the dispatch routine for
  1308. // AcquireFileForModWrite, but the underlying FS did not. So, we
  1309. // return this particular error so that the lazy write knows exactly
  1310. // what happened, and can take the default action.
  1311. //
  1312. status = STATUS_INVALID_DEVICE_REQUEST;
  1313. }
  1314. DfsDbgTrace(-1, Dbg, "DfsPreReleaseForModWrite Exit \n", 0);
  1315. return( status );
  1316. }
  1317. //+----------------------------------------------------------------------------
  1318. //
  1319. // Function: DfsPreAcquireForCcFlush
  1320. //
  1321. // Synopsis: This is the equivalent to FastIoAcquireForCcFlush.
  1322. // Dfs receives this callback through the FsFilter interfaces
  1323. // of the FsRtl package in the kernel.
  1324. //
  1325. // This is the time to do the work necessary to synchronize
  1326. // for a CC flush of the given file. If this operation
  1327. // should be redirected to an underlying FS, the parameters will
  1328. // be changed accordingly so that the operation is redirect when
  1329. // this callback returns.
  1330. //
  1331. // Arguments: [Data] -- The structure that contains the relevent parameters
  1332. // to this operation, like the FileObject and DeviceObject.
  1333. // [CompletionContext] - Provides a pointer for a context to be
  1334. // past from the pre to post operation. Since Dfs
  1335. // does not need a post operation, this parameter is not
  1336. // used.
  1337. //
  1338. // Returns: STATUS_SUCCESS or STATUS_INVALID_DEVICE_REQUEST for default
  1339. // actions.
  1340. //
  1341. //-----------------------------------------------------------------------------
  1342. NTSTATUS
  1343. DfsPreAcquireForCcFlush(
  1344. IN PFS_FILTER_CALLBACK_DATA Data,
  1345. OUT PVOID *CompletionContext)
  1346. {
  1347. PDEVICE_OBJECT targetVdo;
  1348. NTSTATUS status;
  1349. UNREFERENCED_PARAMETER( CompletionContext );
  1350. DfsDbgTrace(+1, Dbg, "DfsPreAcquireForCcFlush Enter \n", 0);
  1351. DfsFastIoLookup(Data->FileObject, Data->DeviceObject, &targetVdo);
  1352. if (targetVdo != NULL) {
  1353. Data->DeviceObject = targetVdo;
  1354. status = STATUS_SUCCESS;
  1355. } else {
  1356. status = STATUS_INVALID_DEVICE_REQUEST;
  1357. }
  1358. DfsDbgTrace(-1, Dbg, "DfsPreAcquireForCcFlush Exit \n", 0);
  1359. return( status );
  1360. }
  1361. //+----------------------------------------------------------------------------
  1362. //
  1363. // Function: DfsPreReleaseForCcFlush
  1364. //
  1365. // Synopsis: This is the equivalent to FastIoReleaseForCcFlush.
  1366. // Dfs receives this callback through the FsFilter interfaces
  1367. // of the FsRtl package in the kernel.
  1368. //
  1369. // This is the time to do the work necessary to end the
  1370. // synchronization operations taken to prepare for a CC flush
  1371. // of this file. If this operation should be redirected to an
  1372. // underlying FS, the parameters will be changed accordingly so
  1373. // that the operation is redirect when this callback returns.
  1374. //
  1375. // Arguments: [Data] -- The structure that contains the relevent parameters
  1376. // to this operation, like the FileObject and DeviceObject.
  1377. // [CompletionContext] - Provides a pointer for a context to be
  1378. // past from the pre to post operation. Since Dfs
  1379. // does not need a post operation, this parameter is not
  1380. // used.
  1381. //
  1382. // Returns: STATUS_SUCCESS or STATUS_INVALID_DEVICE_REQUEST for default
  1383. // actions.
  1384. //
  1385. //-----------------------------------------------------------------------------
  1386. NTSTATUS
  1387. DfsPreReleaseForCcFlush(
  1388. IN PFS_FILTER_CALLBACK_DATA Data,
  1389. OUT PVOID *CompletionContext)
  1390. {
  1391. PDEVICE_OBJECT targetVdo;
  1392. NTSTATUS status;
  1393. UNREFERENCED_PARAMETER( CompletionContext );
  1394. DfsDbgTrace(+1, Dbg, "DfsPreReleaseForCcFlush Enter \n", 0);
  1395. DfsFastIoLookup(Data->FileObject, Data->DeviceObject, &targetVdo);
  1396. if (targetVdo != NULL) {
  1397. Data->DeviceObject = targetVdo;
  1398. status = STATUS_SUCCESS;
  1399. } else {
  1400. status = STATUS_INVALID_DEVICE_REQUEST;
  1401. }
  1402. DfsDbgTrace(-1, Dbg, "DfsPreReleaseForCcFlush Exit \n", 0);
  1403. return( status );
  1404. }