ReactOS  0.4.13-dev-242-g611e6d7
blockio.c File Reference
#include "rfsd.h"
Include dependency graph for blockio.c:

Go to the source code of this file.

Classes

struct  _RFSD_RW_CONTEXT
 

Typedefs

typedef struct _RFSD_RW_CONTEXT RFSD_RW_CONTEXT
 
typedef struct _RFSD_RW_CONTEXTPRFSD_RW_CONTEXT
 

Functions

NTSTATUS NTAPI RfsdReadWriteBlockSyncCompletionRoutine (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
NTSTATUS NTAPI RfsdReadWriteBlockAsyncCompletionRoutine (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
NTSTATUS NTAPI RfsdMediaEjectControlCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Contxt)
 
NTSTATUS RfsdLockUserBuffer (IN PIRP Irp, IN ULONG Length, IN LOCK_OPERATION Operation)
 
PVOID RfsdGetUserBuffer (IN PIRP Irp)
 
NTSTATUS RfsdReadWriteBlocks (IN PRFSD_IRP_CONTEXT IrpContext, IN PRFSD_VCB Vcb, IN PRFSD_BDL RfsdBDL, IN ULONG Length, IN ULONG Count, IN BOOLEAN bVerify)
 
NTSTATUS RfsdReadSync (IN PRFSD_VCB Vcb, IN ULONGLONG Offset, IN ULONG Length, OUT PVOID Buffer, BOOLEAN bVerify)
 
NTSTATUS RfsdReadDisk (IN PRFSD_VCB Vcb, IN ULONGLONG Offset, IN ULONG Size, IN OUT PVOID Buffer, IN BOOLEAN bVerify)
 
NTSTATUS RfsdDiskIoControl (IN PDEVICE_OBJECT DeviceObject, IN ULONG IoctlCode, IN PVOID InputBuffer, IN ULONG InputBufferSize, IN OUT PVOID OutputBuffer, IN OUT PULONG OutputBufferSize)
 
__drv_mustHoldCriticalRegion VOID RfsdMediaEjectControl (IN PRFSD_IRP_CONTEXT IrpContext, IN PRFSD_VCB Vcb, IN BOOLEAN bPrevent)
 
NTSTATUS RfsdDiskShutDown (PRFSD_VCB Vcb)
 

Variables

PRFSD_GLOBAL RfsdGlobal
 

Typedef Documentation

◆ PRFSD_RW_CONTEXT

◆ RFSD_RW_CONTEXT

Function Documentation

◆ RfsdDiskIoControl()

NTSTATUS RfsdDiskIoControl ( IN PDEVICE_OBJECT  DeviceObject,
IN ULONG  IoctlCode,
IN PVOID  InputBuffer,
IN ULONG  InputBufferSize,
IN OUT PVOID  OutputBuffer,
IN OUT PULONG  OutputBufferSize 
)

Definition at line 492 of file blockio.c.

499 {
500  ULONG OutBufferSize = 0;
501  KEVENT Event;
502  PIRP Irp;
505 
506  PAGED_CODE();
507 
509 
510  if (OutputBufferSize)
511  {
512  OutBufferSize = *OutputBufferSize;
513  }
514 
516 
518  IoctlCode,
519  DeviceObject,
520  InputBuffer,
521  InputBufferSize,
522  OutputBuffer,
524  FALSE,
525  &Event,
526  &IoStatus
527  );
528 
529  if (Irp == NULL) {
530  RfsdPrint((DBG_ERROR, "RfsdDiskIoControl: Building IRQ error!\n"));
532  }
533 
535 
536  if (Status == STATUS_PENDING) {
538  Status = IoStatus.Status;
539  }
540 
541  if (OutputBufferSize) {
542  *OutputBufferSize = (ULONG) IoStatus.Information;
543  }
544 
545  return Status;
546 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
_In_ PIRP _In_ ULONG _In_ ULONG _In_ ULONG _In_ ULONG OutBufferSize
Definition: classpnp.h:429
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
#define PAGED_CODE()
Definition: video.h:57
CHAR InputBuffer[80]
Definition: conmgr.c:33
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
smooth NULL
Definition: ftsmooth.c:416
_Must_inspect_result_ __drv_aliasesMem _In_ PDEVICE_OBJECT _In_opt_ PVOID _In_ ULONG _Out_opt_ PVOID OutputBuffer
Definition: iofuncs.h:713
#define STATUS_PENDING
Definition: ntstatus.h:82
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define RfsdPrint(arg)
Definition: rfsd.h:1069
#define DBG_ERROR
Definition: ffsdrv.h:1031
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
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
unsigned int ULONG
Definition: retypes.h:1

Referenced by RfsdInitializeVcb(), RfsdMountVolume(), and RfsdVerifyVolume().

◆ RfsdDiskShutDown()

NTSTATUS RfsdDiskShutDown ( PRFSD_VCB  Vcb)

Definition at line 631 of file blockio.c.

632 {
633  PIRP Irp;
634  KEVENT Event;
637 
638  PAGED_CODE();
639 
641 
643  Vcb->TargetDeviceObject,
644  NULL,
645  0,
646  NULL,
647  &Event,
648  &IoStatus);
649 
650  if (Irp) {
651  Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
652 
653  if (Status == STATUS_PENDING) {
655  Executive,
656  KernelMode,
657  FALSE,
658  NULL);
659 
660  Status = IoStatus.Status;
661  }
662  } else {
663  Status = IoStatus.Status;
664  }
665 
666  return Status;
667 }
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
#define IRP_MJ_SHUTDOWN
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
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
#define PAGED_CODE()
Definition: video.h:57
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
Status
Definition: gdiplustypes.h:24
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218

Referenced by RfsdShutDown().

◆ RfsdGetUserBuffer()

PVOID RfsdGetUserBuffer ( IN PIRP  Irp)

Definition at line 109 of file blockio.c.

110 {
111  PAGED_CODE();
112 
113  ASSERT(Irp != NULL);
114 
115  if (Irp->MdlAddress) {
116 
117 #if (_WIN32_WINNT >= 0x0500)
119 #else
120  return MmGetSystemAddressForMdl(Irp->MdlAddress);
121 #endif
122  } else {
123 
124  return Irp->UserBuffer;
125  }
126 }
_In_ PIRP Irp
Definition: csq.h:116
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define MmGetSystemAddressForMdl(Mdl)

Referenced by RfsdQueryDirectory(), RfsdReadFile(), RfsdReadVolume(), RfsdWriteFile(), and RfsdWriteVolume().

◆ RfsdLockUserBuffer()

NTSTATUS RfsdLockUserBuffer ( IN PIRP  Irp,
IN ULONG  Length,
IN LOCK_OPERATION  Operation 
)

Definition at line 67 of file blockio.c.

70 {
72 
73  PAGED_CODE();
74 
75  ASSERT(Irp != NULL);
76 
77  if (Irp->MdlAddress != NULL) {
78 
79  return STATUS_SUCCESS;
80  }
81 
82  IoAllocateMdl(Irp->UserBuffer, Length, FALSE, FALSE, Irp);
83 
84  if (Irp->MdlAddress == NULL) {
85 
87  }
88 
89  _SEH2_TRY {
90 
91  MmProbeAndLockPages(Irp->MdlAddress, Irp->RequestorMode, Operation);
92 
95 
96  IoFreeMdl(Irp->MdlAddress);
97 
98  Irp->MdlAddress = NULL;
99 
100  DbgBreak();
101 
103  } _SEH2_END;
104 
105  return Status;
106 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define STATUS_INVALID_USER_BUFFER
Definition: udferr_usr.h:166
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
_SEH2_END
Definition: create.c:4424
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
#define DbgBreak()
Definition: ext2fs.h:46
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
return STATUS_SUCCESS
Definition: btrfs.c:2745

Referenced by RfsdQueryDirectory(), RfsdReadFile(), RfsdReadVolume(), RfsdWriteFile(), and RfsdWriteVolume().

◆ RfsdMediaEjectControl()

__drv_mustHoldCriticalRegion VOID RfsdMediaEjectControl ( IN PRFSD_IRP_CONTEXT  IrpContext,
IN PRFSD_VCB  Vcb,
IN BOOLEAN  bPrevent 
)

Definition at line 566 of file blockio.c.

571 {
572  PIRP Irp;
573  KEVENT Event;
575  PREVENT_MEDIA_REMOVAL Prevent;
577 
578  PAGED_CODE();
579 
581  &Vcb->MainResource,
582  TRUE );
583 
584  if (bPrevent != IsFlagOn(Vcb->Flags, VCB_REMOVAL_PREVENTED)) {
585  if (bPrevent) {
587  } else {
589  }
590  }
591 
593  &Vcb->MainResource,
595 
596  Prevent.PreventMediaRemoval = bPrevent;
597 
599 
601  Vcb->TargetDeviceObject,
602  &Prevent,
603  sizeof(PREVENT_MEDIA_REMOVAL),
604  NULL,
605  0,
606  FALSE,
607  NULL,
608  &IoStatus );
609 
610  if (Irp != NULL) {
613  &Event,
614  TRUE,
615  TRUE,
616  TRUE );
617 
618  Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
619 
620  if (Status == STATUS_PENDING) {
622  Executive,
623  KernelMode,
624  FALSE,
625  NULL );
626  }
627  }
628 }
#define ExGetCurrentResourceThread()
Definition: env_spec_w32.h:633
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI RfsdMediaEjectControlCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Contxt)
Definition: blockio.c:549
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
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
#define PAGED_CODE()
Definition: video.h:57
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define IsFlagOn(a, b)
Definition: ext2fs.h:177
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
smooth NULL
Definition: ftsmooth.c:416
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
#define VCB_REMOVAL_PREVENTED
Definition: ext2fs.h:798
BOOLEAN PreventMediaRemoval
Definition: ntddstor.h:251
ClearFlag(Dirent->Flags, DIRENT_FLAG_NOT_PERSISTENT)
Status
Definition: gdiplustypes.h:24
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
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
VOID NTAPI ExReleaseResourceForThreadLite(IN PERESOURCE Resource, IN ERESOURCE_THREAD Thread)
Definition: resource.c:1844
#define IOCTL_DISK_MEDIA_REMOVAL
Definition: cdrw_usr.h:176

◆ RfsdMediaEjectControlCompletion()

NTSTATUS NTAPI RfsdMediaEjectControlCompletion ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Contxt 
)

Definition at line 549 of file blockio.c.

554 {
555  PKEVENT Event = (PKEVENT)Contxt;
556 
557  KeSetEvent( Event, 0, FALSE );
558 
560 
561  return STATUS_SUCCESS;
562 }
struct _KEVENT * PKEVENT
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
return STATUS_SUCCESS
Definition: btrfs.c:2745

Referenced by RfsdMediaEjectControl().

◆ RfsdReadDisk()

NTSTATUS RfsdReadDisk ( IN PRFSD_VCB  Vcb,
IN ULONGLONG  Offset,
IN ULONG  Size,
IN OUT PVOID  Buffer,
IN BOOLEAN  bVerify 
)

Definition at line 439 of file blockio.c.

445 {
447  PUCHAR Buf;
448  ULONG Length;
449  ULONGLONG Lba;
450 
451  PAGED_CODE();
452 
453  // Align the offset and length to the sector boundaries
454  Lba = Offset & (~((ULONGLONG)SECTOR_SIZE - 1));
455  Length = (ULONG)(Size + Offset + SECTOR_SIZE - 1 - Lba) &
456  (~((ULONG)SECTOR_SIZE - 1));
457 
458  // Allocate a temporary buffer to read the sector-aligned data into
460  if (!Buf) {
461  RfsdPrint((DBG_ERROR, "RfsdReadDisk: no enough memory.\n"));
463 
464  goto errorout;
465  }
466 
467  // Read the data
468  Status = RfsdReadSync( Vcb,
469  Lba,
470  Length,
471  Buf,
472  FALSE );
473 
474  if (!NT_SUCCESS(Status)) {
475  RfsdPrint((DBG_ERROR, "RfsdReadDisk: Read Block Device error.\n"));
476 
477  goto errorout;
478  }
479 
480  // Copy the requested data into the user's buffer
481  RtlCopyMemory(Buffer, &Buf[Offset - Lba], Size);
482 
483 errorout:
484 
485  if (Buf)
486  ExFreePool(Buf);
487 
488  return Status;
489 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
#define RFSD_POOL_TAG
Definition: rfsd.h:99
NTSTATUS RfsdReadSync(IN PRFSD_VCB Vcb, IN ULONGLONG Offset, IN ULONG Length, OUT PVOID Buffer, BOOLEAN bVerify)
Definition: blockio.c:365
#define PAGED_CODE()
Definition: video.h:57
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define SECTOR_SIZE
Definition: winldr.h:34
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
uint64_t ULONGLONG
Definition: typedefs.h:65
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define RfsdPrint(arg)
Definition: rfsd.h:1069
#define DBG_ERROR
Definition: ffsdrv.h:1031
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ RfsdReadSync()

NTSTATUS RfsdReadSync ( IN PRFSD_VCB  Vcb,
IN ULONGLONG  Offset,
IN ULONG  Length,
OUT PVOID  Buffer,
BOOLEAN  bVerify 
)

Definition at line 365 of file blockio.c.

372 {
373  PKEVENT Event = NULL;
374  PIRP Irp;
377 
378  PAGED_CODE();
379 
380  ASSERT(Vcb != NULL);
381  ASSERT(Vcb->TargetDeviceObject != NULL);
382  ASSERT(Buffer != NULL);
383 
384  _SEH2_TRY {
385 
387 
388  if (NULL == Event) {
389  _SEH2_LEAVE;
390  }
391 
393 
395  IRP_MJ_READ,
396  Vcb->TargetDeviceObject,
397  Buffer,
398  Length,
400  Event,
401  &IoStatus
402  );
403 
404  if (!Irp) {
406  _SEH2_LEAVE;
407  }
408 
409  if (bVerify) {
412  }
413 
414  Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
415 
416  if (Status == STATUS_PENDING) {
418  Event,
419  Suspended,
420  KernelMode,
421  FALSE,
422  NULL
423  );
424 
425  Status = IoStatus.Status;
426  }
427 
428  } _SEH2_FINALLY {
429 
430  if (Event) {
431  ExFreePool(Event);
432  }
433  } _SEH2_END;
434 
435  return Status;
436 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
PIRP NTAPI IoBuildSynchronousFsdRequest(IN ULONG MajorFunction, IN PDEVICE_OBJECT DeviceObject, IN PVOID Buffer, IN ULONG Length, IN PLARGE_INTEGER StartingOffset, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:1069
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define RFSD_POOL_TAG
Definition: rfsd.h:99
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
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
smooth NULL
Definition: ftsmooth.c:416
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1779
Definition: bufpool.h:45
static BOOL bVerify
Definition: verify.c:27
#define STATUS_PENDING
Definition: ntstatus.h:82
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
_SEH2_FINALLY
Definition: create.c:4395
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define _SEH2_LEAVE
Definition: filesup.c:20
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by RfsdReadDisk().

◆ RfsdReadWriteBlockAsyncCompletionRoutine()

NTSTATUS NTAPI RfsdReadWriteBlockAsyncCompletionRoutine ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Context 
)

Definition at line 163 of file blockio.c.

168 {
170 
171  if (!NT_SUCCESS( Irp->IoStatus.Status )) {
172  DbgBreak(); // [mark]
173  pContext->MasterIrp->IoStatus = Irp->IoStatus;
174  }
175 
176  if (InterlockedDecrement(&pContext->Blocks) == 0) {
177 
178  pContext->MasterIrp->IoStatus.Information = 0;
179 
180  if (NT_SUCCESS(pContext->MasterIrp->IoStatus.Status)) {
181 
182  pContext->MasterIrp->IoStatus.Information =
183  pContext->Length;
184  }
185 
186  IoMarkIrpPending( pContext->MasterIrp );
187 
188  ExFreePool(pContext);
189  }
190 
192 
193  return STATUS_SUCCESS;
194 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
PIRP MasterIrp
Definition: blockio.c:22
ULONG Blocks
Definition: blockio.c:25
struct _RFSD_RW_CONTEXT * PRFSD_RW_CONTEXT
ULONG Length
Definition: blockio.c:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define InterlockedDecrement
Definition: armddk.h:52
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define DbgBreak()
Definition: ext2fs.h:46
return STATUS_SUCCESS
Definition: btrfs.c:2745
IoMarkIrpPending(Irp)
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by RfsdReadWriteBlocks().

◆ RfsdReadWriteBlocks()

NTSTATUS RfsdReadWriteBlocks ( IN PRFSD_IRP_CONTEXT  IrpContext,
IN PRFSD_VCB  Vcb,
IN PRFSD_BDL  RfsdBDL,
IN ULONG  Length,
IN ULONG  Count,
IN BOOLEAN  bVerify 
)

Definition at line 200 of file blockio.c.

207 {
208  PMDL Mdl;
209  PIRP Irp;
210  PIRP MasterIrp = IrpContext->Irp;
213  PRFSD_RW_CONTEXT pContext = NULL;
214  ULONG i;
215  BOOLEAN bBugCheck = FALSE;
216 
217  PAGED_CODE();
218 
219  ASSERT(MasterIrp);
220 
221  _SEH2_TRY {
222 
224 
225  if (!pContext) {
227  _SEH2_LEAVE;
228  }
229 
230  RtlZeroMemory(pContext, sizeof(RFSD_RW_CONTEXT));
231 
232  pContext->Wait = IrpContext->IsSynchronous;
233  pContext->MasterIrp = MasterIrp;
234  pContext->Blocks = Count;
235  pContext->Length = 0;
236 
237  if (pContext->Wait) {
239  }
240 
241  for (i = 0; i < Count; i++) {
242 
244  MasterIrp,
245  (CCHAR)(Vcb->TargetDeviceObject->StackSize + 1) );
246 
247  if (!Irp) {
249 #ifdef __REACTOS__
250  ExFreePool(pContext);
251  pContext = NULL;
252 #endif
253  _SEH2_LEAVE;
254  }
255 
256  Mdl = IoAllocateMdl( (PCHAR)MasterIrp->UserBuffer +
257  RfsdBDL[i].Offset,
258  RfsdBDL[i].Length,
259  FALSE,
260  FALSE,
261  Irp );
262 
263  if (!Mdl) {
265 #ifdef __REACTOS__
266  ExFreePool(pContext);
267  pContext = NULL;
268 #endif
269  _SEH2_LEAVE;
270  }
271 
272  IoBuildPartialMdl( MasterIrp->MdlAddress,
273  Mdl,
274  (PCHAR)MasterIrp->UserBuffer + RfsdBDL[i].Offset,
275  RfsdBDL[i].Length );
276 
279 
280 
281  IrpSp->MajorFunction = IrpContext->MajorFunction;
282  IrpSp->Parameters.Read.Length = RfsdBDL[i].Length;
283  IrpSp->Parameters.Read.ByteOffset.QuadPart = RfsdBDL[i].Lba;
284 
286  Irp,
287  ((IrpContext->IsSynchronous) ?
290  (PVOID) pContext,
291  TRUE,
292  TRUE,
293  TRUE );
294 
296 
297  IrpSp->MajorFunction = IrpContext->MajorFunction;
298  IrpSp->Parameters.Read.Length = RfsdBDL[i].Length;
299  IrpSp->Parameters.Read.ByteOffset.QuadPart = RfsdBDL[i].Lba;
300 
301  if (bVerify) {
303  }
304 
305  RfsdBDL[i].Irp = Irp;
306  }
307 
308  MasterIrp->AssociatedIrp.IrpCount = Count;
309 
310  if (IrpContext->IsSynchronous) {
311  MasterIrp->AssociatedIrp.IrpCount += 1;
312  }
313 
314  pContext->Length = Length;
315 
316  bBugCheck = TRUE;
317 
318  for (i = 0; i < Count; i++) {
319  Status = IoCallDriver ( Vcb->TargetDeviceObject,
320  RfsdBDL[i].Irp);
321  }
322 
323  if (IrpContext->IsSynchronous) {
324  KeWaitForSingleObject( &(pContext->Event),
326 
327  KeClearEvent( &(pContext->Event) );
328  }
329 
330  } _SEH2_FINALLY {
331 
332  if (IrpContext->IsSynchronous) {
333  if (MasterIrp)
334  Status = MasterIrp->IoStatus.Status;
335 
336  if (pContext)
337  ExFreePool(pContext);
338 
339  } else {
340  IrpContext->Irp = NULL;
342  }
343 
345  if (bBugCheck) {
347  }
348 
349  for (i = 0; i < Count; i++) {
350  if (RfsdBDL[i].Irp != NULL ) {
351  if ( RfsdBDL[i].Irp->MdlAddress != NULL ) {
352  IoFreeMdl( RfsdBDL[i].Irp->MdlAddress );
353  }
354 
355  IoFreeIrp( RfsdBDL[i].Irp );
356  }
357  }
358  }
359  } _SEH2_END;
360 
361  return Status;
362 }
signed char * PCHAR
Definition: retypes.h:7
#define RFSD_BUGCHK_BLOCK
Definition: rfsd.h:206
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PIRP Irp
Definition: csq.h:116
PIRP MasterIrp
Definition: blockio.c:22
ULONG Blocks
Definition: blockio.c:25
LONG NTSTATUS
Definition: precomp.h:26
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define RFSD_POOL_TAG
Definition: rfsd.h:99
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
NTSTATUS NTAPI RfsdReadWriteBlockAsyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: blockio.c:163
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
VOID NTAPI IoBuildPartialMdl(IN PMDL SourceMdl, IN PMDL TargetMdl, IN PVOID VirtualAddress, IN ULONG Length)
Definition: iomdl.c:96
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:13
#define SL_OVERRIDE_VERIFY_VOLUME
Definition: iotypes.h:1779
PIRP NTAPI IoMakeAssociatedIrp(IN PIRP Irp, IN CCHAR StackSize)
Definition: irp.c:1925
static BOOL bVerify
Definition: verify.c:27
ULONG Length
Definition: blockio.c:26
#define STATUS_PENDING
Definition: ntstatus.h:82
char CCHAR
Definition: typedefs.h:50
#define Vcb
Definition: cdprocs.h:1425
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS NTAPI RfsdReadWriteBlockSyncCompletionRoutine(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: blockio.c:129
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
_SEH2_END
Definition: create.c:4424
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4157
_SEH2_FINALLY
Definition: create.c:4395
#define RfsdBugCheck(A, B, C, D)
Definition: rfsd.h:232
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define _SEH2_LEAVE
Definition: filesup.c:20
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
KEVENT Event
Definition: blockio.c:23
return STATUS_SUCCESS
Definition: btrfs.c:2745
FORCEINLINE VOID IoSetNextIrpStackLocation(_Inout_ PIRP Irp)
Definition: iofuncs.h:2632
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
BOOLEAN Wait
Definition: blockio.c:24

Referenced by RfsdReadVolume(), RfsdWriteInode(), and RfsdWriteVolume().

◆ RfsdReadWriteBlockSyncCompletionRoutine()

NTSTATUS NTAPI RfsdReadWriteBlockSyncCompletionRoutine ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Context 
)

Definition at line 129 of file blockio.c.

133 {
135 
136  if (!NT_SUCCESS( Irp->IoStatus.Status )) {
137  DbgBreak(); // [mark]
138  pContext->MasterIrp->IoStatus = Irp->IoStatus;
139  }
140 
141  IoFreeMdl( Irp->MdlAddress );
142  IoFreeIrp( Irp );
143 
144  if (InterlockedDecrement(&pContext->Blocks) == 0) {
145 
146  pContext->MasterIrp->IoStatus.Information = 0;
147 
148  if (NT_SUCCESS(pContext->MasterIrp->IoStatus.Status)) {
149 
150  pContext->MasterIrp->IoStatus.Information =
151  pContext->Length;
152  }
153 
154  KeSetEvent( &pContext->Event, 0, FALSE );
155  }
156 
158 
160 }
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:63
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
PIRP MasterIrp
Definition: blockio.c:22
ULONG Blocks
Definition: blockio.c:25
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
struct _RFSD_RW_CONTEXT * PRFSD_RW_CONTEXT
ULONG Length
Definition: blockio.c:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
#define InterlockedDecrement
Definition: armddk.h:52
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
#define DbgBreak()
Definition: ext2fs.h:46
KEVENT Event
Definition: blockio.c:23

Referenced by RfsdReadWriteBlocks().

Variable Documentation

◆ RfsdGlobal

PRFSD_GLOBAL RfsdGlobal

Definition at line 17 of file init.c.