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.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS kernel
22 * FILE: services/fs/fs_rec/blockdev.c
23 * PURPOSE: Filesystem recognizer driver
24 * PROGRAMMER: Eric Kohl
27 /* INCLUDES *****************************************************************/
35 /* FUNCTIONS ****************************************************************/
38 FsRecReadSectors(IN PDEVICE_OBJECT DeviceObject
,
44 IO_STATUS_BLOCK IoStatus
;
51 Event
= ExAllocatePool(NonPagedPool
, sizeof(KEVENT
));
54 return(STATUS_INSUFFICIENT_RESOURCES
);
57 KeInitializeEvent(Event
,
61 Offset
.QuadPart
= (LONGLONG
)DiskSector
* (LONGLONG
)SectorSize
;
62 BlockSize
= SectorCount
* SectorSize
;
64 DPRINT("FsrecReadSectors(DeviceObject %x, DiskSector %d, Buffer %x)\n",
65 DeviceObject
, DiskSector
, Buffer
);
66 DPRINT("Offset %I64x BlockSize %ld\n",
70 DPRINT("Building synchronous FSD Request...\n");
71 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_READ
,
80 DPRINT("IoBuildSynchronousFsdRequest failed\n");
82 return(STATUS_INSUFFICIENT_RESOURCES
);
85 DPRINT("Calling IO Driver... with irp %x\n", Irp
);
86 Status
= IoCallDriver(DeviceObject
, Irp
);
87 if (Status
== STATUS_PENDING
)
89 DPRINT("Operation pending\n");
90 KeWaitForSingleObject(Event
, Suspended
, KernelMode
, FALSE
, NULL
);
91 Status
= IoStatus
.Status
;
96 return(STATUS_SUCCESS
);
101 FsRecDeviceIoControl(IN PDEVICE_OBJECT DeviceObject
,
102 IN ULONG ControlCode
,
103 IN PVOID InputBuffer
,
104 IN ULONG InputBufferSize
,
105 IN OUT PVOID OutputBuffer
,
106 IN OUT PULONG OutputBufferSize
)
108 ULONG BufferSize
= 0;
111 IO_STATUS_BLOCK IoStatus
;
114 if (OutputBufferSize
!= NULL
)
116 BufferSize
= *OutputBufferSize
;
119 Event
= ExAllocatePool(NonPagedPool
, sizeof(KEVENT
));
122 return(STATUS_INSUFFICIENT_RESOURCES
);
125 KeInitializeEvent(Event
, NotificationEvent
, FALSE
);
127 DPRINT("Building device I/O control request ...\n");
128 Irp
= IoBuildDeviceIoControlRequest(ControlCode
,
139 DPRINT("IoBuildDeviceIoControlRequest() failed\n");
141 return(STATUS_INSUFFICIENT_RESOURCES
);
144 DPRINT("Calling IO Driver... with irp %x\n", Irp
);
145 Status
= IoCallDriver(DeviceObject
, Irp
);
146 if (Status
== STATUS_PENDING
)
148 KeWaitForSingleObject(Event
, Suspended
, KernelMode
, FALSE
, NULL
);
149 Status
= IoStatus
.Status
;
152 if (OutputBufferSize
!= NULL
)
154 *OutputBufferSize
= IoStatus
.Information
;