3 * Copyright (C) 2002 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program 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 General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * COPYRIGHT: See COPYING in the top level directory
22 * PROJECT: ReactOS kernel
23 * FILE: services/fs/fs_rec/blockdev.c
24 * PURPOSE: Filesystem recognizer driver
25 * PROGRAMMER: Eric Kohl
28 /* INCLUDES *****************************************************************/
30 #include <ddk/ntddk.h>
38 /* FUNCTIONS ****************************************************************/
41 FsRecReadSectors(IN PDEVICE_OBJECT DeviceObject,
47 PIO_STACK_LOCATION Stack;
48 IO_STATUS_BLOCK IoStatus;
55 Event = ExAllocatePool(NonPagedPool, sizeof(KEVENT));
58 return(STATUS_INSUFFICIENT_RESOURCES);
61 KeInitializeEvent(Event,
65 Offset.QuadPart = (LONGLONG)DiskSector * (LONGLONG)SectorSize;
66 BlockSize = SectorCount * SectorSize;
68 DPRINT("FsrecReadSectors(DeviceObject %x, DiskSector %d, Buffer %x)\n",
69 DeviceObject, DiskSector, Buffer);
70 DPRINT("Offset %I64x BlockSize %ld\n",
74 DPRINT("Building synchronous FSD Request...\n");
75 Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
84 DPRINT("IoBuildSynchronousFsdRequest failed\n");
86 return(STATUS_INSUFFICIENT_RESOURCES);
89 DPRINT("Calling IO Driver... with irp %x\n", Irp);
90 Status = IoCallDriver(DeviceObject, Irp);
91 if (Status == STATUS_PENDING)
93 DPRINT("Operation pending\n");
94 KeWaitForSingleObject(Event, Suspended, KernelMode, FALSE, NULL);
95 Status = IoStatus.Status;
100 return(STATUS_SUCCESS);
105 FsRecDeviceIoControl(IN PDEVICE_OBJECT DeviceObject,
106 IN ULONG ControlCode,
107 IN PVOID InputBuffer,
108 IN ULONG InputBufferSize,
109 IN OUT PVOID OutputBuffer,
110 IN OUT PULONG OutputBufferSize)
112 ULONG BufferSize = 0;
115 IO_STATUS_BLOCK IoStatus;
118 if (OutputBufferSize != NULL)
120 BufferSize = *OutputBufferSize;
123 Event = ExAllocatePool(NonPagedPool, sizeof(KEVENT));
126 return(STATUS_INSUFFICIENT_RESOURCES);
129 KeInitializeEvent(Event, NotificationEvent, FALSE);
131 DPRINT("Building device I/O control request ...\n");
132 Irp = IoBuildDeviceIoControlRequest(ControlCode,
143 DPRINT("IoBuildDeviceIoControlRequest() failed\n");
145 return(STATUS_INSUFFICIENT_RESOURCES);
148 DPRINT("Calling IO Driver... with irp %x\n", Irp);
149 Status = IoCallDriver(DeviceObject, Irp);
150 if (Status == STATUS_PENDING)
152 KeWaitForSingleObject(Event, Suspended, KernelMode, FALSE, NULL);
153 Status = IoStatus.Status;
156 if (OutputBufferSize)
158 *OutputBufferSize = BufferSize;