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 NtfsReadDisk(IN PDEVICE_OBJECT DeviceObject
,
37 IN LONGLONG StartingOffset
,
42 PIO_STACK_LOCATION Stack
;
43 IO_STATUS_BLOCK IoStatus
;
49 DPRINT("NtfsReadDisk(%p, %I64x, %u, %p, %d)\n", DeviceObject
, StartingOffset
, Length
, Buffer
, Override
);
51 KeInitializeEvent(&Event
,
55 Offset
.QuadPart
= StartingOffset
;
57 DPRINT("Building synchronous FSD Request...\n");
58 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_READ
,
67 DPRINT("IoBuildSynchronousFsdRequest failed\n");
68 return STATUS_INSUFFICIENT_RESOURCES
;
73 Stack
= IoGetNextIrpStackLocation(Irp
);
74 Stack
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
77 DPRINT("Calling IO Driver... with irp %p\n", Irp
);
78 Status
= IoCallDriver(DeviceObject
, Irp
);
80 DPRINT("Waiting for IO Operation for %p\n", Irp
);
81 if (Status
== STATUS_PENDING
)
83 DPRINT("Operation pending\n");
84 KeWaitForSingleObject(&Event
, Suspended
, KernelMode
, FALSE
, NULL
);
85 DPRINT("Getting IO Status... for %p\n", Irp
);
86 Status
= IoStatus
.Status
;
89 DPRINT("NtfsReadDisk() done (Status %x)\n", Status
);
95 NtfsReadSectors(IN PDEVICE_OBJECT DeviceObject
,
105 Offset
= (LONGLONG
)DiskSector
* (LONGLONG
)SectorSize
;
106 BlockSize
= SectorCount
* SectorSize
;
108 return NtfsReadDisk(DeviceObject
, Offset
, BlockSize
, Buffer
, Override
);
113 NtfsDeviceIoControl(IN PDEVICE_OBJECT DeviceObject
,
114 IN ULONG ControlCode
,
115 IN PVOID InputBuffer
,
116 IN ULONG InputBufferSize
,
117 IN OUT PVOID OutputBuffer
,
118 IN OUT PULONG OutputBufferSize
,
121 PIO_STACK_LOCATION Stack
;
122 IO_STATUS_BLOCK IoStatus
;
127 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
129 DPRINT("Building device I/O control request ...\n");
130 Irp
= IoBuildDeviceIoControlRequest(ControlCode
,
135 (OutputBufferSize
) ? *OutputBufferSize
: 0,
141 DPRINT("IoBuildDeviceIoControlRequest() failed\n");
142 return STATUS_INSUFFICIENT_RESOURCES
;
147 Stack
= IoGetNextIrpStackLocation(Irp
);
148 Stack
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
151 DPRINT("Calling IO Driver... with irp %p\n", Irp
);
152 Status
= IoCallDriver(DeviceObject
, Irp
);
153 if (Status
== STATUS_PENDING
)
155 KeWaitForSingleObject(&Event
, Suspended
, KernelMode
, FALSE
, NULL
);
156 Status
= IoStatus
.Status
;
159 if (OutputBufferSize
)
161 *OutputBufferSize
= IoStatus
.Information
;