Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenblockdev.c
Go to the documentation of this file.
00001 /* 00002 * ReactOS kernel 00003 * Copyright (C) 2002 ReactOS Team 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 00018 * 00019 * COPYRIGHT: See COPYING in the top level directory 00020 * PROJECT: ReactOS kernel 00021 * FILE: drivers/filesystem/ntfs/blockdev.c 00022 * PURPOSE: NTFS filesystem driver 00023 * PROGRAMMER: Eric Kohl 00024 */ 00025 00026 /* INCLUDES *****************************************************************/ 00027 00028 #include "ntfs.h" 00029 00030 #define NDEBUG 00031 #include <debug.h> 00032 00033 /* GLOBALS *****************************************************************/ 00034 00035 00036 /* FUNCTIONS ****************************************************************/ 00037 00038 NTSTATUS 00039 NtfsReadSectors(IN PDEVICE_OBJECT DeviceObject, 00040 IN ULONG DiskSector, 00041 IN ULONG SectorCount, 00042 IN ULONG SectorSize, 00043 IN OUT PUCHAR Buffer, 00044 IN BOOLEAN Override) 00045 { 00046 PIO_STACK_LOCATION Stack; 00047 IO_STATUS_BLOCK IoStatus; 00048 LARGE_INTEGER Offset; 00049 ULONG BlockSize; 00050 KEVENT Event; 00051 PIRP Irp; 00052 NTSTATUS Status; 00053 00054 KeInitializeEvent(&Event, 00055 NotificationEvent, 00056 FALSE); 00057 00058 Offset.QuadPart = (LONGLONG)DiskSector * (LONGLONG)SectorSize; 00059 BlockSize = SectorCount * SectorSize; 00060 00061 DPRINT("NtfsReadSectors(DeviceObject %p, DiskSector %d, Buffer %p)\n", 00062 DeviceObject, DiskSector, Buffer); 00063 DPRINT("Offset %I64x BlockSize %ld\n", 00064 Offset.QuadPart, 00065 BlockSize); 00066 00067 DPRINT("Building synchronous FSD Request...\n"); 00068 Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ, 00069 DeviceObject, 00070 Buffer, 00071 BlockSize, 00072 &Offset, 00073 &Event, 00074 &IoStatus); 00075 if (Irp == NULL) 00076 { 00077 DPRINT("IoBuildSynchronousFsdRequest failed\n"); 00078 return STATUS_INSUFFICIENT_RESOURCES; 00079 } 00080 00081 if (Override) 00082 { 00083 Stack = IoGetNextIrpStackLocation(Irp); 00084 Stack->Flags |= SL_OVERRIDE_VERIFY_VOLUME; 00085 } 00086 00087 DPRINT("Calling IO Driver... with irp %p\n", Irp); 00088 Status = IoCallDriver(DeviceObject, Irp); 00089 00090 DPRINT("Waiting for IO Operation for %p\n", Irp); 00091 if (Status == STATUS_PENDING) 00092 { 00093 DPRINT("Operation pending\n"); 00094 KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); 00095 DPRINT("Getting IO Status... for %p\n", Irp); 00096 Status = IoStatus.Status; 00097 } 00098 00099 DPRINT("NtfsReadSectors() done (Status %x)\n", Status); 00100 00101 return Status; 00102 } 00103 00104 00105 NTSTATUS 00106 NtfsDeviceIoControl(IN PDEVICE_OBJECT DeviceObject, 00107 IN ULONG ControlCode, 00108 IN PVOID InputBuffer, 00109 IN ULONG InputBufferSize, 00110 IN OUT PVOID OutputBuffer, 00111 IN OUT PULONG OutputBufferSize, 00112 IN BOOLEAN Override) 00113 { 00114 PIO_STACK_LOCATION Stack; 00115 IO_STATUS_BLOCK IoStatus; 00116 KEVENT Event; 00117 PIRP Irp; 00118 NTSTATUS Status; 00119 00120 KeInitializeEvent(&Event, NotificationEvent, FALSE); 00121 00122 DPRINT("Building device I/O control request ...\n"); 00123 Irp = IoBuildDeviceIoControlRequest(ControlCode, 00124 DeviceObject, 00125 InputBuffer, 00126 InputBufferSize, 00127 OutputBuffer, 00128 (OutputBufferSize) ? *OutputBufferSize : 0, 00129 FALSE, 00130 &Event, 00131 &IoStatus); 00132 if (Irp == NULL) 00133 { 00134 DPRINT("IoBuildDeviceIoControlRequest() failed\n"); 00135 return STATUS_INSUFFICIENT_RESOURCES; 00136 } 00137 00138 if (Override) 00139 { 00140 Stack = IoGetNextIrpStackLocation(Irp); 00141 Stack->Flags |= SL_OVERRIDE_VERIFY_VOLUME; 00142 } 00143 00144 DPRINT("Calling IO Driver... with irp %p\n", Irp); 00145 Status = IoCallDriver(DeviceObject, Irp); 00146 if (Status == STATUS_PENDING) 00147 { 00148 KeWaitForSingleObject(&Event, Suspended, KernelMode, FALSE, NULL); 00149 Status = IoStatus.Status; 00150 } 00151 00152 if (OutputBufferSize) 00153 { 00154 *OutputBufferSize = IoStatus.Information; 00155 } 00156 00157 return Status; 00158 } 00159 00160 /* EOF */ Generated on Mon May 28 2012 04:27:26 for ReactOS by
1.7.6.1
|