ReactOS  0.4.14-dev-52-g6116262
fsctl.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: GNU GENERAL PUBLIC LICENSE VERSION 2
3  * PROJECT: ReiserFs file system driver for Windows NT/2000/XP/Vista.
4  * FILE: fsctl.c
5  * PURPOSE:
6  * PROGRAMMER: Mark Piper, Matt Wu, Bo BrantÚn.
7  * HOMEPAGE:
8  * UPDATE HISTORY:
9  */
10 
11 /* INCLUDES *****************************************************************/
12 
13 #include "rfsd.h"
14 
15 /* GLOBALS ***************************************************************/
16 
18 
19 /* DEFINITIONS *************************************************************/
20 
21 BOOLEAN
23  IN PRFSD_IRP_CONTEXT IrpContext,
25 
26 #ifdef ALLOC_PRAGMA
27 //#pragma alloc_text(PAGE, RfsdSetVpbFlag)
28 //#pragma alloc_text(PAGE, RfsdClearVpbFlag)
29 #pragma alloc_text(PAGE, RfsdIsHandleCountZero)
30 #pragma alloc_text(PAGE, RfsdLockVcb)
31 #pragma alloc_text(PAGE, RfsdLockVolume)
32 #pragma alloc_text(PAGE, RfsdUnlockVcb)
33 #pragma alloc_text(PAGE, RfsdUnlockVolume)
34 #pragma alloc_text(PAGE, RfsdAllowExtendedDasdIo)
35 #pragma alloc_text(PAGE, RfsdUserFsRequest)
36 #pragma alloc_text(PAGE, RfsdIsMediaWriteProtected)
37 #pragma alloc_text(PAGE, RfsdMountVolume)
38 #pragma alloc_text(PAGE, RfsdCheckDismount)
39 #pragma alloc_text(PAGE, RfsdPurgeVolume)
40 #pragma alloc_text(PAGE, RfsdPurgeFile)
41 #pragma alloc_text(PAGE, RfsdDismountVolume)
42 #pragma alloc_text(PAGE, RfsdIsVolumeMounted)
43 #pragma alloc_text(PAGE, RfsdVerifyVolume)
44 #pragma alloc_text(PAGE, RfsdFileSystemControl)
45 #endif
46 
47 VOID
49  IN PVPB Vpb,
50  IN USHORT Flag )
51 {
52  KIRQL OldIrql;
53 
55 
56  Vpb->Flags |= Flag;
57 
59 }
60 
61 VOID
63  IN PVPB Vpb,
64  IN USHORT Flag )
65 {
66  KIRQL OldIrql;
67 
69 
70  Vpb->Flags &= ~Flag;
71 
73 }
74 
75 BOOLEAN
77 {
78  PRFSD_FCB Fcb;
80 
81  PAGED_CODE();
82 
83  for( List = Vcb->FcbList.Flink;
84  List != &Vcb->FcbList;
85  List = List->Flink ) {
86 
88 
90  (Fcb->Identifier.Size == sizeof(RFSD_FCB)));
91 
92  RfsdPrint((DBG_INFO, "RfsdIsHandleCountZero: Key:%x,%xh File:%S OpenHandleCount=%xh\n",
93  Fcb->RfsdMcb->Key.k_dir_id, Fcb->RfsdMcb->Key.k_objectid, Fcb->RfsdMcb->ShortName.Buffer, Fcb->OpenHandleCount));
94 
95  if (Fcb->OpenHandleCount) {
96  return FALSE;
97  }
98  }
99 
100  return TRUE;
101 }
102 
103 NTSTATUS
106 {
108 
109  PAGED_CODE();
110 
111  _SEH2_TRY {
112 
113  if (FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
114  RfsdPrint((DBG_INFO, "RfsdLockVolume: Volume is already locked.\n"));
115 
117 
118  _SEH2_LEAVE;
119  }
120 
121  if (Vcb->OpenFileHandleCount > (ULONG)(FileObject ? 1 : 0)) {
122  RfsdPrint((DBG_INFO, "RfsdLockVcb: There are still opened files.\n"));
123 
125 
126  _SEH2_LEAVE;
127  }
128 
129  if (!RfsdIsHandleCountZero(Vcb)) {
130  RfsdPrint((DBG_INFO, "RfsdLockVcb: Thare are still opened files.\n"));
131 
133 
134  _SEH2_LEAVE;
135  }
136 
137  SetFlag(Vcb->Flags, VCB_VOLUME_LOCKED);
138 
140 
141  Vcb->LockFile = FileObject;
142 
143  RfsdPrint((DBG_INFO, "RfsdLockVcb: Volume locked.\n"));
144 
146 
147  } _SEH2_FINALLY {
148  // Nothing
149  } _SEH2_END;
150 
151  return Status;
152 }
153 
155 NTSTATUS
157 {
160  PRFSD_VCB Vcb = 0;
162  BOOLEAN VcbResourceAcquired = FALSE;
163 
164  PAGED_CODE();
165 
166  _SEH2_TRY {
167 
168  ASSERT(IrpContext != NULL);
169 
170  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
171  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
172 
173  DeviceObject = IrpContext->DeviceObject;
174 
176 
177  //
178  // This request is not allowed on the main device object
179  //
182  _SEH2_LEAVE;
183  }
184 
186 
187  ASSERT(Vcb != NULL);
188 
189  ASSERT((Vcb->Identifier.Type == RFSDVCB) &&
190  (Vcb->Identifier.Size == sizeof(RFSD_VCB)));
191 
192  ASSERT(IsMounted(Vcb));
193 
194  IrpSp = IoGetCurrentIrpStackLocation(IrpContext->Irp);
195 
196 #if (_WIN32_WINNT >= 0x0500)
198 #endif
200  &Vcb->MainResource,
201  TRUE );
202 
203  VcbResourceAcquired = TRUE;
204 
206 
207  } _SEH2_FINALLY {
208 
209  if (VcbResourceAcquired) {
211  &Vcb->MainResource,
213  );
214  }
215 
216  if (!IrpContext->ExceptionInProgress) {
217  RfsdCompleteIrpContext(IrpContext, Status);
218  }
219  } _SEH2_END;
220 
221  return Status;
222 }
223 
224 NTSTATUS
227 {
229 
230  PAGED_CODE();
231 
232  _SEH2_TRY {
233 
234  if (FileObject && FileObject->FsContext != Vcb) {
235 
237  _SEH2_LEAVE;
238  }
239 
240  if (!FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
241  RfsdPrint((DBG_ERROR, ": RfsdUnlockVcb: Volume is not locked.\n"));
243  _SEH2_LEAVE;
244  }
245 
246  if (Vcb->LockFile == FileObject) {
247 
249 
251 
252  RfsdPrint((DBG_INFO, "RfsdUnlockVcb: Volume unlocked.\n"));
253 
255  } else {
257  }
258 
259  } _SEH2_FINALLY {
260  // Nothing
261  } _SEH2_END;
262 
263  return Status;
264 }
265 
267 NTSTATUS
269  IN PRFSD_IRP_CONTEXT IrpContext
270  )
271 {
275  PRFSD_VCB Vcb = 0;
276  BOOLEAN VcbResourceAcquired = FALSE;
277 
278  PAGED_CODE();
279 
280  _SEH2_TRY {
281 
282  ASSERT(IrpContext != NULL);
283 
284  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
285  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
286 
287  DeviceObject = IrpContext->DeviceObject;
288 
289  //
290  // This request is not allowed on the main device object
291  //
294  _SEH2_LEAVE;
295  }
296 
298 
299  ASSERT(Vcb != NULL);
300 
301  ASSERT((Vcb->Identifier.Type == RFSDVCB) &&
302  (Vcb->Identifier.Size == sizeof(RFSD_VCB)));
303 
304  ASSERT(IsMounted(Vcb));
305 
306  IrpSp = IoGetCurrentIrpStackLocation(IrpContext->Irp);
307 
309  &Vcb->MainResource,
310  TRUE );
311 
312  VcbResourceAcquired = TRUE;
313 
315 
316  } _SEH2_FINALLY {
317 
318  if (VcbResourceAcquired) {
320  &Vcb->MainResource,
322  );
323  }
324 
325  if (!IrpContext->ExceptionInProgress) {
326  RfsdCompleteIrpContext(IrpContext, Status);
327  }
328  } _SEH2_END;
329 
330  return Status;
331 }
332 
334 NTSTATUS
336 {
338  PIRP Irp;
340 
341  HANDLE Handle;
342 
343  PLIST_ENTRY ListEntry;
344 
347  BOOLEAN GlobalResourceAcquired = FALSE;
348 
350 
351  _SEH2_TRY {
352 
353  Irp = IrpContext->Irp;
355 
356  if (!SeSinglePrivilegeCheck(Privilege, Irp->RequestorMode)) {
358  _SEH2_LEAVE;
359  }
360 
361  if (
362 #ifndef _GNU_NTIFS_
363  IrpSp->Parameters.FileSystemControl.InputBufferLength
364 #else
366  Parameters.FileSystemControl.InputBufferLength
367 #endif
368  != sizeof(HANDLE)) {
369 
371 
372  _SEH2_LEAVE;
373  }
374 
375  Handle = *(PHANDLE)Irp->AssociatedIrp.SystemBuffer;
376 
378  0,
380  KernelMode,
381  (void **)&FileObject,
382  NULL );
383 
384  if (!NT_SUCCESS(Status)) {
385  _SEH2_LEAVE;
386  } else {
388  DeviceObject = FileObject->DeviceObject;
389  }
390 
391  RfsdPrint((DBG_INFO, "RfsdInvalidateVolumes: FileObject=%xh ...\n", FileObject));
392 
395  TRUE );
396 
397  GlobalResourceAcquired = TRUE;
398 
399  ListEntry = RfsdGlobal->VcbList.Flink;
400 
401  while (ListEntry != &RfsdGlobal->VcbList) {
402 
403  PRFSD_VCB Vcb;
404 
405  Vcb = CONTAINING_RECORD(ListEntry, RFSD_VCB, Next);
406 
407  ListEntry = ListEntry->Flink;
408 
409  RfsdPrint((DBG_INFO, "RfsdInvalidateVolumes: Vcb=%xh Vcb->Vpb=%xh...\n", Vcb, Vcb->Vpb));
410  if (Vcb->Vpb && (Vcb->Vpb->RealDevice == DeviceObject))
411  {
412  ExAcquireResourceExclusiveLite(&Vcb->MainResource, TRUE);
413  RfsdPrint((DBG_INFO, "RfsdInvalidateVolumes: RfsdPurgeVolume...\n"));
415  ClearFlag(Vcb->Flags, VCB_MOUNTED);
416  ExReleaseResourceLite(&Vcb->MainResource);
417 
418  //
419  // Vcb is still attached on the list ......
420  //
421 
422  if (ListEntry->Blink == &Vcb->Next)
423  {
424  RfsdPrint((DBG_INFO, "RfsdInvalidateVolumes: RfsdCheckDismount...\n"));
425  RfsdCheckDismount(IrpContext, Vcb, FALSE);
426  }
427  }
428  }
429 
430  } _SEH2_FINALLY {
431 
432  if (GlobalResourceAcquired) {
436  }
437 
438  RfsdCompleteIrpContext(IrpContext, Status);
439  } _SEH2_END;
440 
441  return Status;
442 }
443 
444 NTSTATUS
446 {
448  PRFSD_VCB Vcb;
449  PRFSD_CCB Ccb;
450 
451  PAGED_CODE();
452 
453  IrpSp = IoGetCurrentIrpStackLocation(IrpContext->Irp);
454 
455  Vcb = (PRFSD_VCB) IrpSp->FileObject->FsContext;
456  Ccb = (PRFSD_CCB) IrpSp->FileObject->FsContext2;
457 
458  ASSERT(Vcb != NULL);
459 
460  ASSERT((Vcb->Identifier.Type == RFSDVCB) &&
461  (Vcb->Identifier.Size == sizeof(RFSD_VCB)));
462 
463  ASSERT(IsMounted(Vcb));
464 
465  if (Ccb) {
467 
469 
470  return STATUS_SUCCESS;
471  } else {
473  }
474 }
475 
477 NTSTATUS
479 {
480  PIRP Irp;
481  PIO_STACK_LOCATION IoStackLocation;
484 
485  PAGED_CODE();
486 
487  ASSERT(IrpContext);
488 
489  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
490  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
491 
492  Irp = IrpContext->Irp;
493 
494  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
495 
496 #ifndef _GNU_NTIFS_
497  FsControlCode =
498  IoStackLocation->Parameters.FileSystemControl.FsControlCode;
499 #else
501  IoStackLocation)->Parameters.FileSystemControl.FsControlCode;
502 #endif
503 
504  switch (FsControlCode) {
505 
506  case FSCTL_LOCK_VOLUME:
507  Status = RfsdLockVolume(IrpContext);
508  break;
509 
510  case FSCTL_UNLOCK_VOLUME:
511  Status = RfsdUnlockVolume(IrpContext);
512  break;
513 
515  Status = RfsdDismountVolume(IrpContext);
516  break;
517 
519  Status = RfsdIsVolumeMounted(IrpContext);
520  break;
521 
523  Status = RfsdInvalidateVolumes(IrpContext);
524  break;
525 
526 #if (_WIN32_WINNT >= 0x0500)
528  Status = RfsdAllowExtendedDasdIo(IrpContext);
529  break;
530 #endif //(_WIN32_WINNT >= 0x0500)
531 
532  default:
533 
534  RfsdPrint((DBG_ERROR, "RfsdUserFsRequest: Invalid User Request: %xh.\n", FsControlCode));
536 
537  RfsdCompleteIrpContext(IrpContext, Status);
538  }
539 
540  return Status;
541 }
542 
543 BOOLEAN
545  IN PRFSD_IRP_CONTEXT IrpContext,
547  )
548 {
549  PIRP Irp;
550  KEVENT Event;
553 
554  PAGED_CODE();
555 
557 
559  TargetDevice,
560  NULL,
561  0,
562  NULL,
563  0,
564  FALSE,
565  &Event,
566  &IoStatus );
567 
568  if (Irp == NULL) {
569  return FALSE;
570  }
571 
573 
575 
576  if (Status == STATUS_PENDING) {
577 
579  Executive,
580  KernelMode,
581  FALSE,
582  (PLARGE_INTEGER)NULL );
583 
584  Status = IoStatus.Status;
585  }
586 
588 }
589 
591 NTSTATUS
593 {
595  BOOLEAN GlobalDataResourceAcquired = FALSE;
596  PIRP Irp;
597  PIO_STACK_LOCATION IoStackLocation;
600  PDEVICE_OBJECT VolumeDeviceObject = NULL;
601  PRFSD_VCB Vcb;
602  PRFSD_SUPER_BLOCK RfsdSb = NULL;
603  ULONG dwBytes;
604  DISK_GEOMETRY DiskGeometry;
605 
606  PAGED_CODE();
607 
608  _SEH2_TRY {
609 
610 
611  ASSERT(IrpContext != NULL);
612 
613  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
614  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
615 
616  MainDeviceObject = IrpContext->DeviceObject;
617 
618  //
619  // Make sure we can wait.
620  //
621 
622  SetFlag(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT);
623 
624  //
625  // This request is only allowed on the main device object
626  //
629  _SEH2_LEAVE;
630  }
631 
633  &(RfsdGlobal->Resource),
634  TRUE );
635 
636  GlobalDataResourceAcquired = TRUE;
637 
640  _SEH2_LEAVE;
641  }
642 
643  Irp = IrpContext->Irp;
644 
645  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
646 
648  IoStackLocation->Parameters.MountVolume.DeviceObject;
649 
650  dwBytes = sizeof(DISK_GEOMETRY);
654  NULL,
655  0,
656  &DiskGeometry,
657  &dwBytes );
658 
659  if (!NT_SUCCESS(Status)) {
660  _SEH2_LEAVE;
661  }
662 
664  MainDeviceObject->DriverObject,
665  sizeof(RFSD_VCB),
666  NULL,
668  0,
669  FALSE,
670  &VolumeDeviceObject );
671 
672  if (!NT_SUCCESS(Status)) {
673  _SEH2_LEAVE;
674  }
675 
676  VolumeDeviceObject->StackSize = (CCHAR)(TargetDeviceObject->StackSize + 1);
677 
678  if (TargetDeviceObject->AlignmentRequirement >
679  VolumeDeviceObject->AlignmentRequirement) {
680 
681  VolumeDeviceObject->AlignmentRequirement =
682  TargetDeviceObject->AlignmentRequirement;
683  }
684 
685  (IoStackLocation->Parameters.MountVolume.Vpb)->DeviceObject =
686  VolumeDeviceObject;
687 
688  Vcb = (PRFSD_VCB) VolumeDeviceObject->DeviceExtension;
689 
690  RtlZeroMemory(Vcb, sizeof(RFSD_VCB));
691 
692  Vcb->Identifier.Type = RFSDVCB;
693  Vcb->Identifier.Size = sizeof(RFSD_VCB);
694 
695  Vcb->TargetDeviceObject = TargetDeviceObject;
696  Vcb->DiskGeometry = DiskGeometry;
697 
698  RfsdSb = RfsdLoadSuper(Vcb, FALSE);
699 
700  if (RfsdSb) {
701  if ( SuperblockContainsMagicKey(RfsdSb) ) {
702  RfsdPrint((DBG_INFO, "Volume of ReiserFS rfsd file system is found.\n"));
704  } else {
706  }
707  }
708 
709  if (!NT_SUCCESS(Status)) {
710  _SEH2_LEAVE;
711  }
712 
713  Vcb->BlockSize = RfsdSb->s_blocksize; // NOTE: FFS also does this here, since LoadGroup is not called in the non-ext2 drivers
714  Vcb->GroupDesc = NULL; // NOTE: GroupDesc is not used for ReiserFS. Setting it to NULL will keep other code from barfing.
715  // Vcb->SectorBits = RFSDLog(SECTOR_SIZE); // NOTE: SectorBits are unused for ReiserFS
716 
717  Status = RfsdInitializeVcb(IrpContext, Vcb, RfsdSb, TargetDeviceObject,
718  VolumeDeviceObject, IoStackLocation->Parameters.MountVolume.Vpb);
719 
720  if (NT_SUCCESS(Status)) {
723  } else {
725  }
726 
727  SetFlag(Vcb->Flags, VCB_MOUNTED);
728 
730 
731  ClearFlag(VolumeDeviceObject->Flags, DO_DEVICE_INITIALIZING);
732  }
733 
734  } _SEH2_FINALLY {
735 
736  if (GlobalDataResourceAcquired) {
740  }
741 
742  if (!NT_SUCCESS(Status)) {
743 
744  if (RfsdSb) {
745  ExFreePool(RfsdSb);
746  }
747 
748  if (VolumeDeviceObject) {
749  IoDeleteDevice(VolumeDeviceObject);
750  }
751  }
752 
753  if (!IrpContext->ExceptionInProgress) {
754  if (NT_SUCCESS(Status)) {
755  ClearFlag(VolumeDeviceObject->Flags, DO_DEVICE_INITIALIZING);
756  }
757  RfsdCompleteIrpContext(IrpContext, Status);
758  }
759  } _SEH2_END;
760 
761  return Status;
762 }
763 
765 NTSTATUS
767 {
768 
771  PRFSD_SUPER_BLOCK rfsd_sb = NULL;
772  PRFSD_VCB Vcb = 0;
773  BOOLEAN VcbResourceAcquired = FALSE;
774  BOOLEAN GlobalResourceAcquired = FALSE;
775  PIRP Irp;
776  PIO_STACK_LOCATION IoStackLocation;
777  ULONG ChangeCount;
778  ULONG dwReturn;
779 
780  PAGED_CODE();
781 
782  _SEH2_TRY {
783 
784  ASSERT(IrpContext != NULL);
785 
786  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
787  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
788 
789  DeviceObject = IrpContext->DeviceObject;
790  //
791  // This request is not allowed on the main device object
792  //
795  _SEH2_LEAVE;
796  }
797 
800  TRUE );
801 
802  GlobalResourceAcquired = TRUE;
803 
805 
806  ASSERT(Vcb != NULL);
807 
808  ASSERT((Vcb->Identifier.Type == RFSDVCB) &&
809  (Vcb->Identifier.Size == sizeof(RFSD_VCB)));
810 
812  &Vcb->MainResource,
813  TRUE );
814 
815  VcbResourceAcquired = TRUE;
816 
817  if (!FlagOn(Vcb->TargetDeviceObject->Flags, DO_VERIFY_VOLUME)) {
819  _SEH2_LEAVE;
820  }
821 
822  if (!IsMounted(Vcb)) {
824  _SEH2_LEAVE;
825  }
826 
827  dwReturn = sizeof(ULONG);
829  Vcb->TargetDeviceObject,
831  NULL,
832  0,
833  &ChangeCount,
834  &dwReturn );
835 
836  if (ChangeCount != Vcb->ChangeCount) {
838  _SEH2_LEAVE;
839  }
840 
841  Irp = IrpContext->Irp;
842 
843  IoStackLocation = IoGetCurrentIrpStackLocation(Irp);
844 
845  rfsd_sb = RfsdLoadSuper(Vcb, TRUE);
846 
847  // FUTURE: use the volume name and uuid from the extended superblock to make this happen.
848  // NOTE: The magic check will have to use the same thing as mount did!
849  if ((rfsd_sb != NULL) /*&& (rfsd_sb->s_magic == RFSD_SUPER_MAGIC) &&
850  (memcmp(rfsd_sb->s_uuid, SUPER_BLOCK->s_uuid, 16) == 0) &&
851  (memcmp(rfsd_sb->s_volume_name, SUPER_BLOCK->s_volume_name, 16) ==0)*/) {
852  ClearFlag(Vcb->TargetDeviceObject->Flags, DO_VERIFY_VOLUME);
853 
854  if (RfsdIsMediaWriteProtected(IrpContext, Vcb->TargetDeviceObject)) {
856  } else {
858  }
859 
860  RfsdPrint((DBG_INFO, "RfsdVerifyVolume: Volume verify succeeded.\n"));
861 
863  } else {
865 
867 
869 
870  ClearFlag(Vcb->TargetDeviceObject->Flags, DO_VERIFY_VOLUME);
871 
872  RfsdPrint((DBG_INFO, "RfsdVerifyVolume: Volume verify failed.\n"));
873  }
874 
875  } _SEH2_FINALLY {
876 
877  if (rfsd_sb)
878  ExFreePool(rfsd_sb);
879 
880  if (VcbResourceAcquired) {
882  &Vcb->MainResource,
884  );
885  }
886 
887  if (GlobalResourceAcquired) {
891  }
892 
893  if (!IrpContext->ExceptionInProgress) {
894  RfsdCompleteIrpContext(IrpContext, Status);
895  }
896  } _SEH2_END;
897 
898  return Status;
899 }
900 
902 NTSTATUS
904 {
905  PAGED_CODE();
906 
907  ASSERT(IrpContext);
908 
909  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
910  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
911 
912  return RfsdVerifyVolume(IrpContext);
913 }
914 
916 NTSTATUS
918 {
921  PRFSD_VCB Vcb = 0;
922  BOOLEAN VcbResourceAcquired = FALSE;
923 
924  PAGED_CODE();
925 
926  _SEH2_TRY {
927 
928  ASSERT(IrpContext != NULL);
929 
930  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
931  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
932 
933  DeviceObject = IrpContext->DeviceObject;
934 
935  //
936  // This request is not allowed on the main device object
937  //
940  _SEH2_LEAVE;
941  }
942 
944 
945  ASSERT(Vcb != NULL);
946 
947  ASSERT((Vcb->Identifier.Type == RFSDVCB) &&
948  (Vcb->Identifier.Size == sizeof(RFSD_VCB)));
949 
950  ASSERT(IsMounted(Vcb));
951 
953  &Vcb->MainResource,
954  TRUE );
955 
956  VcbResourceAcquired = TRUE;
957 
958  if ( IsFlagOn(Vcb->Flags, VCB_DISMOUNT_PENDING)) {
960  _SEH2_LEAVE;
961  }
962 
963 /*
964  if (!FlagOn(Vcb->Flags, VCB_VOLUME_LOCKED)) {
965  RfsdPrint((DBG_ERROR, "RfsdDismount: Volume is not locked.\n"));
966 
967  Status = STATUS_ACCESS_DENIED;
968 
969  _SEH2_LEAVE;
970  }
971 */
972 #if DISABLED
974 
976 
978 #endif
980  &Vcb->MainResource,
982 
983  VcbResourceAcquired = FALSE;
984 
985  RfsdCheckDismount(IrpContext, Vcb, TRUE);
986 
987  RfsdPrint((DBG_INFO, "RfsdDismount: Volume dismount pending.\n"));
988 
990 
991  } _SEH2_FINALLY {
992 
993  if (VcbResourceAcquired) {
995  &Vcb->MainResource,
997  );
998  }
999 
1000  if (!IrpContext->ExceptionInProgress) {
1001  RfsdCompleteIrpContext(IrpContext, Status);
1002  }
1003  } _SEH2_END;
1004 
1005  return Status;
1006 }
1007 
1009 BOOLEAN
1011  IN PRFSD_IRP_CONTEXT IrpContext,
1012  IN PRFSD_VCB Vcb,
1013  IN BOOLEAN bForce )
1014 {
1015  KIRQL Irql;
1016  PVPB Vpb = Vcb->Vpb;
1017  BOOLEAN bDeleted = FALSE;
1018  ULONG UnCleanCount = 0;
1019 
1020  PAGED_CODE();
1021 
1023  &RfsdGlobal->Resource, TRUE );
1024 
1026  &Vcb->MainResource, TRUE );
1027 
1028  if ((IrpContext->MajorFunction == IRP_MJ_CREATE) &&
1029  (IrpContext->RealDevice == Vcb->RealDevice)) {
1030  UnCleanCount = 3;
1031  } else {
1032  UnCleanCount = 2;
1033  }
1034 
1036 
1037  if ((Vpb->ReferenceCount == UnCleanCount) || bForce) {
1038 
1039  if ((Vpb->ReferenceCount != UnCleanCount) && bForce) {
1040  KdPrint(("RfsdCheckDismount: force dismount ...\n"));
1041  }
1042 
1043  ClearFlag( Vpb->Flags, VPB_MOUNTED );
1044  ClearFlag( Vpb->Flags, VPB_LOCKED );
1045 
1046 #ifdef _MSC_VER
1047 #pragma prefast( suppress: 28175, "allowed in file system drivers" )
1048 #endif
1049  if ((Vcb->RealDevice != Vpb->RealDevice) &&
1050  (Vcb->RealDevice->Vpb == Vpb)) {
1051  SetFlag( Vcb->RealDevice->Flags, DO_DEVICE_INITIALIZING );
1052  SetFlag( Vpb->Flags, VPB_PERSISTENT );
1053  }
1054 
1055  RfsdRemoveVcb(Vcb);
1056 
1057  ClearFlag(Vpb->Flags, VPB_MOUNTED);
1058  SetFlag(Vcb->Flags, VCB_DISMOUNT_PENDING);
1059 
1060  Vpb->DeviceObject = NULL;
1061 
1062  bDeleted = TRUE;
1063  }
1064 
1066 
1068  &Vcb->MainResource,
1070 
1072  &RfsdGlobal->Resource,
1074 
1075  if (bDeleted) {
1076  KdPrint(("RfsdCheckDismount: now free the vcb ...\n"));
1077  RfsdFreeVcb(Vcb);
1078  }
1079 
1080  return bDeleted;
1081 }
1082 
1084 NTSTATUS
1086  IN BOOLEAN FlushBeforePurge )
1087 {
1088  PRFSD_FCB Fcb;
1089  LIST_ENTRY FcbList;
1090  PLIST_ENTRY ListEntry;
1091  PFCB_LIST_ENTRY FcbListEntry;
1092 
1093  PAGED_CODE();
1094 
1095  _SEH2_TRY {
1096 
1097  ASSERT(Vcb != NULL);
1098 
1099  ASSERT((Vcb->Identifier.Type == RFSDVCB) &&
1100  (Vcb->Identifier.Size == sizeof(RFSD_VCB)));
1101 
1102  if ( IsFlagOn(Vcb->Flags, VCB_READ_ONLY) ||
1103  IsFlagOn(Vcb->Flags, VCB_WRITE_PROTECTED)) {
1104  FlushBeforePurge = FALSE;
1105  }
1106 
1107  FcbListEntry= NULL;
1108  InitializeListHead(&FcbList);
1109 
1110  for (ListEntry = Vcb->FcbList.Flink;
1111  ListEntry != &Vcb->FcbList;
1112  ListEntry = ListEntry->Flink ) {
1113 
1114  Fcb = CONTAINING_RECORD(ListEntry, RFSD_FCB, Next);
1115 
1116  Fcb->ReferenceCount++;
1117 
1118  RfsdPrint((DBG_INFO, "RfsdPurgeVolume: %s refercount=%xh\n", Fcb->AnsiFileName.Buffer, Fcb->ReferenceCount));
1119 
1120  FcbListEntry = ExAllocatePoolWithTag(PagedPool, sizeof(FCB_LIST_ENTRY), RFSD_POOL_TAG);
1121 
1122  if (FcbListEntry) {
1123 
1124  FcbListEntry->Fcb = Fcb;
1125 
1126  InsertTailList(&FcbList, &FcbListEntry->Next);
1127  } else {
1128  RfsdPrint((DBG_ERROR, "RfsdPurgeVolume: Error allocating FcbListEntry ...\n"));
1129  }
1130  }
1131 
1132  while (!IsListEmpty(&FcbList)) {
1133 
1134  ListEntry = RemoveHeadList(&FcbList);
1135 
1136  FcbListEntry = CONTAINING_RECORD(ListEntry, FCB_LIST_ENTRY, Next);
1137 
1138  Fcb = FcbListEntry->Fcb;
1139 
1141  &Fcb->MainResource,
1142  TRUE )) {
1143 
1144  RfsdPurgeFile(Fcb, FlushBeforePurge);
1145 
1146  if (!Fcb->OpenHandleCount && Fcb->ReferenceCount == 1) {
1147  RemoveEntryList(&Fcb->Next);
1148  RfsdFreeFcb(Fcb);
1149  } else {
1151  &Fcb->MainResource,
1153  }
1154  }
1155 
1156  ExFreePool(FcbListEntry);
1157  }
1158 
1159  if (FlushBeforePurge) {
1160  ExAcquireSharedStarveExclusive(&Vcb->PagingIoResource, TRUE);
1161  ExReleaseResourceLite(&Vcb->PagingIoResource);
1162 
1163  CcFlushCache(&Vcb->SectionObject, NULL, 0, NULL);
1164  }
1165 
1166  if (Vcb->SectionObject.ImageSectionObject) {
1167  MmFlushImageSection(&Vcb->SectionObject, MmFlushForWrite);
1168  }
1169 
1170  if (Vcb->SectionObject.DataSectionObject) {
1171  CcPurgeCacheSection(&Vcb->SectionObject, NULL, 0, FALSE);
1172  }
1173 
1174  RfsdPrint((DBG_INFO, "RfsdPurgeVolume: Volume flushed and purged.\n"));
1175 
1176  } _SEH2_FINALLY {
1177  // Nothing
1178  } _SEH2_END;
1179 
1180  return STATUS_SUCCESS;
1181 }
1182 
1184 NTSTATUS
1186  IN BOOLEAN FlushBeforePurge )
1187 {
1189 
1190  PAGED_CODE();
1191 
1192  ASSERT(Fcb != NULL);
1193 
1194  ASSERT((Fcb->Identifier.Type == RFSDFCB) &&
1195  (Fcb->Identifier.Size == sizeof(RFSD_FCB)));
1196 
1197 
1198  if( !IsFlagOn(Fcb->Vcb->Flags, VCB_READ_ONLY) && FlushBeforePurge &&
1199  !IsFlagOn(Fcb->Vcb->Flags, VCB_WRITE_PROTECTED)) {
1200 
1201  RfsdPrint((DBG_INFO, "RfsdPurgeFile: CcFlushCache on %s.\n",
1202  Fcb->AnsiFileName.Buffer));
1203 
1206 
1207  CcFlushCache(&Fcb->SectionObject, NULL, 0, &IoStatus);
1208 
1210  }
1211 
1212  if (Fcb->SectionObject.ImageSectionObject) {
1213 
1214  RfsdPrint((DBG_INFO, "RfsdPurgeFile: MmFlushImageSection on %s.\n",
1215  Fcb->AnsiFileName.Buffer));
1216 
1217  MmFlushImageSection(&Fcb->SectionObject, MmFlushForWrite);
1218  }
1219 
1220  if (Fcb->SectionObject.DataSectionObject) {
1221 
1222  RfsdPrint((DBG_INFO, "RfsdPurgeFile: CcPurgeCacheSection on %s.\n",
1223  Fcb->AnsiFileName.Buffer));
1224 
1225  CcPurgeCacheSection(&Fcb->SectionObject, NULL, 0, FALSE);
1226  }
1227 
1228  return STATUS_SUCCESS;
1229 }
1230 
1232 NTSTATUS
1234 {
1235  NTSTATUS Status;
1236 
1237  PAGED_CODE();
1238 
1239  ASSERT(IrpContext);
1240 
1241  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
1242  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
1243 
1244  switch (IrpContext->MinorFunction) {
1245 
1247  Status = RfsdUserFsRequest(IrpContext);
1248  break;
1249 
1250  case IRP_MN_MOUNT_VOLUME:
1251  Status = RfsdMountVolume(IrpContext);
1252  break;
1253 
1254  case IRP_MN_VERIFY_VOLUME:
1255  Status = RfsdVerifyVolume(IrpContext);
1256  break;
1257 
1258  default:
1259 
1260  RfsdPrint((DBG_ERROR, "RfsdFilsSystemControl: Invalid Device Request.\n"));
1262  RfsdCompleteIrpContext(IrpContext, Status);
1263  }
1264 
1265  return Status;
1266 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
Definition: ext2fs.h:1103
NTSTATUS RfsdDiskIoControl(IN PDEVICE_OBJECT DeviceOjbect, IN ULONG IoctlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer, IN OUT PULONG OutputBufferSize)
Definition: blockio.c:492
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
Definition: fssup.c:384
#define IN
Definition: typedefs.h:38
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define IsMounted(Vcb)
Definition: ext2fs.h:803
#define FSCTL_UNLOCK_VOLUME
Definition: nt_native.h:833
NTSTATUS RfsdCompleteIrpContext(IN PRFSD_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: memory.c:160
#define TRUE
Definition: types.h:120
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1221
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
__drv_mustHoldCriticalRegion NTSTATUS RfsdIsVolumeMounted(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fsctl.c:903
#define __drv_mustHoldCriticalRegion
Definition: ffsdrv.h:34
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:222
_Must_inspect_result_ __drv_aliasesMem PDEVICE_OBJECT _In_ PDEVICE_OBJECT TargetDevice
Definition: iofuncs.h:688
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
NTSTATUS RfsdAllowExtendedDasdIo(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fsctl.c:445
_In_ PIRP Irp
Definition: csq.h:116
#define VCB_MOUNTED
Definition: ext2fs.h:781
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
NTSTATUS RfsdLockVcb(IN PRFSD_VCB Vcb, IN PFILE_OBJECT FileObject)
Definition: fsctl.c:104
VOID RfsdFreeFcb(IN PRFSD_FCB Fcb)
Definition: memory.c:541
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_DISK_CHECK_VERIFY
Definition: cdrw_usr.h:175
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
__drv_mustHoldCriticalRegion NTSTATUS RfsdUserFsRequest(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fsctl.c:478
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1209
#define IOCTL_DISK_IS_WRITABLE
Definition: cdrw_usr.h:172
__drv_mustHoldCriticalRegion NTSTATUS RfsdPurgeFile(IN PRFSD_FCB Fcb, IN BOOLEAN FlushBeforePurge)
Definition: fsctl.c:1185
#define RFSD_POOL_TAG
Definition: rfsd.h:99
NTSTATUS RfsdFlushVolume(IN PRFSD_VCB Vcb, BOOLEAN bShutDown)
Definition: flush.c:97
BOOLEAN NTAPI SeSinglePrivilegeCheck(IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode)
Definition: priv.c:524
NTSTATUS RfsdFlushFiles(IN PRFSD_VCB Vcb, BOOLEAN bShutDown)
Definition: flush.c:51
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define VPB_PERSISTENT
Definition: iotypes.h:1766
LIST_ENTRY VcbList
Definition: rfsd.h:410
#define _GNU_NTIFS_
__drv_mustHoldCriticalRegion NTSTATUS RfsdFileSystemControl(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fsctl.c:1233
#define STATUS_WRONG_VOLUME
Definition: udferr_usr.h:140
#define InsertTailList(ListHead, Entry)
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Out_ PKIRQL Irql
Definition: csq.h:179
BOOLEAN SuperblockContainsMagicKey(PRFSD_SUPER_BLOCK sb)
Definition: rfsd.c:2698
Definition: rfsd.h:323
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define PAGED_CODE()
Definition: video.h:57
PDEVICE_OBJECT DeviceObject
Definition: rfsd.h:407
_SEH2_TRY
Definition: create.c:4250
Definition: rfsd.h:324
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
UCHAR KIRQL
Definition: env_spec_w32.h:591
else
Definition: tritemp.h:161
BOOLEAN RfsdIsMediaWriteProtected(IN PRFSD_IRP_CONTEXT IrpContext, IN PDEVICE_OBJECT TargetDevice)
Definition: fsctl.c:544
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
#define IRP_MN_VERIFY_VOLUME
Definition: iotypes.h:4049
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
#define CCB_ALLOW_EXTENDED_DASD_IO
Definition: ext2fs.h:1028
#define SE_TCB_PRIVILEGE
Definition: security.c:661
#define FSCTL_INVALIDATE_VOLUMES
Definition: nt_native.h:847
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
#define VPB_LOCKED
Definition: iotypes.h:1765
NTSTATUS RfsdInitializeVcb(PRFSD_IRP_CONTEXT IrpContext, PRFSD_VCB Vcb, PRFSD_SUPER_BLOCK RfsdSb, PDEVICE_OBJECT TargetDevice, PDEVICE_OBJECT VolumeDevice, PVPB Vpb)
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
VOID RfsdFreeVcb(IN PRFSD_VCB Vcb)
Definition: memory.c:1581
VOID RfsdSetVpbFlag(IN PVPB Vpb, IN USHORT Flag)
Definition: fsctl.c:48
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1780
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161
Definition: rfsd.h:326
struct _RFSD_VCB RFSD_VCB
VOID RfsdRemoveVcb(PRFSD_VCB Vcb)
Definition: memory.c:1244
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:113
#define FSCTL_DISMOUNT_VOLUME
Definition: nt_native.h:834
struct _RFSD_VCB * PRFSD_VCB
#define IRP_MN_MOUNT_VOLUME
Definition: iotypes.h:4048
ULONG OpenHandleCount
Definition: ntfs.h:533
NTSTATUS NTAPI CcWaitForCurrentLazyWriterActivity(VOID)
Definition: lazyrite.c:30
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
_In_ HANDLE Handle
Definition: extypes.h:390
#define IRP_MN_USER_FS_REQUEST
Definition: iotypes.h:4047
ULONG Flags
Definition: rfsd.h:431
LIST_ENTRY List
Definition: psmgr.c:57
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
PEXT2_FCB Fcb
Definition: ext2fs.h:1104
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
Definition: section.c:4798
PRFSD_SUPER_BLOCK RfsdLoadSuper(IN PRFSD_VCB Vcb, IN BOOLEAN bVerify)
Definition: rfsd.c:80
char CCHAR
Definition: typedefs.h:50
__drv_mustHoldCriticalRegion BOOLEAN RfsdCheckDismount(IN PRFSD_IRP_CONTEXT IrpContext, IN PRFSD_VCB Vcb, IN BOOLEAN bForce)
Definition: fsctl.c:1010
#define Vcb
Definition: cdprocs.h:1425
Definition: xml2sdb.h:79
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
__drv_mustHoldCriticalRegion NTSTATUS RfsdInvalidateVolumes(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fsctl.c:335
LIST_ENTRY Next
Definition: ext2fs.h:1105
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
Definition: user_lib.cpp:531
ERESOURCE Resource
Definition: rfsd.h:388
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
* PFILE_OBJECT
Definition: iotypes.h:1955
#define FSCTL_ALLOW_EXTENDED_DASD_IO
Definition: winioctl.h:124
__drv_mustHoldCriticalRegion NTSTATUS RfsdMountVolume(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fsctl.c:592
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
ULONG Flags
Definition: ntfs.h:532
#define VCB_WRITE_PROTECTED
Definition: ext2fs.h:796
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_In_ PPCI_DEVICE_PRESENCE_PARAMETERS Parameters
Definition: iotypes.h:872
#define VCB_DISMOUNT_PENDING
Definition: ext2fs.h:782
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define RfsdPrint(arg)
Definition: rfsd.h:1069
ULONG Type
Definition: ntfs.h:95
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
#define VOID
Definition: acefi.h:82
#define FCB_FILE_MODIFIED
Definition: ext2fs.h:873
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:593
#define DBG_ERROR
Definition: ffsdrv.h:1031
Definition: typedefs.h:117
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
__drv_mustHoldCriticalRegion NTSTATUS RfsdPurgeVolume(IN PRFSD_VCB Vcb, IN BOOLEAN FlushBeforePurge)
Definition: fsctl.c:1085
POBJECT_TYPE IoFileObjectType
Definition: iomgr.c:36
ERESOURCE MainResource
Definition: ntfs.h:524
ULONG AlignmentRequirement
Definition: env_spec_w32.h:420
#define VCB_READ_ONLY
Definition: ext2fs.h:795
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
__drv_mustHoldCriticalRegion NTSTATUS RfsdVerifyVolume(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fsctl.c:766
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
BOOLEAN NTAPI ExAcquireSharedStarveExclusive(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:1063
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
struct _DISK_GEOMETRY DISK_GEOMETRY
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
_SEH2_END
Definition: create.c:4424
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
__drv_mustHoldCriticalRegion NTSTATUS RfsdDismountVolume(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fsctl.c:917
unsigned short USHORT
Definition: pedump.c:61
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
UINT16 s_blocksize
Definition: reiserfs.h:42
static PDEVICE_OBJECT MainDeviceObject
__drv_mustHoldCriticalRegion NTSTATUS RfsdUnlockVolume(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fsctl.c:268
_SEH2_FINALLY
Definition: create.c:4395
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define FSCTL_IS_VOLUME_MOUNTED
Definition: nt_native.h:836
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG FsControlCode
Definition: fltkernel.h:1369
#define VCB_VOLUME_LOCKED
Definition: ext2fs.h:780
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
Definition: iotypes.h:166
#define STATUS_VOLUME_DISMOUNTED
Definition: ntstatus.h:733
#define STATUS_NOT_LOCKED
Definition: ntstatus.h:265
#define FSCTL_LOCK_VOLUME
Definition: nt_native.h:832
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
ERESOURCE PagingIoResource
Definition: ntfs.h:523
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
BOOLEAN RfsdIsHandleCountZero(IN PRFSD_VCB Vcb)
Definition: fsctl.c:76
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 RFSD_UNLOAD_PENDING
Definition: rfsd.h:447
VOID RfsdClearVpbFlag(IN PVPB Vpb, IN USHORT Flag)
Definition: fsctl.c:62
PRFSD_GLOBAL RfsdGlobal
Definition: init.c:17
IO_STACK_LOCATION * PEXTENDED_IO_STACK_LOCATION
Definition: ext2fs.h:174
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
_In_ PFCB Fcb
Definition: cdprocs.h:151
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
Definition: fatprocs.h:1664
return STATUS_SUCCESS
Definition: btrfs.c:2966
VOID RfsdInsertVcb(PRFSD_VCB Vcb)
Definition: memory.c:1238
#define VPB_MOUNTED
Definition: iotypes.h:1764
#define KdPrint(x)
Definition: env_spec_w32.h:288
FILE_NAME_NODE ShortName
Definition: fatstruc.h:1114
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1220
ULONG Size
Definition: ntfs.h:96
IN OUT PVCB IN PDEVICE_OBJECT IN PVPB Vpb
Definition: fatprocs.h:1664
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
__drv_mustHoldCriticalRegion NTSTATUS RfsdLockVolume(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: fsctl.c:156
NTSTATUS RfsdUnlockVcb(IN PRFSD_VCB Vcb, IN PFILE_OBJECT FileObject)
Definition: fsctl.c:225