Added stubs for missing partition functions

svn path=/trunk/; revision=1951
This commit is contained in:
Eric Kohl 2001-06-08 15:11:04 +00:00
parent 624e3335e1
commit 18b431ed17
6 changed files with 292 additions and 256 deletions

View file

@ -1,6 +1,6 @@
#ifndef _INCLUDE_DDK_IOFUNCS_H
#define _INCLUDE_DDK_IOFUNCS_H
/* $Id: iofuncs.h,v 1.23 2001/05/01 23:08:17 chorns Exp $ */
/* $Id: iofuncs.h,v 1.24 2001/06/08 15:06:51 ekohl Exp $ */
/* --- EXPORTED BY NTOSKRNL --- */
@ -1181,7 +1181,7 @@ IoWritePartitionTable (
ULONG SectorSize,
ULONG SectorsPerTrack,
ULONG NumberOfHeads,
PDRIVE_LAYOUT_INFORMATION * PartitionBuffer
PDRIVE_LAYOUT_INFORMATION PartitionBuffer
);

View file

@ -1,9 +1,9 @@
/* $Id: drive.c,v 1.2 2000/06/30 22:51:34 ekohl Exp $
/* $Id: drive.c,v 1.3 2001/06/08 15:08:36 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: hal/x86/drive.c
* PURPOSE: Drive letters
* PURPOSE: Drive letter assignment
* PROGRAMMER:
* UPDATE HISTORY:
* 2000-03-25
@ -17,25 +17,22 @@
/* FUNCTIONS *****************************************************************/
VOID
STDCALL
IoAssignDriveLetters (
IN PLOADER_PARAMETER_BLOCK LoaderBlock,
IN PSTRING NtDeviceName,
OUT PUCHAR NtSystemPath,
OUT PSTRING NtSystemPathString
)
VOID STDCALL
IoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
IN PSTRING NtDeviceName,
OUT PUCHAR NtSystemPath,
OUT PSTRING NtSystemPathString)
{
#ifdef __NTOSKRNL__
HalDispatchTable.HalIoAssignDriveLetters (LoaderBlock,
NtDeviceName,
NtSystemPath,
NtSystemPathString);
HalDispatchTable.HalIoAssignDriveLetters(LoaderBlock,
NtDeviceName,
NtSystemPath,
NtSystemPathString);
#else
HalDispatchTable->HalIoAssignDriveLetters (LoaderBlock,
NtDeviceName,
NtSystemPath,
NtSystemPathString);
HalDispatchTable->HalIoAssignDriveLetters(LoaderBlock,
NtDeviceName,
NtSystemPath,
NtSystemPathString);
#endif
}

View file

@ -1,4 +1,4 @@
/* $Id: parttab.c,v 1.3 2000/08/21 00:12:20 ekohl Exp $
/* $Id: parttab.c,v 1.4 2001/06/08 15:08:36 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -19,14 +19,11 @@
/* FUNCTIONS *****************************************************************/
NTSTATUS
STDCALL
IoReadPartitionTable (
PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
BOOLEAN ReturnRecognizedPartitions,
PDRIVE_LAYOUT_INFORMATION * PartitionBuffer
)
NTSTATUS STDCALL
IoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
BOOLEAN ReturnRecognizedPartitions,
PDRIVE_LAYOUT_INFORMATION *PartitionBuffer)
{
#ifdef __NTOSKRNL__
return HalDispatchTable.HalIoReadPartitionTable(DeviceObject,
@ -41,29 +38,47 @@ IoReadPartitionTable (
#endif
}
NTSTATUS
STDCALL
IoSetPartitionInformation (
PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
ULONG PartitionNumber,
ULONG PartitionType)
NTSTATUS STDCALL
IoSetPartitionInformation(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
ULONG PartitionNumber,
ULONG PartitionType)
{
UNIMPLEMENTED;
#ifdef __NTOSKRNL__
return HalDispatchTable.HalIoSetPartitionInformation(DeviceObject,
SectorSize,
PartitionNumber,
PartitionType);
#else
return HalDispatchTable->HalIoSetPartitionInformation(DeviceObject,
SectorSize,
PartitionNumber,
PartitionType);
#endif
}
NTSTATUS
STDCALL
IoWritePartitionTable (
PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
ULONG SectorsPerTrack,
ULONG NumberOfHeads,
PDRIVE_LAYOUT_INFORMATION * PBuffer
)
{
UNIMPLEMENTED;
}
NTSTATUS STDCALL
IoWritePartitionTable(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
ULONG SectorsPerTrack,
ULONG NumberOfHeads,
PDRIVE_LAYOUT_INFORMATION PartitionBuffer)
{
#ifdef __NTOSKRNL__
return HalDispatchTable.HalIoWritePartitionTable(DeviceObject,
SectorSize,
SectorsPerTrack,
NumberOfHeads,
PartitionBuffer);
#else
return HalDispatchTable->HalIoWritePartitionTable(DeviceObject,
SectorSize,
SectorsPerTrack,
NumberOfHeads,
PartitionBuffer);
#endif
}
/* EOF */

View file

@ -1,32 +1,35 @@
#ifndef __INCLUDE_INTERNAL_XHAL_H
#define __INCLUDE_INTERNAL_XHAL_H
VOID
FASTCALL
xHalExamineMBR (
IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG MBRTypeIdentifier,
OUT PVOID * Buffer
);
VOID FASTCALL
xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG MBRTypeIdentifier,
OUT PVOID *Buffer);
VOID
FASTCALL
xHalIoAssignDriveLetters (
IN PLOADER_PARAMETER_BLOCK LoaderBlock,
IN PSTRING NtDeviceName,
OUT PUCHAR NtSystemPath,
OUT PSTRING NtSystemPathString
);
VOID FASTCALL
xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
IN PSTRING NtDeviceName,
OUT PUCHAR NtSystemPath,
OUT PSTRING NtSystemPathString);
NTSTATUS
FASTCALL
xHalIoReadPartitionTable (
PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
BOOLEAN ReturnRecognizedPartitions,
PDRIVE_LAYOUT_INFORMATION * PartitionBuffer
);
NTSTATUS FASTCALL
xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
ULONG SectorSize,
BOOLEAN ReturnRecognizedPartitions,
PDRIVE_LAYOUT_INFORMATION *PartitionBuffer);
NTSTATUS FASTCALL
xHalIoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG PartitionNumber,
IN ULONG PartitionType);
NTSTATUS STDCALL
xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG SectorsPerTrack,
IN ULONG NumberOfHeads,
IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer);
#endif

View file

@ -1,4 +1,4 @@
/* $Id: xhaldisp.c,v 1.3 2001/02/10 22:51:09 dwelch Exp $
/* $Id: xhaldisp.c,v 1.4 2001/06/08 15:11:04 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -27,8 +27,8 @@ HAL_DISPATCH EXPORTED HalDispatchTable =
xHalExamineMBR,
xHalIoAssignDriveLetters,
xHalIoReadPartitionTable,
NULL, // xHalIoSetPartitionInformation,
NULL, // xHalIoWritePartitionTable,
xHalIoSetPartitionInformation,
xHalIoWritePartitionTable,
NULL, // HalReferenceHandlerForBus
NULL, // HalReferenceBusHandler
NULL // HalDereferenceBusHandler

View file

@ -1,4 +1,4 @@
/* $Id: xhaldrv.c,v 1.9 2001/06/07 21:16:41 ekohl Exp $
/* $Id: xhaldrv.c,v 1.10 2001/06/08 15:11:04 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -66,79 +66,80 @@ typedef struct _PARTITION_TABLE
/* FUNCTIONS *****************************************************************/
static NTSTATUS
xHalpQueryDriveLayout (
IN PUNICODE_STRING DeviceName,
OUT PDRIVE_LAYOUT_INFORMATION *LayoutInfo
)
xHalpQueryDriveLayout(IN PUNICODE_STRING DeviceName,
OUT PDRIVE_LAYOUT_INFORMATION *LayoutInfo)
{
IO_STATUS_BLOCK StatusBlock;
DISK_GEOMETRY DiskGeometry;
PDEVICE_OBJECT DeviceObject = NULL;
PFILE_OBJECT FileObject;
KEVENT Event;
PIRP Irp;
NTSTATUS Status;
IO_STATUS_BLOCK StatusBlock;
DISK_GEOMETRY DiskGeometry;
PDEVICE_OBJECT DeviceObject = NULL;
PFILE_OBJECT FileObject;
KEVENT Event;
PIRP Irp;
NTSTATUS Status;
DPRINT ("xHalpQueryDriveLayout %wZ %p\n",
DeviceName,
LayoutInfo);
/*
* Get the drives sector size
*/
Status = IoGetDeviceObjectPointer (DeviceName,
FILE_READ_DATA,
&FileObject,
&DeviceObject);
if (!NT_SUCCESS(Status))
{
DPRINT ("Status %x\n",Status);
return Status;
}
KeInitializeEvent (&Event,
NotificationEvent,
FALSE);
Irp = IoBuildDeviceIoControlRequest (IOCTL_DISK_GET_DRIVE_GEOMETRY,
DeviceObject,
NULL,
0,
&DiskGeometry,
sizeof(DISK_GEOMETRY),
FALSE,
&Event,
&StatusBlock);
if (Irp == NULL)
{
ObDereferenceObject (FileObject);
return STATUS_INSUFFICIENT_RESOURCES;
}
Status = IoCallDriver(DeviceObject, Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
Status = StatusBlock.Status;
}
if (!NT_SUCCESS(Status))
{
ObDereferenceObject (FileObject);
return Status;
}
DPRINT("DiskGeometry.BytesPerSector: %d\n",
DiskGeometry.BytesPerSector);
/* read the partition table */
Status = IoReadPartitionTable (DeviceObject,
DiskGeometry.BytesPerSector,
FALSE,
LayoutInfo);
ObDereferenceObject (FileObject);
DPRINT("xHalpQueryDriveLayout %wZ %p\n",
DeviceName,
LayoutInfo);
/* Get the drives sector size */
Status = IoGetDeviceObjectPointer(DeviceName,
FILE_READ_DATA,
&FileObject,
&DeviceObject);
if (!NT_SUCCESS(Status))
{
DPRINT("Status %x\n",Status);
return Status;
}
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
Irp = IoBuildDeviceIoControlRequest(IOCTL_DISK_GET_DRIVE_GEOMETRY,
DeviceObject,
NULL,
0,
&DiskGeometry,
sizeof(DISK_GEOMETRY),
FALSE,
&Event,
&StatusBlock);
if (Irp == NULL)
{
ObDereferenceObject(FileObject);
return STATUS_INSUFFICIENT_RESOURCES;
}
Status = IoCallDriver(DeviceObject,
Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = StatusBlock.Status;
}
if (!NT_SUCCESS(Status))
{
ObDereferenceObject(FileObject);
return Status;
}
DPRINT("DiskGeometry.BytesPerSector: %d\n",
DiskGeometry.BytesPerSector);
/* read the partition table */
Status = IoReadPartitionTable(DeviceObject,
DiskGeometry.BytesPerSector,
FALSE,
LayoutInfo);
ObDereferenceObject(FileObject);
return Status;
}
@ -148,139 +149,138 @@ xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject,
IN ULONG MBRTypeIdentifier,
OUT PVOID *Buffer)
{
KEVENT Event;
IO_STATUS_BLOCK StatusBlock;
LARGE_INTEGER Offset;
PUCHAR LocalBuffer;
PIRP Irp;
NTSTATUS Status;
KEVENT Event;
IO_STATUS_BLOCK StatusBlock;
LARGE_INTEGER Offset;
PUCHAR LocalBuffer;
PIRP Irp;
NTSTATUS Status;
DPRINT ("xHalExamineMBR()\n");
*Buffer = NULL;
DPRINT("xHalExamineMBR()\n");
*Buffer = NULL;
if (SectorSize < 512)
SectorSize = 512;
if (SectorSize > 4096)
SectorSize = 4096;
if (SectorSize < 512)
SectorSize = 512;
if (SectorSize > 4096)
SectorSize = 4096;
LocalBuffer = (PUCHAR)ExAllocatePool (PagedPool,
SectorSize);
if (LocalBuffer == NULL)
return;
LocalBuffer = (PUCHAR)ExAllocatePool(PagedPool,
SectorSize);
if (LocalBuffer == NULL)
return;
KeInitializeEvent (&Event,
NotificationEvent,
FALSE);
KeInitializeEvent(&Event,
NotificationEvent,
FALSE);
Offset.QuadPart = 0;
Offset.QuadPart = 0;
Irp = IoBuildSynchronousFsdRequest (IRP_MJ_READ,
DeviceObject,
LocalBuffer,
SectorSize,
&Offset,
&Event,
&StatusBlock);
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
DeviceObject,
LocalBuffer,
SectorSize,
&Offset,
&Event,
&StatusBlock);
Status = IoCallDriver (DeviceObject,
Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject (&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = StatusBlock.Status;
}
Status = IoCallDriver(DeviceObject,
Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = StatusBlock.Status;
}
if (!NT_SUCCESS(Status))
{
DPRINT ("xHalExamineMBR failed (Status = 0x%08lx)\n",
Status);
ExFreePool (LocalBuffer);
return;
}
if (!NT_SUCCESS(Status))
{
DPRINT("xHalExamineMBR failed (Status = 0x%08lx)\n",
Status);
ExFreePool(LocalBuffer);
return;
}
if (LocalBuffer[0x1FE] != 0x55 || LocalBuffer[0x1FF] != 0xAA)
{
DPRINT ("xHalExamineMBR: invalid MBR signature\n");
ExFreePool (LocalBuffer);
return;
}
if (LocalBuffer[0x1FE] != 0x55 || LocalBuffer[0x1FF] != 0xAA)
{
DPRINT("xHalExamineMBR: invalid MBR signature\n");
ExFreePool(LocalBuffer);
return;
}
if (LocalBuffer[0x1C2] != MBRTypeIdentifier)
{
DPRINT ("xHalExamineMBR: invalid MBRTypeIdentifier\n");
ExFreePool (LocalBuffer);
return;
}
if (LocalBuffer[0x1C2] != MBRTypeIdentifier)
{
DPRINT("xHalExamineMBR: invalid MBRTypeIdentifier\n");
ExFreePool(LocalBuffer);
return;
}
*Buffer = (PVOID)LocalBuffer;
*Buffer = (PVOID)LocalBuffer;
}
static VOID
HalpAssignDrive (
IN PUNICODE_STRING PartitionName,
IN OUT PULONG DriveMap,
IN ULONG DriveNumber
)
HalpAssignDrive(IN PUNICODE_STRING PartitionName,
IN OUT PULONG DriveMap,
IN ULONG DriveNumber)
{
WCHAR DriveNameBuffer[8];
UNICODE_STRING DriveName;
ULONG i;
WCHAR DriveNameBuffer[8];
UNICODE_STRING DriveName;
ULONG i;
DPRINT("HalpAssignDrive()\n");
DPRINT("HalpAssignDrive()\n");
if ((DriveNumber != AUTO_DRIVE) && (DriveNumber < 24))
{
/* force assignment */
if ((*DriveMap & (1 << DriveNumber)) != 0)
{
DbgPrint("Drive letter already used!\n");
return;
}
}
else
{
/* automatic assignment */
DriveNumber = AUTO_DRIVE;
if ((DriveNumber != AUTO_DRIVE) && (DriveNumber < 24))
{
/* force assignment */
if ((*DriveMap & (1 << DriveNumber)) != 0)
{
DbgPrint("Drive letter already used!\n");
return;
}
}
else
{
/* automatic assignment */
DriveNumber = AUTO_DRIVE;
for (i = 2; i < 24; i++)
{
if ((*DriveMap & (1 << i)) == 0)
{
DriveNumber = i;
break;
}
}
for (i = 2; i < 24; i++)
{
if ((*DriveMap & (1 << i)) == 0)
{
DriveNumber = i;
break;
}
}
if (DriveNumber == AUTO_DRIVE)
{
DbgPrint("No drive letter available!\n");
return;
}
}
if (DriveNumber == AUTO_DRIVE)
{
DbgPrint("No drive letter available!\n");
return;
}
}
DPRINT("DriveNumber %d\n", DriveNumber);
DPRINT("DriveNumber %d\n", DriveNumber);
/* set bit in drive map */
*DriveMap = *DriveMap | (1 << DriveNumber);
/* set bit in drive map */
*DriveMap = *DriveMap | (1 << DriveNumber);
/* build drive name */
swprintf (DriveNameBuffer,
L"\\??\\%C:",
'A' + DriveNumber);
RtlInitUnicodeString (&DriveName,
DriveNameBuffer);
/* build drive name */
swprintf(DriveNameBuffer,
L"\\??\\%C:",
'A' + DriveNumber);
RtlInitUnicodeString(&DriveName,
DriveNameBuffer);
DPRINT(" %wZ ==> %wZ\n",
&DriveName,
PartitionName);
DPRINT(" %wZ ==> %wZ\n",
&DriveName,
PartitionName);
/* create symbolic link */
IoCreateSymbolicLink (&DriveName,
PartitionName);
/* create symbolic link */
IoCreateSymbolicLink(&DriveName,
PartitionName);
}
@ -732,7 +732,7 @@ xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
IsRecognizedPartition (PartitionTable->Partition[i].PartitionType);
LayoutBuffer->PartitionEntry[Count].RewritePartition = FALSE;
DPRINT1(" %ld: nr: %d boot: %1x type: %x start: 0x%I64x count: 0x%I64x\n",
DPRINT(" %ld: nr: %d boot: %1x type: %x start: 0x%I64x count: 0x%I64x\n",
Count,
LayoutBuffer->PartitionEntry[Count].PartitionNumber,
LayoutBuffer->PartitionEntry[Count].BootIndicator,
@ -764,4 +764,25 @@ xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
return STATUS_SUCCESS;
}
NTSTATUS FASTCALL
xHalIoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG PartitionNumber,
IN ULONG PartitionType)
{
return STATUS_NOT_IMPLEMENTED;
}
NTSTATUS FASTCALL
xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
IN ULONG SectorSize,
IN ULONG SectorsPerTrack,
IN ULONG NumberOfHeads,
IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer)
{
return STATUS_NOT_IMPLEMENTED;
}
/* EOF */