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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 * COPYRIGHT: See COPYING in the top level directory
20 * PROJECT: ReactOS kernel
21 * FILE: drivers/filesystem/ntfs/blockdev.c
22 * PURPOSE: NTFS filesystem driver
23 * PROGRAMMER: Eric Kohl
26 /* INCLUDES *****************************************************************/
33 /* FUNCTIONS ****************************************************************/
36 NtfsReadSectors(IN PDEVICE_OBJECT DeviceObject
,
43 PIO_STACK_LOCATION Stack
;
44 IO_STATUS_BLOCK IoStatus
;
51 KeInitializeEvent(&Event
,
55 Offset
.QuadPart
= (LONGLONG
)DiskSector
* (LONGLONG
)SectorSize
;
56 BlockSize
= SectorCount
* SectorSize
;
58 DPRINT("NtfsReadSectors(DeviceObject %p, DiskSector %d, Buffer %p)\n",
59 DeviceObject
, DiskSector
, Buffer
);
60 DPRINT("Offset %I64x BlockSize %ld\n",
64 DPRINT("Building synchronous FSD Request...\n");
65 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_READ
,
74 DPRINT("IoBuildSynchronousFsdRequest failed\n");
75 return STATUS_INSUFFICIENT_RESOURCES
;
80 Stack
= IoGetNextIrpStackLocation(Irp
);
81 Stack
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
84 DPRINT("Calling IO Driver... with irp %p\n", Irp
);
85 Status
= IoCallDriver(DeviceObject
, Irp
);
87 DPRINT("Waiting for IO Operation for %p\n", Irp
);
88 if (Status
== STATUS_PENDING
)
90 DPRINT("Operation pending\n");
91 KeWaitForSingleObject(&Event
, Suspended
, KernelMode
, FALSE
, NULL
);
92 DPRINT("Getting IO Status... for %p\n", Irp
);
93 Status
= IoStatus
.Status
;
96 DPRINT("NtfsReadSectors() done (Status %x)\n", Status
);
103 NtfsDeviceIoControl(IN PDEVICE_OBJECT DeviceObject
,
104 IN ULONG ControlCode
,
105 IN PVOID InputBuffer
,
106 IN ULONG InputBufferSize
,
107 IN OUT PVOID OutputBuffer
,
108 IN OUT PULONG OutputBufferSize
,
111 PIO_STACK_LOCATION Stack
;
112 IO_STATUS_BLOCK IoStatus
;
117 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
119 DPRINT("Building device I/O control request ...\n");
120 Irp
= IoBuildDeviceIoControlRequest(ControlCode
,
125 (OutputBufferSize
) ? *OutputBufferSize
: 0,
131 DPRINT("IoBuildDeviceIoControlRequest() failed\n");
132 return STATUS_INSUFFICIENT_RESOURCES
;
137 Stack
= IoGetNextIrpStackLocation(Irp
);
138 Stack
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
141 DPRINT("Calling IO Driver... with irp %p\n", Irp
);
142 Status
= IoCallDriver(DeviceObject
, Irp
);
143 if (Status
== STATUS_PENDING
)
145 KeWaitForSingleObject(&Event
, Suspended
, KernelMode
, FALSE
, NULL
);
146 Status
= IoStatus
.Status
;
149 if (OutputBufferSize
)
151 *OutputBufferSize
= IoStatus
.Information
;