[HEADERS] Use the new header with SPDX license identifier for host headers I've contr...
[reactos.git] / reactos / drivers / filesystems / fastfat_new / device.c
1 /*
2 * PROJECT: ReactOS FAT file system driver
3 * LICENSE: GNU GPLv3 as published by the Free Software Foundation
4 * FILE: drivers/filesystems/fastfat/device.c
5 * PURPOSE: Device control
6 * PROGRAMMERS: Aleksey Bragin (aleksey@reactos.org)
7 */
8
9 /* INCLUDES *****************************************************************/
10
11 #define NDEBUG
12 #include "fastfat.h"
13
14 /* FUNCTIONS ****************************************************************/
15
16 NTSTATUS
17 NTAPI
18 FatDeviceControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
19 {
20 DPRINT1("FatDeviceControl()\n");
21 return STATUS_NOT_IMPLEMENTED;
22 }
23
24 NTSTATUS
25 FatPerformDevIoCtrl(PDEVICE_OBJECT DeviceObject,
26 ULONG ControlCode,
27 PVOID InputBuffer,
28 ULONG InputBufferSize,
29 PVOID OutputBuffer,
30 ULONG OutputBufferSize,
31 BOOLEAN Override)
32 {
33 PIRP Irp;
34 KEVENT Event;
35 NTSTATUS Status;
36 PIO_STACK_LOCATION Stack;
37 IO_STATUS_BLOCK IoStatus;
38
39 /* Initialize the event for waiting */
40 KeInitializeEvent(&Event, NotificationEvent, FALSE);
41
42 /* Build the device I/O control request */
43 Irp = IoBuildDeviceIoControlRequest(ControlCode,
44 DeviceObject,
45 InputBuffer,
46 InputBufferSize,
47 OutputBuffer,
48 OutputBufferSize,
49 FALSE,
50 &Event,
51 &IoStatus);
52
53 /* Fail if IRP hasn't been allocated */
54 if (!Irp) return STATUS_INSUFFICIENT_RESOURCES;
55
56 /* Set verify override flag if requested */
57 if (Override)
58 {
59 Stack = IoGetNextIrpStackLocation(Irp);
60 Stack->Flags |= SL_OVERRIDE_VERIFY_VOLUME;
61 }
62
63 /* Call the driver */
64 Status = IoCallDriver(DeviceObject, Irp);
65
66 /* Wait if needed */
67 if (Status == STATUS_PENDING)
68 {
69 KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
70 Status = IoStatus.Status;
71 }
72
73 return Status;
74 }
75
76 /* EOF */