ReactOS  0.4.14-dev-49-gfb4591c
fastio.c
Go to the documentation of this file.
1 /*
2  * FFS File System Driver for Windows
3  *
4  * fastio.c
5  *
6  * 2004.5.6 ~
7  *
8  * Lee Jae-Hong, http://www.pyrasis.com
9  *
10  * See License.txt
11  *
12  */
13 
14 #include "ntifs.h"
15 #include "ffsdrv.h"
16 
17 /* Globals */
18 
19 extern PFFS_GLOBAL FFSGlobal;
20 
21 
22 /* Definitions */
23 
24 #ifdef ALLOC_PRAGMA
25 #if DBG
26 #pragma alloc_text(PAGE, FFSFastIoRead)
27 #pragma alloc_text(PAGE, FFSFastIoWrite)
28 #endif
29 #pragma alloc_text(PAGE, FFSFastIoCheckIfPossible)
30 #pragma alloc_text(PAGE, FFSFastIoQueryBasicInfo)
31 #pragma alloc_text(PAGE, FFSFastIoQueryStandardInfo)
32 #pragma alloc_text(PAGE, FFSFastIoQueryNetworkOpenInfo)
33 #pragma alloc_text(PAGE, FFSFastIoLock)
34 #pragma alloc_text(PAGE, FFSFastIoUnlockSingle)
35 #pragma alloc_text(PAGE, FFSFastIoUnlockAll)
36 #pragma alloc_text(PAGE, FFSFastIoUnlockAllByKey)
37 #endif
38 
39 
44  IN ULONG Length,
45  IN BOOLEAN Wait,
50 {
51  BOOLEAN bPossible = FALSE;
52  PFFS_FCB Fcb;
53  LARGE_INTEGER lLength;
54 
55  PAGED_CODE();
56 
57  lLength.QuadPart = Length;
58 
59  _SEH2_TRY
60  {
61  _SEH2_TRY
62  {
64 
66  {
67  bPossible = FastIoIsNotPossible;
69  }
70 
71  Fcb = (PFFS_FCB)FileObject->FsContext;
72 
73  ASSERT(Fcb != NULL);
74 
75  if (Fcb->Identifier.Type == FFSVCB)
76  {
77  bPossible = FastIoIsNotPossible;
79  }
80 
82  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
83 
84  if (IsDirectory(Fcb))
85  {
86  bPossible = FALSE;
88  }
89 
91  {
92  bPossible = FsRtlFastCheckLockForRead(
93  &Fcb->FileLockAnchor,
94  FileOffset,
95  &lLength,
96  LockKey,
97  FileObject,
99 
100  if (!bPossible)
101  bPossible = FastIoIsQuestionable;
102  }
103  else
104  {
105  if (IsFlagOn(Fcb->Vcb->Flags, VCB_READ_ONLY) ||
107  {
108  bPossible = FastIoIsNotPossible;
109  }
110  else
111  {
112  bPossible = FsRtlFastCheckLockForWrite(
113  &Fcb->FileLockAnchor,
114  FileOffset,
115  &lLength,
116  LockKey,
117  FileObject,
119 
120  if (!bPossible)
121  bPossible = FastIoIsQuestionable;
122  }
123  }
124 
125  FFSPrint((DBG_INFO, "FFSFastIIOCheckPossible: %s %s %s\n",
127  "FASTIO_CHECK_IF_POSSIBLE",
128  Fcb->AnsiFileName.Buffer));
129 
130  FFSPrint((DBG_INFO,
131  "FFSFastIIOCheckPossible: Offset: %I64xg Length: %xh Key: %u %s %s\n",
132  FileOffset->QuadPart,
133  Length,
134  LockKey,
135  (CheckForReadOperation ? "CheckForReadOperation:" :
136  "CheckForWriteOperation:"),
137  (bPossible ? "Succeeded" : "Failed")));
138  }
140  {
141  bPossible = FastIoIsNotPossible;
142  } _SEH2_END;
143  }
145  {
147  } _SEH2_END;
148 
149  return bPossible;
150 }
151 
152 
153 #if DBG
154 
159  IN ULONG Length,
160  IN BOOLEAN Wait,
161  IN ULONG LockKey,
162  OUT PVOID Buffer,
165 {
166  BOOLEAN Status;
167  PFFS_FCB Fcb;
168 
169  PAGED_CODE();
170 
171  Fcb = (PFFS_FCB)FileObject->FsContext;
172 
173  ASSERT(Fcb != NULL);
174 
175  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
176  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
177 
178  FFSPrint((DBG_INFO, "FFSFastIoRead: %s %s %s\n",
180  "FASTIO_READ",
181  Fcb->AnsiFileName.Buffer));
182 
183  FFSPrint((DBG_INFO, "FFSFastIoRead: Offset: %I64xh Length: %xh Key: %u\n",
184  FileOffset->QuadPart,
185  Length,
186  LockKey));
187 
191 
192  return Status;
193 }
194 
195 #if !FFS_READ_ONLY
196 
201  IN ULONG Length,
202  IN BOOLEAN Wait,
203  IN ULONG LockKey,
204  OUT PVOID Buffer,
207 {
208  BOOLEAN bRet;
209  PFFS_FCB Fcb;
210 
211  PAGED_CODE();
212 
213  Fcb = (PFFS_FCB)FileObject->FsContext;
214 
215  ASSERT(Fcb != NULL);
216 
217  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
218  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
219 
221  "FFSFastIoWrite: %s %s %s\n",
223  "FASTIO_WRITE",
224  Fcb->AnsiFileName.Buffer));
225 
227  "FFSFastIoWrite: Offset: %I64xh Length: %xh Key: %xh\n",
228  FileOffset->QuadPart,
229  Length,
230  LockKey));
231 
232  if (IsFlagOn(Fcb->Vcb->Flags, VCB_READ_ONLY))
233  {
234  FFSBreakPoint();
235  return FALSE;
236  }
237 
238  bRet = FsRtlCopyWrite(
241 
242  return bRet;
243 }
244 
245 #endif // !FFS_READ_ONLY
246 
247 #endif /* DBG */
248 
249 
254  IN BOOLEAN Wait,
258 {
259  BOOLEAN Status = FALSE;
260  PFFS_VCB Vcb;
261  PFFS_FCB Fcb = 0;
262  BOOLEAN FcbMainResourceAcquired = FALSE;
263 
264  PAGED_CODE();
265 
266  _SEH2_TRY
267  {
268  _SEH2_TRY
269  {
271 
273  {
275  Status = TRUE;
276  _SEH2_LEAVE;
277  }
278 
280 
281  ASSERT(Vcb != NULL);
282 
283  Fcb = (PFFS_FCB)FileObject->FsContext;
284 
285  ASSERT(Fcb != NULL);
286 
287  if (Fcb->Identifier.Type == FFSVCB)
288  {
290  Status = TRUE;
291  _SEH2_LEAVE;
292  }
293 
294  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
295  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
296 
297  FFSPrint((DBG_INFO,
298  "FFSFastIoQueryBasicInfo: %s %s %s\n",
300  "FASTIO_QUERY_BASIC_INFO",
301  Fcb->AnsiFileName.Buffer));
302 
304  &Fcb->MainResource,
305  Wait))
306  {
307  Status = FALSE;
308  _SEH2_LEAVE;
309  }
310 
311  FcbMainResourceAcquired = TRUE;
312 
314 
315  /*
316  typedef struct _FILE_BASIC_INFORMATION {
317  LARGE_INTEGER CreationTime;
318  LARGE_INTEGER LastAccessTime;
319  LARGE_INTEGER LastWriteTime;
320  LARGE_INTEGER ChangeTime;
321  ULONG FileAttributes;
322  } FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION;
323  */
324 
325  if (FS_VERSION == 1)
326  {
327  Buffer->CreationTime = FFSSysTime(Fcb->dinode1->di_ctime);
328  Buffer->LastAccessTime = FFSSysTime(Fcb->dinode1->di_atime);
329  Buffer->LastWriteTime = FFSSysTime(Fcb->dinode1->di_mtime);
330  Buffer->ChangeTime = FFSSysTime(Fcb->dinode1->di_mtime);
331  }
332  else
333  {
334  Buffer->CreationTime = FFSSysTime((ULONG)Fcb->dinode2->di_ctime);
335  Buffer->LastAccessTime = FFSSysTime((ULONG)Fcb->dinode2->di_atime);
336  Buffer->LastWriteTime = FFSSysTime((ULONG)Fcb->dinode2->di_mtime);
337  Buffer->ChangeTime = FFSSysTime((ULONG)Fcb->dinode2->di_mtime);
338  }
339 
340 
341  Buffer->FileAttributes = Fcb->FFSMcb->FileAttr;
342 
343  IoStatus->Information = sizeof(FILE_BASIC_INFORMATION);
344 
345  IoStatus->Status = STATUS_SUCCESS;
346 
347  Status = TRUE;
348  }
350  {
351  IoStatus->Status = _SEH2_GetExceptionCode();
352  Status = TRUE;
353  } _SEH2_END;
354  }
355 
357  {
358  if (FcbMainResourceAcquired)
359  {
361  &Fcb->MainResource,
363  }
364 
366  } _SEH2_END;
367 
368 
369  if (Status == FALSE)
370  {
372  "FFSFastIoQueryBasicInfo: %s %s *** Status: FALSE ***\n",
374  "FASTIO_QUERY_BASIC_INFO"));
375  }
376  else if (IoStatus->Status != STATUS_SUCCESS)
377  {
379  "FFSFastIoQueryBasicInfo: %s %s *** Status: %s (%#x) ***\n",
381  "FASTIO_QUERY_BASIC_INFO",
382  FFSNtStatusToString(IoStatus->Status),
383  IoStatus->Status));
384  }
385 
386  return Status;
387 }
388 
389 
394  IN BOOLEAN Wait,
398 {
399 
400  BOOLEAN Status = FALSE;
401  PFFS_VCB Vcb;
402  PFFS_FCB Fcb = 0;
403  BOOLEAN FcbMainResourceAcquired = FALSE;
404 
405  PAGED_CODE();
406 
407  _SEH2_TRY
408  {
409  _SEH2_TRY
410  {
412 
414  {
416  Status = TRUE;
417  _SEH2_LEAVE;
418  }
419 
421 
422  ASSERT(Vcb != NULL);
423 
424  Fcb = (PFFS_FCB)FileObject->FsContext;
425 
426  ASSERT(Fcb != NULL);
427 
428  if (Fcb->Identifier.Type == FFSVCB)
429  {
431  Status = TRUE;
432  _SEH2_LEAVE;
433  }
434 
435  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
436  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
437 
439  "FFSFastIoQueryStandardInfo: %s %s %s\n",
441  "FASTIO_QUERY_STANDARD_INFO",
442  Fcb->AnsiFileName.Buffer));
443 
445  &Fcb->MainResource,
446  Wait))
447  {
448  Status = FALSE;
449  _SEH2_LEAVE;
450  }
451 
452  FcbMainResourceAcquired = TRUE;
453 
455 
456  /*
457  typedef struct _FILE_STANDARD_INFORMATION {
458  LARGE_INTEGER AllocationSize;
459  LARGE_INTEGER EndOfFile;
460  ULONG NumberOfLinks;
461  BOOLEAN DeletePending;
462  BOOLEAN Directory;
463  } FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION;
464  */
465 
466  if (FS_VERSION == 1)
467  {
468  Buffer->AllocationSize.QuadPart =
469  (LONGLONG)(Fcb->dinode1->di_size);
470 
471  Buffer->EndOfFile.QuadPart =
472  (LONGLONG)(Fcb->dinode1->di_size);
473 
474  Buffer->NumberOfLinks = Fcb->dinode1->di_nlink;
475  }
476  else
477  {
478  Buffer->AllocationSize.QuadPart =
479  (LONGLONG)(Fcb->dinode2->di_size);
480 
481  Buffer->EndOfFile.QuadPart =
482  (LONGLONG)(Fcb->dinode2->di_size);
483 
484  Buffer->NumberOfLinks = Fcb->dinode2->di_nlink;
485  }
486 
487 
488  if (IsFlagOn(Fcb->Vcb->Flags, VCB_READ_ONLY))
489  {
490  Buffer->DeletePending = FALSE;
491  }
492  else
493  {
494  Buffer->DeletePending = IsFlagOn(Fcb->Flags, FCB_DELETE_PENDING);
495  }
496 
497  if (FlagOn(Fcb->FFSMcb->FileAttr, FILE_ATTRIBUTE_DIRECTORY))
498  {
499  Buffer->Directory = TRUE;
500  }
501  else
502  {
503  Buffer->Directory = FALSE;
504  }
505 
506  IoStatus->Information = sizeof(FILE_STANDARD_INFORMATION);
507 
508  IoStatus->Status = STATUS_SUCCESS;
509 
510  Status = TRUE;
511  }
513  {
514  IoStatus->Status = _SEH2_GetExceptionCode();
515  Status = TRUE;
516  } _SEH2_END;
517  }
518 
520  {
521  if (FcbMainResourceAcquired)
522  {
524  &Fcb->MainResource,
526  );
527  }
528 
530  } _SEH2_END;
531 
532 #if DBG
533  if (Status == FALSE)
534  {
536  "FFSFastIoQueryStandardInfo: %s %s *** Status: FALSE ***\n",
538  "FASTIO_QUERY_STANDARD_INFO"));
539  }
540  else if (IoStatus->Status != STATUS_SUCCESS)
541  {
543  "FFSFastIoQueryStandardInfo: %s %s *** Status: %s (%#x) ***\n",
545  "FASTIO_QUERY_STANDARD_INFO",
546  FFSNtStatusToString(IoStatus->Status),
547  IoStatus->Status));
548  }
549 #endif
550 
551  return Status;
552 }
553 
554 
559  IN BOOLEAN Wait,
563 {
564  BOOLEAN Status = FALSE;
565  PFFS_VCB Vcb;
566  PFFS_FCB Fcb = 0;
567  BOOLEAN FcbMainResourceAcquired = FALSE;
568 
569  PAGED_CODE();
570 
571  _SEH2_TRY
572  {
573  _SEH2_TRY
574  {
576 
578  {
580  Status = TRUE;
581  _SEH2_LEAVE;
582  }
583 
585 
586  ASSERT(Vcb != NULL);
587 
588  Fcb = (PFFS_FCB)FileObject->FsContext;
589 
590  ASSERT(Fcb != NULL);
591 
592  if (Fcb->Identifier.Type == FFSVCB)
593  {
595  Status = TRUE;
596  _SEH2_LEAVE;
597  }
598 
599  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
600  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
601 
602  FFSPrint((DBG_INFO,
603  "%-16.16s %-31s %s\n",
605  "FASTIO_QUERY_NETWORK_OPEN_INFO",
606  Fcb->AnsiFileName.Buffer));
607 
609  &Fcb->MainResource,
610  Wait))
611  {
612  Status = FALSE;
613  _SEH2_LEAVE;
614  }
615 
616  FcbMainResourceAcquired = TRUE;
617 
619 
620  /*
621  typedef struct _FILE_NETWORK_OPEN_INFORMATION {
622  LARGE_INTEGER CreationTime;
623  LARGE_INTEGER LastAccessTime;
624  LARGE_INTEGER LastWriteTime;
625  LARGE_INTEGER ChangeTime;
626  LARGE_INTEGER AllocationSize;
627  LARGE_INTEGER EndOfFile;
628  ULONG FileAttributes;
629  } FILE_NETWORK_OPEN_INFORMATION, *PFILE_NETWORK_OPEN_INFORMATION;
630  */
631 
632  if (FS_VERSION == 1)
633  {
634  Buffer->CreationTime = FFSSysTime(Fcb->dinode1->di_ctime);
635  Buffer->LastAccessTime = FFSSysTime(Fcb->dinode1->di_atime);
636  Buffer->LastWriteTime = FFSSysTime(Fcb->dinode1->di_mtime);
637  Buffer->ChangeTime = FFSSysTime(Fcb->dinode1->di_mtime);
638  Buffer->FileAttributes = Fcb->FFSMcb->FileAttr;
639  Buffer->AllocationSize.QuadPart =
640  (LONGLONG)(Fcb->dinode1->di_size);
641  Buffer->EndOfFile.QuadPart =
642  (LONGLONG)(Fcb->dinode1->di_size);
643  }
644  else
645  {
646  Buffer->CreationTime = FFSSysTime((ULONG)Fcb->dinode2->di_ctime);
647  Buffer->LastAccessTime = FFSSysTime((ULONG)Fcb->dinode2->di_atime);
648  Buffer->LastWriteTime = FFSSysTime((ULONG)Fcb->dinode2->di_mtime);
649  Buffer->ChangeTime = FFSSysTime((ULONG)Fcb->dinode2->di_mtime);
650  Buffer->FileAttributes = Fcb->FFSMcb->FileAttr;
651  Buffer->AllocationSize.QuadPart =
652  (LONGLONG)(Fcb->dinode2->di_size);
653  Buffer->EndOfFile.QuadPart =
654  (LONGLONG)(Fcb->dinode2->di_size);
655  }
656 
657  Buffer->FileAttributes = Fcb->FFSMcb->FileAttr;
658 
659  IoStatus->Information = sizeof(FILE_NETWORK_OPEN_INFORMATION);
660 
661  IoStatus->Status = STATUS_SUCCESS;
662 
663  Status = TRUE;
664  }
666  {
667  IoStatus->Status = _SEH2_GetExceptionCode();
668  Status = TRUE;
669  } _SEH2_END;
670  }
672  {
673  if (FcbMainResourceAcquired)
674  {
676  &Fcb->MainResource,
678  );
679  }
680 
682  } _SEH2_END;
683 
684 
685 
686  if (Status == FALSE)
687  {
689  "%s %s *** Status: FALSE ***\n",
691  "FASTIO_QUERY_NETWORK_OPEN_INFO"));
692  }
693  else if (IoStatus->Status != STATUS_SUCCESS)
694  {
696  "%s %s *** Status: %s (%#x) ***\n",
698  "FASTIO_QUERY_NETWORK_OPEN_INFO",
699  FFSNtStatusToString(IoStatus->Status),
700  IoStatus->Status));
701  }
702 
703  return Status;
704 }
705 
706 
713  IN ULONG Key,
718 {
719  BOOLEAN Status = FALSE;
720  PFFS_FCB Fcb;
721 
722  PAGED_CODE();
723 
724  _SEH2_TRY
725  {
726  _SEH2_TRY
727  {
729 
731  {
733  Status = TRUE;
734  _SEH2_LEAVE;
735  }
736 
737  Fcb = (PFFS_FCB)FileObject->FsContext;
738 
739  ASSERT(Fcb != NULL);
740 
741  if (Fcb->Identifier.Type == FFSVCB)
742  {
744  Status = TRUE;
745  _SEH2_LEAVE;
746  }
747 
748  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
749  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
750 
751  if (IsDirectory(Fcb))
752  {
753  FFSBreakPoint();
755  Status = TRUE;
756  _SEH2_LEAVE;
757  }
758 
760  "FFSFastIoLock: %s %s %s\n",
762  "FASTIO_LOCK",
763  Fcb->AnsiFileName.Buffer));
764 
766  "FFSFastIoLock: Offset: %I64xh Length: %I64xh Key: %u %s%s\n",
767  FileOffset->QuadPart,
768  Length->QuadPart,
769  Key,
770  (FailImmediately ? "FailImmediately " : ""),
771  (ExclusiveLock ? "ExclusiveLock " : "")));
772 
773  if (Fcb->Header.IsFastIoPossible != FastIoIsQuestionable)
774  {
776  "FFSFastIoLock: %s %s %s\n",
778  "FastIoIsQuestionable",
779  Fcb->AnsiFileName.Buffer));
780 
781  Fcb->Header.IsFastIoPossible = FastIoIsQuestionable;
782  }
783 #ifdef _MSC_VER
784 #pragma prefast( suppress: 28159, "bug in prefast" )
785 #endif
787  &Fcb->FileLockAnchor,
788  FileObject,
789  FileOffset,
790  Length,
791  Process,
792  Key,
795  IoStatus,
796  NULL,
797  FALSE);
798  }
800  {
801  IoStatus->Status = _SEH2_GetExceptionCode();
802  Status = TRUE;
803  } _SEH2_END;
804  }
805 
807  {
809  } _SEH2_END;
810 
811 #if DBG
812  if (Status == FALSE)
813  {
815  "FFSFastIoLock: %s %s *** Status: FALSE ***\n",
817  "FASTIO_LOCK"));
818  }
819  else if (IoStatus->Status != STATUS_SUCCESS)
820  {
822  "FFSFastIoLock: %s %s *** Status: %s (%#x) ***\n",
824  "FASTIO_LOCK",
825  FFSNtStatusToString(IoStatus->Status),
826  IoStatus->Status));
827  }
828 #endif
829 
830  return Status;
831 }
832 
833 
840  IN ULONG Key,
843 {
844  BOOLEAN Status = FALSE;
845  PFFS_FCB Fcb;
846 
847  PAGED_CODE();
848 
849  _SEH2_TRY
850  {
851  _SEH2_TRY
852  {
854 
856  {
858  Status = TRUE;
859  _SEH2_LEAVE;
860  }
861 
862  Fcb = (PFFS_FCB)FileObject->FsContext;
863 
864  ASSERT(Fcb != NULL);
865 
866  if (Fcb->Identifier.Type == FFSVCB)
867  {
868  FFSBreakPoint();
870  Status = TRUE;
871  _SEH2_LEAVE;
872  }
873 
874  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
875  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
876 
877  if (IsDirectory(Fcb))
878  {
879  FFSBreakPoint();
881  Status = TRUE;
882  _SEH2_LEAVE;
883  }
884 
886  "FFSFastIoUnlockSingle: %s %s %s\n",
888  "FASTIO_UNLOCK_SINGLE",
889  Fcb->AnsiFileName.Buffer));
890 
892  "FFSFastIoUnlockSingle: Offset: %I64xh Length: %I64xh Key: %u\n",
893  FileOffset->QuadPart,
894  Length->QuadPart,
895  Key));
896 
898  &Fcb->FileLockAnchor,
899  FileObject,
900  FileOffset,
901  Length,
902  Process,
903  Key,
904  NULL,
905  FALSE);
906 
907  IoStatus->Information = 0;
908 
909  Status = TRUE;
910  }
912  {
913  IoStatus->Status = _SEH2_GetExceptionCode();
914  Status = TRUE;
915  } _SEH2_END;
916  }
918  {
920  } _SEH2_END;
921 
922 #if DBG
923  if (Status == FALSE)
924  {
926  "FFSFastIoUnlockSingle: %s %s *** Status: FALSE ***\n",
928  "FASTIO_UNLOCK_SINGLE"));
929  }
930  else if (IoStatus->Status != STATUS_SUCCESS)
931  {
933  "FFSFastIoUnlockSingle: %s %s *** Status: %s (%#x) ***\n",
935  "FASTIO_UNLOCK_SINGLE",
936  FFSNtStatusToString(IoStatus->Status),
937  IoStatus->Status));
938  }
939 #endif
940  return Status;
941 }
942 
943 
950 {
951  BOOLEAN Status = FALSE;
952  PFFS_FCB Fcb;
953 
954  PAGED_CODE();
955 
956  _SEH2_TRY
957  {
958  _SEH2_TRY
959  {
961 
963  {
965  Status = TRUE;
966  _SEH2_LEAVE;
967  }
968 
969  Fcb = (PFFS_FCB)FileObject->FsContext;
970 
971  ASSERT(Fcb != NULL);
972 
973  if (Fcb->Identifier.Type == FFSVCB)
974  {
975  FFSBreakPoint();
977  Status = TRUE;
978  _SEH2_LEAVE;
979  }
980 
981  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
982  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
983 
984  if (IsDirectory(Fcb))
985  {
986  FFSBreakPoint();
988  Status = TRUE;
989  _SEH2_LEAVE;
990  }
991 
993  "FFSFastIoUnlockSingle: %s %s %s\n",
995  "FASTIO_UNLOCK_ALL",
996  Fcb->AnsiFileName.Buffer));
997 
998  IoStatus->Status = FsRtlFastUnlockAll(
999  &Fcb->FileLockAnchor,
1000  FileObject,
1001  Process,
1002  NULL);
1003 
1004  IoStatus->Information = 0;
1005 
1006  Status = TRUE;
1007  }
1009  {
1010  IoStatus->Status = _SEH2_GetExceptionCode();
1011  Status = TRUE;
1012  } _SEH2_END;
1013  }
1015  {
1017  } _SEH2_END;
1018 
1019 #if DBG
1020  if (Status == FALSE)
1021  {
1023  "FFSFastIoUnlockSingle: %s %s *** Status: FALSE ***\n",
1025  "FASTIO_UNLOCK_ALL"));
1026  }
1027  else if (IoStatus->Status != STATUS_SUCCESS)
1028  {
1030  "FFSFastIoUnlockSingle: %s %s *** Status: %s (%#x) ***\n",
1032  "FASTIO_UNLOCK_ALL",
1033  FFSNtStatusToString(IoStatus->Status),
1034  IoStatus->Status));
1035  }
1036 #endif
1037  return Status;
1038 }
1039 
1040 
1041 BOOLEAN NTAPI
1044 #ifndef __REACTOS__
1046 #else
1047  IN PVOID Process,
1048 #endif
1049  IN ULONG Key,
1052 {
1053  BOOLEAN Status = FALSE;
1054  PFFS_FCB Fcb;
1055 
1056  PAGED_CODE();
1057 
1058  _SEH2_TRY
1059  {
1060  _SEH2_TRY
1061  {
1063 
1065  {
1067  Status = TRUE;
1068  _SEH2_LEAVE;
1069  }
1070 
1071  Fcb = (PFFS_FCB)FileObject->FsContext;
1072 
1073  ASSERT(Fcb != NULL);
1074 
1075  if (Fcb->Identifier.Type == FFSVCB)
1076  {
1077  FFSBreakPoint();
1079  Status = TRUE;
1080  _SEH2_LEAVE;
1081  }
1082 
1083  ASSERT((Fcb->Identifier.Type == FFSFCB) &&
1084  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
1085 
1086  if (IsDirectory(Fcb))
1087  {
1088  FFSBreakPoint();
1090  Status = TRUE;
1091  _SEH2_LEAVE;
1092  }
1093 
1094  FFSPrint((DBG_INFO,
1095  "FFSFastIoUnlockAllByKey: %s %s %s\n",
1097  "FASTIO_UNLOCK_ALL_BY_KEY",
1098  Fcb->AnsiFileName.Buffer));
1099 
1100  FFSPrint((DBG_INFO,
1101  "FFSFastIoUnlockAllByKey: Key: %u\n",
1102  Key));
1103 
1105  &Fcb->FileLockAnchor,
1106  FileObject,
1107  Process,
1108  Key,
1109  NULL);
1110 
1111  IoStatus->Information = 0;
1112 
1113  Status = TRUE;
1114  }
1115 
1117  {
1118  IoStatus->Status = _SEH2_GetExceptionCode();
1119  Status = TRUE;
1120  } _SEH2_END;
1121  }
1122 
1124  {
1126  } _SEH2_END;
1127 #if DBG
1128  if (Status == FALSE)
1129  {
1131  "FFSFastIoUnlockAllByKey: %s %s *** Status: FALSE ***\n",
1133  "FASTIO_UNLOCK_ALL_BY_KEY"));
1134  }
1135  else if (IoStatus->Status != STATUS_SUCCESS)
1136  {
1138  "FFSFastIoUnlockAllByKey: %s %s *** Status: %s (%#x) ***\n",
1140  "FASTIO_UNLOCK_ALL_BY_KEY",
1141  FFSNtStatusToString(IoStatus->Status),
1142  IoStatus->Status));
1143  }
1144 #endif
1145  return Status;
1146 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
Definition: ffsdrv.h:281
#define IN
Definition: typedefs.h:38
PCHAR FFSNtStatusToString(IN NTSTATUS Status)
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI FFSFastIoWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
BOOLEAN NTAPI FsRtlFastCheckLockForRead(IN PFILE_LOCK FileLock, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN ULONG Key, IN PFILE_OBJECT FileObject, IN PVOID Process)
Definition: filelock.c:752
#define FsRtlEnterFileSystem
#define FS_VERSION
Definition: ffsdrv.h:81
#define __drv_mustHoldCriticalRegion
Definition: ffsdrv.h:34
#define FsRtlExitFileSystem
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
BOOLEAN NTAPI FFSFastIoUnlockAll(IN PFILE_OBJECT FileObject, IN PEPROCESS Process, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:945
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char * PUCHAR
Definition: retypes.h:3
__drv_mustHoldCriticalRegion BOOLEAN NTAPI FFSFastIoQueryNetworkOpenInfo(IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, OUT PFILE_NETWORK_OPEN_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:557
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
struct _FFS_FCB * PFFS_FCB
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN CheckForReadOperation
Definition: fatprocs.h:2650
#define FCB_DELETE_PENDING
Definition: ext2fs.h:879
PDEVICE_OBJECT DeviceObject
Definition: ffsdrv.h:371
ULONG ProcessNameOffset
#define PAGED_CODE()
Definition: video.h:57
struct _FILE_NETWORK_OPEN_INFORMATION FILE_NETWORK_OPEN_INFORMATION
_SEH2_TRY
Definition: create.c:4250
#define FFSBreakPoint()
Definition: ffsdrv.h:43
NTSTATUS NTAPI FsRtlFastUnlockAllByKey(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN ULONG Key, IN PVOID Context OPTIONAL)
Definition: filelock.c:1087
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
NTSTATUS NTAPI FsRtlFastUnlockSingle(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN PEPROCESS Process, IN ULONG Key, IN PVOID Context OPTIONAL, IN BOOLEAN AlreadySynchronized)
Definition: filelock.c:829
PFFS_GLOBAL FFSGlobal
Definition: init.c:22
BOOLEAN NTAPI FFSFastIoUnlockAllByKey(IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:1042
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG BOOLEAN FailImmediately
Definition: fatprocs.h:2697
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
LARGE_INTEGER FFSSysTime(IN ULONG i_time)
Definition: misc.c:53
smooth NULL
Definition: ftsmooth.c:416
struct _FFS_VCB * PFFS_VCB
Definition: bufpool.h:45
BOOLEAN NTAPI FFSFastIoUnlockSingle(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN PEPROCESS Process, IN ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:835
#define FFSGetCurrentProcessName()
Definition: ffsdrv.h:1070
BOOLEAN NTAPI FFSFastIoRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG LockKey
Definition: fatprocs.h:2650
int64_t LONGLONG
Definition: typedefs.h:66
#define Vcb
Definition: cdprocs.h:1425
__drv_mustHoldCriticalRegion BOOLEAN NTAPI FFSFastIoQueryBasicInfo(IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, OUT PFILE_BASIC_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:252
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
* PFILE_OBJECT
Definition: iotypes.h:1955
BOOLEAN NTAPI FFSFastIoCheckIfPossible(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, IN BOOLEAN CheckForReadOperation, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:41
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Flags
Definition: ntfs.h:532
#define VCB_WRITE_PROTECTED
Definition: ext2fs.h:796
_Must_inspect_result_ _In_ PFLT_INSTANCE _Out_ PBOOLEAN IsDirectory
Definition: fltkernel.h:1139
ULONG Type
Definition: ntfs.h:95
#define FILE_STANDARD_INFORMATION
Definition: disk.h:54
Definition: ffsdrv.h:280
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
NTSTATUS NTAPI FsRtlFastUnlockAll(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN PVOID Context OPTIONAL)
Definition: filelock.c:1026
ERESOURCE MainResource
Definition: ntfs.h:524
#define VCB_READ_ONLY
Definition: ext2fs.h:795
Status
Definition: gdiplustypes.h:24
__drv_mustHoldCriticalRegion BOOLEAN NTAPI FFSFastIoQueryStandardInfo(IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, OUT PFILE_STANDARD_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:392
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
_SEH2_FINALLY
Definition: create.c:4395
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG BOOLEAN BOOLEAN ExclusiveLock
Definition: fatprocs.h:2697
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
BOOLEAN NTAPI FsRtlCopyRead(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:64
BOOLEAN NTAPI FsRtlCopyWrite(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, OUT PVOID Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:264
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PVCB Vcb
Definition: cdstruc.h:939
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define DBG_INFO
Definition: ffsdrv.h:1034
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
#define _SEH2_LEAVE
Definition: filesup.c:20
_In_ PFCB Fcb
Definition: cdprocs.h:151
return STATUS_SUCCESS
Definition: btrfs.c:2966
#define FsRtlFastLock(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)
Definition: fsrtlfuncs.h:1581
BOOLEAN NTAPI FsRtlFastCheckLockForWrite(IN PFILE_LOCK FileLock, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN ULONG Key, IN PFILE_OBJECT FileObject, IN PVOID Process)
Definition: filelock.c:786
ULONG Size
Definition: ntfs.h:96
LONGLONG QuadPart
Definition: typedefs.h:112
BOOLEAN NTAPI FFSFastIoLock(IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, IN PEPROCESS Process, IN ULONG Key, IN BOOLEAN FailImmediately, IN BOOLEAN ExclusiveLock, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
Definition: fastio.c:708
IN BOOLEAN Wait
Definition: fatprocs.h:1529
#define FILE_BASIC_INFORMATION
Definition: disk.h:53