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/ntfs/blockdev.c
24 * PURPOSE: NTFS filesystem driver
25 * PROGRAMMER: Eric Kohl
28 /* INCLUDES *****************************************************************/
30 #include <ddk/ntddk.h>
38 /* FUNCTIONS ****************************************************************/
41 NtfsReadSectors(IN PDEVICE_OBJECT DeviceObject
,
48 PIO_STACK_LOCATION Stack
;
49 IO_STATUS_BLOCK IoStatus
;
56 KeInitializeEvent(&Event
,
60 Offset
.QuadPart
= (LONGLONG
)DiskSector
* (LONGLONG
)SectorSize
;
61 BlockSize
= SectorCount
* SectorSize
;
63 DPRINT("NtfsReadSectors(DeviceObject %x, DiskSector %d, Buffer %x)\n",
64 DeviceObject
, DiskSector
, Buffer
);
65 DPRINT("Offset %I64x BlockSize %ld\n",
69 DPRINT("Building synchronous FSD Request...\n");
70 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_READ
,
79 DPRINT("IoBuildSynchronousFsdRequest failed\n");
80 return STATUS_INSUFFICIENT_RESOURCES
;
85 Stack
= IoGetNextIrpStackLocation(Irp
);
86 Stack
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
89 DPRINT("Calling IO Driver... with irp %x\n", Irp
);
90 Status
= IoCallDriver(DeviceObject
, Irp
);
92 DPRINT("Waiting for IO Operation for %x\n", Irp
);
93 if (Status
== STATUS_PENDING
)
95 DPRINT("Operation pending\n");
96 KeWaitForSingleObject(&Event
, Suspended
, KernelMode
, FALSE
, NULL
);
97 DPRINT("Getting IO Status... for %x\n", Irp
);
98 Status
= IoStatus
.Status
;
101 DPRINT("NtfsReadSectors() done (Status %x)\n", Status
);
108 NtfsDeviceIoControl(IN PDEVICE_OBJECT DeviceObject
,
109 IN ULONG ControlCode
,
110 IN PVOID InputBuffer
,
111 IN ULONG InputBufferSize
,
112 IN OUT PVOID OutputBuffer
,
113 IN OUT PULONG OutputBufferSize
,
116 PIO_STACK_LOCATION Stack
;
117 IO_STATUS_BLOCK IoStatus
;
122 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
124 DPRINT("Building device I/O control request ...\n");
125 Irp
= IoBuildDeviceIoControlRequest(ControlCode
,
130 (OutputBufferSize
) ? *OutputBufferSize
: 0,
136 DPRINT("IoBuildDeviceIoControlRequest() failed\n");
137 return STATUS_INSUFFICIENT_RESOURCES
;
142 Stack
= IoGetNextIrpStackLocation(Irp
);
143 Stack
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
146 DPRINT("Calling IO Driver... with irp %x\n", Irp
);
147 Status
= IoCallDriver(DeviceObject
, Irp
);
148 if (Status
== STATUS_PENDING
)
150 KeWaitForSingleObject(&Event
, Suspended
, KernelMode
, FALSE
, NULL
);
151 Status
= IoStatus
.Status
;
154 if (OutputBufferSize
)
156 *OutputBufferSize
= IoStatus
.Information
;