[BTRFS]
[reactos.git] / reactos / drivers / filesystems / btrfs / fastio.c
1 /* Copyright (c) Mark Harmstone 2016
2 *
3 * This file is part of WinBtrfs.
4 *
5 * WinBtrfs is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public Licence as published by
7 * the Free Software Foundation, either version 3 of the Licence, or
8 * (at your option) any later version.
9 *
10 * WinBtrfs is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public Licence for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public Licence
16 * along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */
17
18 #include <ntifs.h>
19 #include "btrfs_drv.h"
20
21 FAST_IO_DISPATCH FastIoDispatch;
22
23 static void STDCALL acquire_file_for_create_section(PFILE_OBJECT FileObject) {
24 TRACE("STUB: acquire_file_for_create_section\n");
25 }
26
27 static void STDCALL release_file_for_create_section(PFILE_OBJECT FileObject) {
28 TRACE("STUB: release_file_for_create_section\n");
29 }
30
31 static BOOLEAN STDCALL fast_query_basic_info(PFILE_OBJECT FileObject, BOOLEAN wait, PFILE_BASIC_INFORMATION buf,
32 PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject) {
33
34 TRACE("STUB: fast_query_basic_info\n");
35
36 return FALSE;
37 }
38
39 static BOOLEAN STDCALL fast_query_standard_info(PFILE_OBJECT FileObject, BOOLEAN wait, PFILE_STANDARD_INFORMATION buf,
40 PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject) {
41
42 TRACE("STUB: fast_query_standard_info\n");
43
44 return FALSE;
45 }
46
47 static BOOLEAN STDCALL fast_io_query_open(PIRP Irp, PFILE_NETWORK_OPEN_INFORMATION NetworkInformation, PDEVICE_OBJECT DeviceObject) {
48 TRACE("STUB: fast_io_query_open\n");
49
50 return FALSE;
51 }
52
53 static BOOLEAN STDCALL fast_io_check_if_possible(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait,
54 ULONG LockKey, BOOLEAN CheckForReadOperation, PIO_STATUS_BLOCK IoStatus,
55 PDEVICE_OBJECT DeviceObject) {
56 fcb* fcb = FileObject->FsContext;
57 LARGE_INTEGER len2;
58
59 TRACE("(%p, %llx, %x, %x, %x, %x, %p, %p)\n", FileObject, FileOffset->QuadPart, Length, Wait, LockKey, CheckForReadOperation, IoStatus, DeviceObject);
60
61 len2.QuadPart = Length;
62
63 if (CheckForReadOperation) {
64 if (FsRtlFastCheckLockForRead(&fcb->lock, FileOffset, &len2, LockKey, FileObject, PsGetCurrentProcess()))
65 return TRUE;
66 } else {
67 if (!fcb->Vcb->readonly && !(fcb->subvol->root_item.flags & BTRFS_SUBVOL_READONLY) && FsRtlFastCheckLockForWrite(&fcb->lock, FileOffset, &len2, LockKey, FileObject, PsGetCurrentProcess()))
68 return TRUE;
69 }
70
71 return FALSE;
72 }
73
74 static BOOLEAN STDCALL fast_io_lock(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, PLARGE_INTEGER Length, PEPROCESS ProcessId, ULONG Key, BOOLEAN FailImmediately, BOOLEAN ExclusiveLock, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject){
75 TRACE("STUB: fast_io_lock\n");
76 return FALSE;
77 }
78
79 static BOOLEAN STDCALL fast_io_unlock_single(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, PLARGE_INTEGER Length, PEPROCESS ProcessId, ULONG Key, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject){
80 TRACE("STUB: fast_io_unlock_single\n");
81 return FALSE;
82 }
83
84 static BOOLEAN STDCALL fast_io_unlock_all(PFILE_OBJECT FileObject, PEPROCESS ProcessId, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject){
85 TRACE("STUB: fast_io_unlock_all\n");
86 return FALSE;
87 }
88
89 static BOOLEAN STDCALL fast_io_unlock_all_by_key(PFILE_OBJECT FileObject, PVOID ProcessId, ULONG Key, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject){
90 TRACE("STUB: fast_io_unlock_all_by_key\n");
91 return FALSE;
92 }
93
94 static BOOLEAN STDCALL fast_io_device_control(PFILE_OBJECT FileObject, BOOLEAN Wait, PVOID InputBuffer OPTIONAL, ULONG InputBufferLength, PVOID OutputBuffer OPTIONAL, ULONG OutputBufferLength, ULONG IoControlCode, PIO_STATUS_BLOCK IoStatus, PDEVICE_OBJECT DeviceObject){
95 TRACE("STUB: fast_io_device_control\n");
96 return FALSE;
97 }
98
99 static VOID STDCALL fast_io_detach_device(PDEVICE_OBJECT SourceDevice, PDEVICE_OBJECT TargetDevice){
100 TRACE("STUB: fast_io_detach_device\n");
101 }
102
103 static BOOLEAN STDCALL fast_io_query_network_open_info(PFILE_OBJECT FileObject, BOOLEAN Wait, struct _FILE_NETWORK_OPEN_INFORMATION *Buffer, struct _IO_STATUS_BLOCK *IoStatus, PDEVICE_OBJECT DeviceObject){
104 TRACE("STUB: fast_io_query_network_open_info\n");
105 return FALSE;
106 }
107
108 static NTSTATUS STDCALL fast_io_acquire_for_mod_write(PFILE_OBJECT FileObject, PLARGE_INTEGER EndingOffset, struct _ERESOURCE **ResourceToRelease, PDEVICE_OBJECT DeviceObject){
109 TRACE("STUB: fast_io_acquire_for_mod_write\n");
110 return STATUS_NOT_IMPLEMENTED;
111 }
112
113 static BOOLEAN STDCALL fast_io_read_compressed(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, ULONG LockKey, PVOID Buffer, PMDL *MdlChain, PIO_STATUS_BLOCK IoStatus, struct _COMPRESSED_DATA_INFO *CompressedDataInfo, ULONG CompressedDataInfoLength, PDEVICE_OBJECT DeviceObject){
114 TRACE("STUB: fast_io_read_compressed\n");
115 return FALSE;
116 }
117
118 static BOOLEAN STDCALL fast_io_write_compressed(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, ULONG LockKey, PVOID Buffer, PMDL *MdlChain, PIO_STATUS_BLOCK IoStatus, struct _COMPRESSED_DATA_INFO *CompressedDataInfo, ULONG CompressedDataInfoLength, PDEVICE_OBJECT DeviceObject){
119 TRACE("STUB: fast_io_write_compressed\n");
120 return FALSE;
121 }
122
123 static BOOLEAN STDCALL fast_io_mdl_read_complete_compressed(PFILE_OBJECT FileObject, PMDL MdlChain, PDEVICE_OBJECT DeviceObject){
124 TRACE("STUB: fast_io_mdl_read_complete_compressed\n");
125 return FALSE;
126 }
127
128 static BOOLEAN STDCALL fast_io_mdl_write_complete_compressed(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, PMDL MdlChain, PDEVICE_OBJECT DeviceObject){
129 TRACE("STUB: fast_io_mdl_write_complete_compressed\n");
130 return FALSE;
131 }
132
133 static NTSTATUS STDCALL fast_io_release_for_mod_write(PFILE_OBJECT FileObject, struct _ERESOURCE *ResourceToRelease, PDEVICE_OBJECT DeviceObject){
134 TRACE("STUB: fast_io_release_for_mod_write\n");
135 return STATUS_NOT_IMPLEMENTED;
136 }
137
138 static NTSTATUS STDCALL fast_io_acquire_for_ccflush(PFILE_OBJECT FileObject, PDEVICE_OBJECT DeviceObject){
139 TRACE("STUB: fast_io_acquire_for_ccflush\n");
140 return STATUS_NOT_IMPLEMENTED;
141 }
142
143 static NTSTATUS STDCALL fast_io_release_for_ccflush(PFILE_OBJECT FileObject, PDEVICE_OBJECT DeviceObject){
144 TRACE("STUB: fast_io_release_for_ccflush\n");
145 return STATUS_NOT_IMPLEMENTED;
146 }
147
148 void __stdcall init_fast_io_dispatch(FAST_IO_DISPATCH** fiod) {
149 RtlZeroMemory(&FastIoDispatch, sizeof(FastIoDispatch));
150
151 FastIoDispatch.SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH);
152
153 FastIoDispatch.FastIoCheckIfPossible = fast_io_check_if_possible;
154 FastIoDispatch.FastIoRead = FsRtlCopyRead;
155 FastIoDispatch.FastIoWrite = FsRtlCopyWrite;
156 FastIoDispatch.FastIoQueryBasicInfo = fast_query_basic_info;
157 FastIoDispatch.FastIoQueryStandardInfo = fast_query_standard_info;
158 FastIoDispatch.FastIoLock = fast_io_lock;
159 FastIoDispatch.FastIoUnlockSingle = fast_io_unlock_single;
160 FastIoDispatch.FastIoUnlockAll = fast_io_unlock_all;
161 FastIoDispatch.FastIoUnlockAllByKey = fast_io_unlock_all_by_key;
162 FastIoDispatch.FastIoDeviceControl = fast_io_device_control;
163 FastIoDispatch.AcquireFileForNtCreateSection = acquire_file_for_create_section;
164 FastIoDispatch.ReleaseFileForNtCreateSection = release_file_for_create_section;
165 FastIoDispatch.FastIoDetachDevice = fast_io_detach_device;
166 FastIoDispatch.FastIoQueryNetworkOpenInfo = fast_io_query_network_open_info;
167 FastIoDispatch.AcquireForModWrite = fast_io_acquire_for_mod_write;
168 FastIoDispatch.MdlRead = FsRtlMdlReadDev;
169 FastIoDispatch.MdlReadComplete = FsRtlMdlReadCompleteDev;
170 FastIoDispatch.PrepareMdlWrite = FsRtlPrepareMdlWriteDev;
171 FastIoDispatch.MdlWriteComplete = FsRtlMdlWriteCompleteDev;
172 FastIoDispatch.FastIoReadCompressed = fast_io_read_compressed;
173 FastIoDispatch.FastIoWriteCompressed = fast_io_write_compressed;
174 FastIoDispatch.MdlReadCompleteCompressed = fast_io_mdl_read_complete_compressed;
175 FastIoDispatch.MdlWriteCompleteCompressed = fast_io_mdl_write_complete_compressed;
176 FastIoDispatch.FastIoQueryOpen = fast_io_query_open;
177 FastIoDispatch.ReleaseForModWrite = fast_io_release_for_mod_write;
178 FastIoDispatch.AcquireForCcFlush = fast_io_acquire_for_ccflush;
179 FastIoDispatch.ReleaseForCcFlush = fast_io_release_for_ccflush;
180
181 *fiod = &FastIoDispatch;
182 }