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 /* GLOBALS *****************************************************************/
36 /* FUNCTIONS ****************************************************************/
39 NtfsReadSectors(IN PDEVICE_OBJECT DeviceObject
,
46 PIO_STACK_LOCATION Stack
;
47 IO_STATUS_BLOCK IoStatus
;
54 KeInitializeEvent(&Event
,
58 Offset
.QuadPart
= (LONGLONG
)DiskSector
* (LONGLONG
)SectorSize
;
59 BlockSize
= SectorCount
* SectorSize
;
61 DPRINT("NtfsReadSectors(DeviceObject %p, DiskSector %d, Buffer %p)\n",
62 DeviceObject
, DiskSector
, Buffer
);
63 DPRINT("Offset %I64x BlockSize %ld\n",
67 DPRINT("Building synchronous FSD Request...\n");
68 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_READ
,
77 DPRINT("IoBuildSynchronousFsdRequest failed\n");
78 return STATUS_INSUFFICIENT_RESOURCES
;
83 Stack
= IoGetNextIrpStackLocation(Irp
);
84 Stack
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
87 DPRINT("Calling IO Driver... with irp %p\n", Irp
);
88 Status
= IoCallDriver(DeviceObject
, Irp
);
90 DPRINT("Waiting for IO Operation for %p\n", Irp
);
91 if (Status
== STATUS_PENDING
)
93 DPRINT("Operation pending\n");
94 KeWaitForSingleObject(&Event
, Suspended
, KernelMode
, FALSE
, NULL
);
95 DPRINT("Getting IO Status... for %p\n", Irp
);
96 Status
= IoStatus
.Status
;
99 DPRINT("NtfsReadSectors() done (Status %x)\n", Status
);
106 NtfsDeviceIoControl(IN PDEVICE_OBJECT DeviceObject
,
107 IN ULONG ControlCode
,
108 IN PVOID InputBuffer
,
109 IN ULONG InputBufferSize
,
110 IN OUT PVOID OutputBuffer
,
111 IN OUT PULONG OutputBufferSize
,
114 PIO_STACK_LOCATION Stack
;
115 IO_STATUS_BLOCK IoStatus
;
120 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
122 DPRINT("Building device I/O control request ...\n");
123 Irp
= IoBuildDeviceIoControlRequest(ControlCode
,
128 (OutputBufferSize
) ? *OutputBufferSize
: 0,
134 DPRINT("IoBuildDeviceIoControlRequest() failed\n");
135 return STATUS_INSUFFICIENT_RESOURCES
;
140 Stack
= IoGetNextIrpStackLocation(Irp
);
141 Stack
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
144 DPRINT("Calling IO Driver... with irp %p\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
)
154 *OutputBufferSize
= IoStatus
.Information
;