From 576dc2f69b4cc3f5ba808da9096933035524f1e9 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Wed, 13 Mar 2002 01:30:34 +0000 Subject: [PATCH] Moved creation of ARC names into ntoskrnl. svn path=/trunk/; revision=2707 --- reactos/drivers/dd/floppy/floppy.c | 4 - reactos/drivers/dd/ide/ide.c | 39 +---- reactos/drivers/storage/disk/disk.c | 93 +++--------- reactos/ntoskrnl/include/internal/io.h | 5 +- reactos/ntoskrnl/include/internal/xhal.h | 4 + reactos/ntoskrnl/io/arcname.c | 174 +++++++++++++++++++++++ reactos/ntoskrnl/io/xhaldrv.c | 12 +- reactos/ntoskrnl/ke/main.c | 8 +- 8 files changed, 218 insertions(+), 121 deletions(-) create mode 100644 reactos/ntoskrnl/io/arcname.c diff --git a/reactos/drivers/dd/floppy/floppy.c b/reactos/drivers/dd/floppy/floppy.c index ce68b291891..09a61f201b4 100644 --- a/reactos/drivers/dd/floppy/floppy.c +++ b/reactos/drivers/dd/floppy/floppy.c @@ -41,8 +41,6 @@ FloppyCreateController(PDRIVER_OBJECT DriverObject, PFLOPPY_CONTROLLER_EXTENSION ControllerExtension; PFLOPPY_DEVICE_EXTENSION DeviceExtension; UNICODE_STRING DeviceName; - UNICODE_STRING arcname; - UNICODE_STRING SymlinkName; NTSTATUS Status; PDEVICE_OBJECT DeviceObject; PCONFIGURATION_INFORMATION ConfigInfo; @@ -241,8 +239,6 @@ FloppyCreateController(PDRIVER_OBJECT DriverObject, // Ok, we own the adapter object, from now on we can just IoMapTransfer, and not // bother releasing the adapter ever. - RtlInitUnicodeString( &arcname, L"\\ArcName\\multi(0)disk(0)fdisk(0)" ); - Status = IoAssignArcName( &arcname, &DeviceName ); DPRINT( "Floppy drive initialized\n" ); return TRUE; diff --git a/reactos/drivers/dd/ide/ide.c b/reactos/drivers/dd/ide/ide.c index 644dc060297..8fe612447c3 100644 --- a/reactos/drivers/dd/ide/ide.c +++ b/reactos/drivers/dd/ide/ide.c @@ -1,4 +1,4 @@ -/* $Id: ide.c,v 1.52 2002/03/12 20:16:53 ekohl Exp $ +/* $Id: ide.c,v 1.53 2002/03/13 01:29:44 ekohl Exp $ * * IDE.C - IDE Disk driver * written by Rex Jolliff @@ -875,7 +875,7 @@ IDEGetDriveIdentification(IN int CommandPort, // IDECreateDiskDevice // // DESCRIPTION: -// Creates a device by calling IoCreateDevice and a sylbolic link for Win32 +// Creates the disk device object // // RUN LEVEL: // PASSIVE_LEVEL @@ -905,9 +905,7 @@ IDECreateDiskDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG SectorCount) { WCHAR NameBuffer[IDE_MAX_NAME_LENGTH]; - WCHAR ArcNameBuffer[IDE_MAX_NAME_LENGTH + 15]; UNICODE_STRING DeviceName; - UNICODE_STRING ArcName; NTSTATUS RC; PIDE_DEVICE_EXTENSION DeviceExtension; @@ -971,20 +969,6 @@ IDECreateDiskDevice(IN PDRIVER_OBJECT DriverObject, IoInitializeDpcRequest(*DeviceObject, IDEDpcForIsr); - /* assign arc name */ - swprintf(ArcNameBuffer, - L"\\ArcName\\multi(0)disk(0)rdisk(%d)", - DiskNumber); - RtlInitUnicodeString(&ArcName, - ArcNameBuffer); - DPRINT("%wZ ==> %wZ\n", &ArcName, &DeviceName); - RC = IoAssignArcName(&ArcName, - &DeviceName); - if (!NT_SUCCESS(RC)) - { - DbgPrint("IoAssignArcName (%wZ) failed (Status %x)\n", &ArcName, RC); - } - return RC; } @@ -992,7 +976,7 @@ IDECreateDiskDevice(IN PDRIVER_OBJECT DriverObject, // IDECreatePartitionDevice // // DESCRIPTION: -// Creates a device by calling IoCreateDevice and a sylbolic link for Win32 +// Creates a partition device object // // RUN LEVEL: // PASSIVE_LEVEL @@ -1023,9 +1007,7 @@ IDECreatePartitionDevice(IN PDRIVER_OBJECT DriverObject, IN PPARTITION_INFORMATION PartitionInfo) { WCHAR NameBuffer[IDE_MAX_NAME_LENGTH]; - WCHAR ArcNameBuffer[IDE_MAX_NAME_LENGTH + 15]; UNICODE_STRING DeviceName; - UNICODE_STRING ArcName; NTSTATUS RC; PIDE_DEVICE_EXTENSION DeviceExtension; @@ -1087,21 +1069,6 @@ IDECreatePartitionDevice(IN PDRIVER_OBJECT DriverObject, &DeviceName, DeviceExtension->PartitionLength.QuadPart >> 20); - /* assign arc name */ - swprintf(ArcNameBuffer, - L"\\ArcName\\multi(0)disk(0)rdisk(%d)partition(%d)", - DiskNumber, - PartitionInfo->PartitionNumber); - RtlInitUnicodeString(&ArcName, - ArcNameBuffer); - DPRINT("%wZ ==> %wZ\n", &ArcName, &DeviceName); - RC = IoAssignArcName(&ArcName, - &DeviceName); - if (!NT_SUCCESS(RC)) - { - DbgPrint("IoAssignArcName (%wZ) failed (Status %x)\n", &ArcName, RC); - } - return RC; } diff --git a/reactos/drivers/storage/disk/disk.c b/reactos/drivers/storage/disk/disk.c index 55cdb36f215..7f410ae38bb 100644 --- a/reactos/drivers/storage/disk/disk.c +++ b/reactos/drivers/storage/disk/disk.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: disk.c,v 1.8 2002/03/08 12:01:26 ekohl Exp $ +/* $Id: disk.c,v 1.9 2002/03/13 01:30:34 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -386,11 +386,6 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject, ULONG PartitionNumber; NTSTATUS Status; - WCHAR ArcNameBuffer[120]; - UNICODE_STRING ArcName; - ANSI_STRING DeviceNameA; - UNICODE_STRING DeviceName; - DPRINT("DiskClassCreateDeviceObject() called\n"); /* Create the harddisk device directory */ @@ -525,30 +520,6 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject, DPRINT("SectorSize: %lu\n", DiskDeviceExtension->DiskGeometry->BytesPerSector); - /* assign arc name */ - RtlInitAnsiString(&DeviceNameA, - NameBuffer2); - RtlAnsiStringToUnicodeString(&DeviceName, - &DeviceNameA, - TRUE); - swprintf(ArcNameBuffer, - L"\\ArcName\\multi(0)disk(0)rdisk(%lu)", - DiskNumber); - RtlInitUnicodeString(&ArcName, - ArcNameBuffer); - DPRINT("ArcNameBuffer '%S'\n", ArcNameBuffer); - DPRINT("%wZ ==> %wZ\n", &ArcName, &DeviceName); - Status = IoAssignArcName(&ArcName, - &DeviceName); - RtlFreeUnicodeString(&DeviceName); - - if (!NT_SUCCESS(Status)) - { - DbgPrint("IoAssignArcName (%wZ) failed (Status %x)\n", &ArcName, Status); - KeBugCheck(0); - } - - /* Read partition table */ Status = IoReadPartitionTable(DiskDeviceObject, DiskDeviceExtension->DiskGeometry->BytesPerSector, @@ -646,32 +617,6 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject, DiskData->HiddenSectors = PartitionEntry->HiddenSectors; DiskData->BootIndicator = PartitionEntry->BootIndicator; DiskData->DriveNotReady = FALSE; - - - /* assign arc name */ - RtlInitAnsiString(&DeviceNameA, - NameBuffer2); - RtlAnsiStringToUnicodeString(&DeviceName, - &DeviceNameA, - TRUE); - swprintf(ArcNameBuffer, - L"\\ArcName\\multi(0)disk(0)rdisk(%lu)partition(%lu)", - DiskNumber, - PartitionNumber + 1); - RtlInitUnicodeString(&ArcName, - ArcNameBuffer); - DPRINT("ArcNameBuffer '%S'\n", ArcNameBuffer); - DPRINT("%wZ ==> %wZ\n", &ArcName, &DeviceName); - Status = IoAssignArcName(&ArcName, - &DeviceName); - RtlFreeUnicodeString(&DeviceName); - - if (!NT_SUCCESS(Status)) - { - DbgPrint("IoAssignArcName (%wZ) failed (Status %x)\n", &ArcName, Status); - KeBugCheck(0); - } - } else { @@ -795,6 +740,8 @@ DiskClassDeviceControl(IN PDEVICE_OBJECT DeviceObject, case IOCTL_DISK_SET_PARTITION_INFO: DPRINT1("Unhandled IOCTL_DISK_SET_PARTITION_INFO\n"); + Status = STATUS_INVALID_DEVICE_REQUEST; + Information = 0; break; case IOCTL_DISK_GET_DRIVE_LAYOUT: @@ -866,20 +813,26 @@ DiskClassDeviceControl(IN PDEVICE_OBJECT DeviceObject, } -// DiskClassShutdownFlush -// -// DESCRIPTION: -// Answer requests for shutdown and flush calls -// -// RUN LEVEL: -// PASSIVE_LEVEL -// -// ARGUMENTS: -// Standard dispatch arguments -// -// RETURNS: -// NTSTATUS -// +/********************************************************************** + * NAME EXPORTED + * DiskClassShutdownFlush + * + * DESCRIPTION + * Answer requests for shutdown and flush calls. + * + * RUN LEVEL + * PASSIVE_LEVEL + * + * ARGUMENTS + * DeviceObject + * Pointer to the device. + * + * Irp + * Pointer to the IRP + * + * RETURN VALUE + * Status + */ NTSTATUS STDCALL DiskClassShutdownFlush(IN PDEVICE_OBJECT DeviceObject, diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index c86754dfeac..61f3ad3e1e8 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: io.h,v 1.15 2001/10/10 21:57:00 hbirr Exp $ +/* $Id: io.h,v 1.16 2002/03/13 01:26:02 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -311,6 +311,9 @@ NTSTATUS STDCALL IoPageWrite (PFILE_OBJECT FileObject, PIO_STATUS_BLOCK StatusBlock, BOOLEAN PagingIo); +NTSTATUS +IoCreateArcNames(VOID); + NTSTATUS IopInitiatePnpIrp( PDEVICE_OBJECT DeviceObject, diff --git a/reactos/ntoskrnl/include/internal/xhal.h b/reactos/ntoskrnl/include/internal/xhal.h index d6c52dbde36..55a3f17943c 100644 --- a/reactos/ntoskrnl/include/internal/xhal.h +++ b/reactos/ntoskrnl/include/internal/xhal.h @@ -1,6 +1,10 @@ #ifndef __INCLUDE_INTERNAL_XHAL_H #define __INCLUDE_INTERNAL_XHAL_H +NTSTATUS +xHalQueryDriveLayout(IN PUNICODE_STRING DeviceName, + OUT PDRIVE_LAYOUT_INFORMATION *LayoutInfo); + VOID FASTCALL xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject, IN ULONG SectorSize, diff --git a/reactos/ntoskrnl/io/arcname.c b/reactos/ntoskrnl/io/arcname.c new file mode 100644 index 00000000000..12d8f49afd5 --- /dev/null +++ b/reactos/ntoskrnl/io/arcname.c @@ -0,0 +1,174 @@ +/* + * ReactOS kernel + * Copyright (C) 2002 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: arcname.c,v 1.1 2002/03/13 01:27:06 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: ntoskrnl/io/arcname.c + * PURPOSE: creates ARC names for boot devices + * PROGRAMMER: Eric Kohl (ekohl@rz-online.de) + */ + + +/* INCLUDES *****************************************************************/ + +#include + +#include "internal/io.h" +#include "internal/xhal.h" + +#define NDEBUG +#include + + +/* FUNCTIONS ****************************************************************/ + +NTSTATUS +IoCreateArcNames(VOID) +{ + PCONFIGURATION_INFORMATION ConfigInfo; + PDRIVE_LAYOUT_INFORMATION LayoutInfo = NULL; + WCHAR DeviceNameBuffer[80]; + WCHAR ArcNameBuffer[80]; + UNICODE_STRING DeviceName; + UNICODE_STRING ArcName; + ULONG i, j; + NTSTATUS Status; + + DPRINT("IoCreateArcNames() called\n"); + + ConfigInfo = IoGetConfigurationInformation(); + + /* create ARC names for floppy drives */ + DPRINT("Floppy drives: %lu\n", ConfigInfo->FloppyCount); + for (i = 0; i < ConfigInfo->FloppyCount; i++) + { + swprintf(DeviceNameBuffer, + L"\\Device\\Floppy%lu", + i); + RtlInitUnicodeString(&DeviceName, + DeviceNameBuffer); + + swprintf(ArcNameBuffer, + L"\\ArcName\\multi(0)disk(0)fdisk(%lu)", + i); + RtlInitUnicodeString(&ArcName, + ArcNameBuffer); + DPRINT("%wZ ==> %wZ\n", + &ArcName, + &DeviceName); + + Status = IoAssignArcName(&ArcName, + &DeviceName); + if (!NT_SUCCESS(Status)) + return(Status); + } + + /* create ARC names for hard disk drives */ + DPRINT("Disk drives: %lu\n", ConfigInfo->DiskCount); + for (i = 0; i < ConfigInfo->DiskCount; i++) + { + swprintf(DeviceNameBuffer, + L"\\Device\\Harddisk%lu\\Partition0", + i); + RtlInitUnicodeString(&DeviceName, + DeviceNameBuffer); + + swprintf(ArcNameBuffer, + L"\\ArcName\\multi(0)disk(0)rdisk(%lu)partition(0)", + i); + RtlInitUnicodeString(&ArcName, + ArcNameBuffer); + DPRINT("%wZ ==> %wZ\n", + &ArcName, + &DeviceName); + + Status = IoAssignArcName(&ArcName, + &DeviceName); + if (!NT_SUCCESS(Status)) + return(Status); + + Status = xHalQueryDriveLayout(&DeviceName, + &LayoutInfo); + if (!NT_SUCCESS(Status)) + return(Status); + + DPRINT("Number of partitions: %u\n", LayoutInfo->PartitionCount); + + for (j = 0;j < LayoutInfo->PartitionCount; j++) + { + swprintf(DeviceNameBuffer, + L"\\Device\\Harddisk%lu\\Partition%lu", + i, + j + 1); + RtlInitUnicodeString(&DeviceName, + DeviceNameBuffer); + + swprintf(ArcNameBuffer, + L"\\ArcName\\multi(0)disk(0)rdisk(%lu)partition(%lu)", + i, + j + 1); + RtlInitUnicodeString(&ArcName, + ArcNameBuffer); + DPRINT("%wZ ==> %wZ\n", + &ArcName, + &DeviceName); + + Status = IoAssignArcName(&ArcName, + &DeviceName); + if (!NT_SUCCESS(Status)) + return(Status); + } + + ExFreePool(LayoutInfo); + LayoutInfo = NULL; + } + + /* create ARC names for cdrom drives */ + DPRINT("CD-ROM drives: %lu\n", ConfigInfo->CDRomCount); + for (i = 0; i < ConfigInfo->CDRomCount; i++) + { + swprintf(DeviceNameBuffer, + L"\\Device\\CdRom%lu", + i); + RtlInitUnicodeString(&DeviceName, + DeviceNameBuffer); + + swprintf(ArcNameBuffer, + L"\\ArcName\\multi(0)disk(0)cdrom(%lu)", + i); + RtlInitUnicodeString(&ArcName, + ArcNameBuffer); + DPRINT("%wZ ==> %wZ\n", + &ArcName, + &DeviceName); + + Status = IoAssignArcName(&ArcName, + &DeviceName); + if (!NT_SUCCESS(Status)) + return(Status); + } + + + DPRINT("IoCreateArcNames() done\n"); + + return(STATUS_SUCCESS); +} + +/* EOF */ \ No newline at end of file diff --git a/reactos/ntoskrnl/io/xhaldrv.c b/reactos/ntoskrnl/io/xhaldrv.c index 0d5a4a5053e..c2bc26cfa20 100644 --- a/reactos/ntoskrnl/io/xhaldrv.c +++ b/reactos/ntoskrnl/io/xhaldrv.c @@ -1,4 +1,4 @@ -/* $Id: xhaldrv.c,v 1.15 2001/08/21 20:13:09 chorns Exp $ +/* $Id: xhaldrv.c,v 1.16 2002/03/13 01:27:06 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -59,9 +59,9 @@ typedef struct _PARTITION_TABLE /* FUNCTIONS *****************************************************************/ -static NTSTATUS -xHalpQueryDriveLayout(IN PUNICODE_STRING DeviceName, - OUT PDRIVE_LAYOUT_INFORMATION *LayoutInfo) +NTSTATUS +xHalQueryDriveLayout(IN PUNICODE_STRING DeviceName, + OUT PDRIVE_LAYOUT_INFORMATION *LayoutInfo) { IO_STATUS_BLOCK StatusBlock; DISK_GEOMETRY DiskGeometry; @@ -361,8 +361,8 @@ xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock, RtlInitUnicodeString(&UnicodeString1, Buffer1); - Status = xHalpQueryDriveLayout(&UnicodeString1, - &LayoutArray[i]); + Status = xHalQueryDriveLayout(&UnicodeString1, + &LayoutArray[i]); if (!NT_SUCCESS(Status)) { DbgPrint("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n", diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index ff072047f18..86385f47abe 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: main.c,v 1.114 2002/02/20 20:14:22 ekohl Exp $ +/* $Id: main.c,v 1.115 2002/03/13 01:26:32 ekohl Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/main.c @@ -1125,6 +1125,8 @@ ExpInitializeExecutive(VOID) } } + IoCreateArcNames(); + /* Create the SystemRoot symbolic link */ CPRINT("CommandLine: %s\n", (PUCHAR)KeLoaderBlock.CommandLine); @@ -1137,8 +1139,6 @@ ExpInitializeExecutive(VOID) #endif /* DBGPRINT_FILE_LOG */ - CmInitializeRegistry2(); - #if 0 CreateDefaultRegistry(); #endif @@ -1243,7 +1243,7 @@ _main (ULONG MultiBootMagic, PLOADER_PARAMETER_BLOCK _LoaderBlock) */ strcpy (KeLoaderCommandLine, "multi(0)disk(0)rdisk(0)partition(1)\\reactos /DEBUGPORT=SCREEN"); - strcat (KeLoaderCommandLine, (PUCHAR)KeLoaderBlock.CommandLine); +/* strcat (KeLoaderCommandLine, (PUCHAR)KeLoaderBlock.CommandLine); */ KeLoaderBlock.CommandLine = (ULONG)KeLoaderCommandLine; strcpy(KeLoaderModuleStrings[0], "ntoskrnl.exe");