NTSTATUS NTAPI FatLockControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) { PFAT_IRP_CONTEXT IrpContext; NTSTATUS Status; BOOLEAN TopLevel; DPRINT1("FatLockControl()\n"); /* Enter FsRtl critical region */ FsRtlEnterFileSystem(); /* Set Top Level IRP if not set */ TopLevel = FatIsTopLevelIrp(Irp); /* Build an irp context */ IrpContext = FatBuildIrpContext(Irp, IoIsOperationSynchronous(Irp)); /* Call internal function */ Status = FatiLockControl(IrpContext, Irp); /* Reset Top Level IRP */ if (TopLevel) IoSetTopLevelIrp(NULL); /* Leave FsRtl critical region */ FsRtlExitFileSystem(); return Status; }
NTSTATUS NTAPI FatFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) { NTSTATUS Status = STATUS_SUCCESS; PFAT_IRP_CONTEXT IrpContext; BOOLEAN CanWait = TRUE; DPRINT("FatFileSystemControl(DeviceObject %p, Irp %p)\n", DeviceObject, Irp); /* Get CanWait flag */ if (IoGetCurrentIrpStackLocation(Irp)->FileObject) { CanWait = IoIsOperationSynchronous(Irp); } /* Enter FsRtl critical region */ FsRtlEnterFileSystem(); /* Build an irp context */ IrpContext = FatBuildIrpContext(Irp, CanWait); /* Call internal function */ Status = FatiFileSystemControl(IrpContext, Irp); /* Leave FsRtl critical region */ FsRtlExitFileSystem(); return Status; }
NTSTATUS NTAPI FatCleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp) { PFAT_IRP_CONTEXT IrpContext; NTSTATUS Status; DPRINT("FatCleanup(DeviceObject %p, Irp %p)\n", DeviceObject, Irp); /* FatCleanup works only with a volume device object */ if (DeviceObject == FatGlobalData.DiskDeviceObject) { /* Complete the request and return success */ Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = FILE_OPENED; IoCompleteRequest(Irp, IO_DISK_INCREMENT); return STATUS_SUCCESS; } /* Enter FsRtl critical region */ FsRtlEnterFileSystem(); /* Build an irp context */ IrpContext = FatBuildIrpContext(Irp, TRUE); /* Call internal function */ Status = FatiCleanup(IrpContext, Irp); /* Leave FsRtl critical region */ FsRtlExitFileSystem(); return Status; }
NTSTATUS NTAPI FatRead(PDEVICE_OBJECT DeviceObject, PIRP Irp) { NTSTATUS Status; BOOLEAN TopLevel, CanWait; PFAT_IRP_CONTEXT IrpContext; CanWait = TRUE; TopLevel = FALSE; Status = STATUS_INVALID_DEVICE_REQUEST; /* Get CanWait flag */ if (IoGetCurrentIrpStackLocation(Irp)->FileObject != NULL) CanWait = IoIsOperationSynchronous(Irp); /* Enter FsRtl critical region */ FsRtlEnterFileSystem(); if (DeviceObject != FatGlobalData.DiskDeviceObject) { /* Set Top Level IRP if not set */ TopLevel = FatIsTopLevelIrp(Irp); /* Build an irp context */ IrpContext = FatBuildIrpContext(Irp, CanWait); /* Perform the actual read */ Status = FatiRead(IrpContext); /* Restore top level Irp */ if (TopLevel) IoSetTopLevelIrp(NULL); } /* Leave FsRtl critical region */ FsRtlExitFileSystem(); return Status; }