Finished drive letter assignment

Implemented WinNT compatible ARC path (boot.ini)

svn path=/trunk/; revision=1315
This commit is contained in:
Eric Kohl 2000-08-25 15:56:24 +00:00
parent 6c2d255207
commit 1a10e72f31
4 changed files with 229 additions and 73 deletions

View file

@ -1,4 +1,4 @@
/* $Id: ide.c,v 1.33 2000/08/24 19:15:20 ekohl Exp $ /* $Id: ide.c,v 1.34 2000/08/25 15:56:24 ekohl Exp $
* *
* IDE.C - IDE Disk driver * IDE.C - IDE Disk driver
* written by Rex Jolliff * written by Rex Jolliff
@ -925,13 +925,13 @@ IDECreateDevice(IN PDRIVER_OBJECT DriverObject,
} }
RtlInitUnicodeString (&ArcName, RtlInitUnicodeString (&ArcName,
ArcNameBuffer); ArcNameBuffer);
DPRINT1("%wZ ==> %wZ\n", &ArcName, &DeviceName); DPRINT("%wZ ==> %wZ\n", &ArcName, &DeviceName);
RC = IoAssignArcName (&ArcName, RC = IoAssignArcName (&ArcName,
&DeviceName); &DeviceName);
if (!NT_SUCCESS(RC)) if (!NT_SUCCESS(RC))
{ {
DPRINT1("IoAssignArcName (%wZ) failed (Status %x)\n", DPRINT("IoAssignArcName (%wZ) failed (Status %x)\n",
&ArcName, RC); &ArcName, RC);
} }

View file

@ -1,4 +1,4 @@
/* $Id: volume.c,v 1.17 2000/06/29 23:35:24 dwelch Exp $ /* $Id: volume.c,v 1.18 2000/08/25 15:52:56 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -6,7 +6,7 @@
* PURPOSE: File volume functions * PURPOSE: File volume functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl) * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
* Erik Bos, Alexandre Julliard : * Erik Bos, Alexandre Julliard :
* DRIVE_IsValid, GetLogicalDriveStringsA, * GetLogicalDriveStringsA,
* GetLogicalDriveStringsW, GetLogicalDrives * GetLogicalDriveStringsW, GetLogicalDrives
* UPDATE HISTORY: * UPDATE HISTORY:
* Created 01/11/98 * Created 01/11/98
@ -20,6 +20,7 @@
*/ */
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <napi/shared_data.h>
#include <windows.h> #include <windows.h>
#include <ntos/minmax.h> #include <ntos/minmax.h>
@ -31,68 +32,62 @@
#define MAX_DOS_DRIVES 26 #define MAX_DOS_DRIVES 26
int DRIVE_IsValid( int drive )
{
char Drives[4];
Drives[0] = 'A';
Drives[1] = ':';
Drives[2] = '\\';
Drives[3] = 0;
Drives[0] = 'A' + drive -1;
if ((drive < 0) || (drive >= MAX_DOS_DRIVES)) return 0;
if ( CreateFileA(Drives,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS|FILE_ATTRIBUTE_DIRECTORY,NULL) == INVALID_HANDLE_VALUE ) {
return 0;
}
return drive;
}
DWORD DWORD
STDCALL STDCALL
GetLogicalDriveStringsA( GetLogicalDriveStringsA(DWORD nBufferLength,
DWORD nBufferLength, LPSTR lpBuffer)
LPSTR lpBuffer
)
{ {
int drive, count; DWORD drive, count;
DWORD dwDriveMap;
for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++) dwDriveMap = ((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->DosDeviceMap;
if (DRIVE_IsValid(drive)) count++;
if (count * 4 * sizeof(char) <= nBufferLength) for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++)
{ {
LPSTR p = lpBuffer; if (dwDriveMap & (1<<drive))
for (drive = 0; drive < MAX_DOS_DRIVES; drive++) count++;
if (DRIVE_IsValid(drive)) }
if (count * 4 * sizeof(char) <= nBufferLength)
{
LPSTR p = lpBuffer;
for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
if (dwDriveMap & (1<<drive))
{ {
*p++ = 'A' + drive; *p++ = 'A' + drive;
*p++ = ':'; *p++ = ':';
*p++ = '\\'; *p++ = '\\';
*p++ = '\0'; *p++ = '\0';
} }
*p = '\0'; *p = '\0';
} }
return count * 4 * sizeof(char); return (count * 4 * sizeof(char));
} }
DWORD DWORD
STDCALL STDCALL
GetLogicalDriveStringsW( GetLogicalDriveStringsW(DWORD nBufferLength,
DWORD nBufferLength, LPWSTR lpBuffer)
LPWSTR lpBuffer
)
{ {
int drive, count; DWORD drive, count;
DWORD dwDriveMap;
dwDriveMap = ((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->DosDeviceMap;
for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++)
{
if (dwDriveMap & (1<<drive))
count++;
}
for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++)
if (DRIVE_IsValid(drive)) count++;
if (count * 4 * sizeof(WCHAR) <= nBufferLength) if (count * 4 * sizeof(WCHAR) <= nBufferLength)
{ {
LPWSTR p = lpBuffer; LPWSTR p = lpBuffer;
for (drive = 0; drive < MAX_DOS_DRIVES; drive++) for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
if (DRIVE_IsValid(drive)) if (dwDriveMap & (1<<drive))
{ {
*p++ = (WCHAR)('A' + drive); *p++ = (WCHAR)('A' + drive);
*p++ = (WCHAR)':'; *p++ = (WCHAR)':';
@ -101,7 +96,7 @@ GetLogicalDriveStringsW(
} }
*p = (WCHAR)'\0'; *p = (WCHAR)'\0';
} }
return count * 4 * sizeof(WCHAR); return (count * 4 * sizeof(WCHAR));
} }
@ -109,12 +104,7 @@ DWORD
STDCALL STDCALL
GetLogicalDrives(VOID) GetLogicalDrives(VOID)
{ {
DWORD ret = 0; return (((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->DosDeviceMap);
int drive;
for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
if (DRIVE_IsValid(drive)) ret |= (1 << drive);
return ret;
} }

View file

@ -1,4 +1,4 @@
/* $Id: xhaldrv.c,v 1.6 2000/08/24 19:09:12 ekohl Exp $ /* $Id: xhaldrv.c,v 1.7 2000/08/25 15:55:02 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -9,14 +9,6 @@
* Created 19/06/2000 * Created 19/06/2000
*/ */
/*
* TODO:
* - Read disk signature in xHalIoReadPartitionTable().
* - Build correct system path from nt device name or arc name.
* For example: \Device\Harddisk0\Partition1\reactos ==> C:\reactos
* Or: multi(0)disk(0)rdisk(0)partition(1)\reactos ==> C:\reactos
*/
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
@ -32,6 +24,7 @@
#define PARTITION_MAGIC 0xaa55 #define PARTITION_MAGIC 0xaa55
#define PART_MAGIC_OFFSET 0x01fe #define PART_MAGIC_OFFSET 0x01fe
#define PARTITION_OFFSET 0x01be #define PARTITION_OFFSET 0x01be
#define SIGNATURE_OFFSET 0x01b8
#define PARTITION_TBL_SIZE 4 #define PARTITION_TBL_SIZE 4
#define IsUsablePartition(P) \ #define IsUsablePartition(P) \
@ -676,10 +669,9 @@ xHalIoReadPartitionTable (
} }
#endif #endif
/* FIXME: Set the correct value */
if (ExtendedFound == FALSE); if (ExtendedFound == FALSE);
{ {
LayoutBuffer->Signature = 0xdeadbeef; LayoutBuffer->Signature = *((PULONG)(SectorBuffer + SIGNATURE_OFFSET));
} }
ExtendedFound = FALSE; ExtendedFound = FALSE;

View file

@ -1,4 +1,4 @@
/* $Id: main.c,v 1.58 2000/08/24 19:10:27 ekohl Exp $ /* $Id: main.c,v 1.59 2000/08/25 15:54:11 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -29,7 +29,7 @@
#include <internal/i386/segment.h> #include <internal/i386/segment.h>
#include <napi/shared_data.h> #include <napi/shared_data.h>
//#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
/* DATA *********************************************************************/ /* DATA *********************************************************************/
@ -161,17 +161,188 @@ CreateSystemRootLink (PCSZ ParameterLine)
*/ */
} }
static VOID static VOID
InitSystemSharedUserPage (VOID) InitSystemSharedUserPage (PCSZ ParameterLine)
{ {
PKUSER_SHARED_DATA SharedPage; PKUSER_SHARED_DATA SharedPage;
UNICODE_STRING ArcDeviceName;
UNICODE_STRING ArcName;
UNICODE_STRING BootPath;
UNICODE_STRING DriveDeviceName;
UNICODE_STRING DriveName;
WCHAR DriveNameBuffer[20];
PCHAR ParamBuffer;
PWCHAR ArcNameBuffer;
PCHAR p;
NTSTATUS Status;
ULONG Length;
OBJECT_ATTRIBUTES ObjectAttributes;
HANDLE Handle;
ULONG i;
BOOLEAN BootDriveFound;
SharedPage = (PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE; SharedPage = (PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE;
SharedPage->DosDeviceMap = 0;
/* set system root in shared user page */
wcscpy (SharedPage->NtSystemRoot, L"C:\\reactos");
SharedPage->NtProductType = NtProductWinNt; SharedPage->NtProductType = NtProductWinNt;
for (i = 0; i < 32; i++)
{
SharedPage->DosDeviceDriveType[i] = 0;
}
BootDriveFound = FALSE;
/*
* Retrieve the current dos system path
* (e.g.: C:\reactos) from the given arc path
* (e.g.: multi(0)disk(0)rdisk(0)partititon(1)\reactos)
* Format: "<arc_name>\<path> [options...]"
*/
/* create local parameter line copy */
ParamBuffer = ExAllocatePool (PagedPool, 256);
strcpy (ParamBuffer, (char *)ParameterLine);
DPRINT("%s\n", ParamBuffer);
/* cut options off */
p = strchr (ParamBuffer, ' ');
if (p)
{
*p = 0;
}
DPRINT("%s\n", ParamBuffer);
/* extract path */
p = strchr (ParamBuffer, '\\');
if (p)
{
DPRINT("Boot path: %s\n", p);
RtlCreateUnicodeStringFromAsciiz (&BootPath, p);
*p = 0;
}
else
{
DPRINT("Boot path: %s\n", "\\");
RtlCreateUnicodeStringFromAsciiz (&BootPath, "\\");
}
DPRINT("Arc name: %s\n", ParamBuffer);
/* Only arc name left - build full arc name */
ArcNameBuffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
swprintf (ArcNameBuffer, L"\\ArcName\\%S", ParamBuffer);
RtlInitUnicodeString (&ArcName, ArcNameBuffer);
DPRINT("Arc name: %wZ\n", &ArcName);
/* free ParamBuffer */
ExFreePool (ParamBuffer);
/* allocate arc device name string */
ArcDeviceName.Length = 0;
ArcDeviceName.MaximumLength = 256 * sizeof(WCHAR);
ArcDeviceName.Buffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
InitializeObjectAttributes (&ObjectAttributes,
&ArcName,
0,
NULL,
NULL);
Status = NtOpenSymbolicLinkObject (&Handle,
SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes);
RtlFreeUnicodeString (&ArcName);
if (!NT_SUCCESS(Status))
{
RtlFreeUnicodeString (&BootPath);
RtlFreeUnicodeString (&ArcDeviceName);
DbgPrint("NtOpenSymbolicLinkObject() failed (Status %x)\n",
Status);
KeBugCheck (0x0);
}
Status = NtQuerySymbolicLinkObject (Handle,
&ArcDeviceName,
&Length);
NtClose (Handle);
if (!NT_SUCCESS(Status))
{
RtlFreeUnicodeString (&BootPath);
RtlFreeUnicodeString (&ArcDeviceName);
DbgPrint("NtQuerySymbolicObject() failed (Status %x)\n",
Status);
KeBugCheck (0x0);
}
DPRINT("Length: %lu ArcDeviceName: %wZ\n", Length, &ArcDeviceName);
/* allocate device name string */
DriveDeviceName.Length = 0;
DriveDeviceName.MaximumLength = 256 * sizeof(WCHAR);
DriveDeviceName.Buffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR));
for (i = 0; i < 26; i++)
{
swprintf (DriveNameBuffer, L"\\??\\%C:", 'A' + i);
RtlInitUnicodeString (&DriveName,
DriveNameBuffer);
InitializeObjectAttributes (&ObjectAttributes,
&DriveName,
0,
NULL,
NULL);
Status = NtOpenSymbolicLinkObject (&Handle,
SYMBOLIC_LINK_ALL_ACCESS,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
DPRINT("Failed to open link %wZ\n",
&DriveName);
continue;
}
Status = NtQuerySymbolicLinkObject (Handle,
&DriveDeviceName,
&Length);
if (!NT_SUCCESS(Status))
{
DPRINT("Failed query open link %wZ\n",
&DriveName);
continue;
}
DPRINT("Opened link: %wZ ==> %wZ\n",
&DriveName, &DriveDeviceName);
if (!RtlCompareUnicodeString (&ArcDeviceName, &DriveDeviceName, FALSE))
{
DPRINT("DOS Boot path: %c:%wZ\n", 'A' + i, &BootPath);
swprintf (SharedPage->NtSystemRoot,
L"%C:%wZ", 'A' + i, &BootPath);
BootDriveFound = TRUE;
}
NtClose (Handle);
/* set bit in dos drives bitmap (drive available) */
SharedPage->DosDeviceMap |= (1<<i);
}
RtlFreeUnicodeString (&BootPath);
RtlFreeUnicodeString (&DriveDeviceName);
RtlFreeUnicodeString (&ArcDeviceName);
DPRINT("DosDeviceMap: 0x%x\n", SharedPage->DosDeviceMap);
if (BootDriveFound == FALSE)
{
DbgPrint("No system drive found!\n");
KeBugCheck (0x0);
}
} }
@ -307,8 +478,11 @@ void _main (PLOADER_PARAMETER_BLOCK LoaderBlock)
NULL, NULL,
NULL); NULL);
/* initialize shared user page */ /*
InitSystemSharedUserPage (); * Initialize shared user page:
* - set dos system path, dos device map, etc.
*/
InitSystemSharedUserPage (KeLoaderBlock.kernel_parameters);
/* /*
* Launch initial process * Launch initial process