mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 04:23:32 +00:00
Don't use a hardcoded sector size of 512 bytes.
svn path=/trunk/; revision=11794
This commit is contained in:
parent
0b6ffe64b0
commit
4605029c67
2 changed files with 34 additions and 29 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* ReactOS kernel
|
* ReactOS kernel
|
||||||
* Copyright (C) 2001, 2002, 2003 ReactOS Team
|
* Copyright (C) 2001, 2002, 2003, 2004 ReactOS Team
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,13 +16,13 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: disk.c,v 1.46 2004/07/15 04:04:08 jimtabor Exp $
|
/* $Id: disk.c,v 1.47 2004/11/24 11:09:49 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: services/storage/disk/disk.c
|
* FILE: services/storage/disk/disk.c
|
||||||
* PURPOSE: disk class driver
|
* PURPOSE: disk class driver
|
||||||
* PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
|
* PROGRAMMER: Eric Kohl
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
@ -53,7 +53,7 @@ typedef struct _DISK_DATA
|
||||||
BOOLEAN BootIndicator;
|
BOOLEAN BootIndicator;
|
||||||
BOOLEAN DriveNotReady;
|
BOOLEAN DriveNotReady;
|
||||||
} DISK_DATA, *PDISK_DATA;
|
} DISK_DATA, *PDISK_DATA;
|
||||||
|
|
||||||
BOOLEAN STDCALL
|
BOOLEAN STDCALL
|
||||||
DiskClassFindDevices(PDRIVER_OBJECT DriverObject,
|
DiskClassFindDevices(PDRIVER_OBJECT DriverObject,
|
||||||
PUNICODE_STRING RegistryPath,
|
PUNICODE_STRING RegistryPath,
|
||||||
|
@ -640,14 +640,12 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
||||||
|
|
||||||
if ((DiskDeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) &&
|
if ((DiskDeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) &&
|
||||||
(DiskDeviceExtension->DiskGeometry->MediaType == RemovableMedia))
|
(DiskDeviceExtension->DiskGeometry->MediaType == RemovableMedia))
|
||||||
{
|
{
|
||||||
|
DiskClassCreateMediaChangeEvent(DiskDeviceExtension,DiskNumber);
|
||||||
DiskClassCreateMediaChangeEvent(DiskDeviceExtension,DiskNumber);
|
if (DiskDeviceExtension->MediaChangeEvent != NULL)
|
||||||
if(DiskDeviceExtension->MediaChangeEvent != NULL)
|
|
||||||
{
|
{
|
||||||
DPRINT("Allocated media change event!\n");
|
DPRINT("Allocated media change event!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check disk for presence of a disk manager */
|
/* Check disk for presence of a disk manager */
|
||||||
|
@ -668,9 +666,10 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
||||||
ExFreePool(MbrBuffer);
|
ExFreePool(MbrBuffer);
|
||||||
MbrBuffer = NULL;
|
MbrBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((DiskDeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) &&
|
if ((DiskDeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) &&
|
||||||
(DiskDeviceExtension->DiskGeometry->MediaType == RemovableMedia))
|
(DiskDeviceExtension->DiskGeometry->MediaType == RemovableMedia))
|
||||||
{
|
{
|
||||||
/* Allocate a partition list for a single entry. */
|
/* Allocate a partition list for a single entry. */
|
||||||
PartitionList = ExAllocatePool(NonPagedPool,
|
PartitionList = ExAllocatePool(NonPagedPool,
|
||||||
sizeof(DRIVE_LAYOUT_INFORMATION));
|
sizeof(DRIVE_LAYOUT_INFORMATION));
|
||||||
|
@ -765,8 +764,10 @@ DiskClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject,
|
||||||
PartitionEntry->PartitionNumber,
|
PartitionEntry->PartitionNumber,
|
||||||
PartitionEntry->BootIndicator,
|
PartitionEntry->BootIndicator,
|
||||||
PartitionEntry->PartitionType,
|
PartitionEntry->PartitionType,
|
||||||
PartitionEntry->StartingOffset.QuadPart / 512 /*DrvParms.BytesPerSector*/,
|
PartitionEntry->StartingOffset.QuadPart /
|
||||||
PartitionEntry->PartitionLength.QuadPart / 512 /* DrvParms.BytesPerSector*/);
|
DiskDeviceExtension->DiskGeometry->BytesPerSector,
|
||||||
|
PartitionEntry->PartitionLength.QuadPart /
|
||||||
|
DiskDeviceExtension->DiskGeometry->BytesPerSector);
|
||||||
|
|
||||||
/* Create partition device object */
|
/* Create partition device object */
|
||||||
sprintf(NameBuffer2,
|
sprintf(NameBuffer2,
|
||||||
|
@ -890,7 +891,7 @@ DiskBuildPartitionTable(IN PDEVICE_OBJECT DiskDeviceObject,
|
||||||
DPRINT("Drive not ready\n");
|
DPRINT("Drive not ready\n");
|
||||||
DiskData->DriveNotReady = TRUE;
|
DiskData->DriveNotReady = TRUE;
|
||||||
if (PartitionList != NULL)
|
if (PartitionList != NULL)
|
||||||
ExFreePool(PartitionList);
|
ExFreePool(PartitionList);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -906,30 +907,32 @@ DiskBuildPartitionTable(IN PDEVICE_OBJECT DiskDeviceObject,
|
||||||
|
|
||||||
if (PartitionList->PartitionCount)
|
if (PartitionList->PartitionCount)
|
||||||
{
|
{
|
||||||
for (PartitionNumber = 0; PartitionNumber < PartitionList->PartitionCount; PartitionNumber++)
|
for (PartitionNumber = 0; PartitionNumber < PartitionList->PartitionCount; PartitionNumber++)
|
||||||
{
|
{
|
||||||
PartitionEntry = &PartitionList->PartitionEntry[PartitionNumber];
|
PartitionEntry = &PartitionList->PartitionEntry[PartitionNumber];
|
||||||
|
|
||||||
DiskData->PartitionType = PartitionEntry->PartitionType;
|
DiskData->PartitionType = PartitionEntry->PartitionType;
|
||||||
DiskData->PartitionNumber = PartitionNumber + 1;
|
DiskData->PartitionNumber = PartitionNumber + 1;
|
||||||
DiskData->PartitionOrdinal = PartitionNumber + 1;
|
DiskData->PartitionOrdinal = PartitionNumber + 1;
|
||||||
DiskData->HiddenSectors = PartitionEntry->HiddenSectors;
|
DiskData->HiddenSectors = PartitionEntry->HiddenSectors;
|
||||||
DiskData->BootIndicator = PartitionEntry->BootIndicator;
|
DiskData->BootIndicator = PartitionEntry->BootIndicator;
|
||||||
DiskData->DriveNotReady = FALSE;
|
DiskData->DriveNotReady = FALSE;
|
||||||
DiskDeviceExtension->StartingOffset = PartitionEntry->StartingOffset;
|
DiskDeviceExtension->StartingOffset = PartitionEntry->StartingOffset;
|
||||||
DiskDeviceExtension->PartitionLength = PartitionEntry->PartitionLength;
|
DiskDeviceExtension->PartitionLength = PartitionEntry->PartitionLength;
|
||||||
|
|
||||||
DPRINT1("Partition %02ld: nr: %d boot: %1x type: %x offset: %I64d size: %I64d\n",
|
DPRINT1("Partition %02ld: nr: %d boot: %1x type: %x offset: %I64d size: %I64d\n",
|
||||||
PartitionNumber,
|
PartitionNumber,
|
||||||
DiskData->PartitionNumber,
|
DiskData->PartitionNumber,
|
||||||
DiskData->BootIndicator,
|
DiskData->BootIndicator,
|
||||||
DiskData->PartitionType,
|
DiskData->PartitionType,
|
||||||
DiskDeviceExtension->StartingOffset.QuadPart / 512 /*DrvParms.BytesPerSector*/,
|
DiskDeviceExtension->StartingOffset.QuadPart /
|
||||||
DiskDeviceExtension->PartitionLength.QuadPart / 512 /* DrvParms.BytesPerSector*/);
|
DiskDeviceExtension->DiskGeometry->BytesPerSector,
|
||||||
|
DiskDeviceExtension->PartitionLength.QuadPart /
|
||||||
|
DiskDeviceExtension->DiskGeometry->BytesPerSector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DiskData->PartitionType = 0;
|
DiskData->PartitionType = 0;
|
||||||
DiskData->PartitionNumber = 1;
|
DiskData->PartitionNumber = 1;
|
||||||
DiskData->PartitionOrdinal = 0;
|
DiskData->PartitionOrdinal = 0;
|
||||||
|
@ -938,7 +941,7 @@ DiskBuildPartitionTable(IN PDEVICE_OBJECT DiskDeviceObject,
|
||||||
DiskData->DriveNotReady = FALSE;
|
DiskData->DriveNotReady = FALSE;
|
||||||
DiskDeviceExtension->StartingOffset.QuadPart = 0;
|
DiskDeviceExtension->StartingOffset.QuadPart = 0;
|
||||||
DiskDeviceExtension->PartitionLength.QuadPart += DiskDeviceExtension->StartingOffset.QuadPart;
|
DiskDeviceExtension->PartitionLength.QuadPart += DiskDeviceExtension->StartingOffset.QuadPart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("DiskBuildPartitionTable() done\n");
|
DPRINT("DiskBuildPartitionTable() done\n");
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.8 2004/06/10 08:20:20 hbirr Exp $
|
# $Id: makefile,v 1.9 2004/11/24 11:09:49 ekohl Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../../..
|
PATH_TO_TOP = ../../..
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ TARGET_NAME = disk
|
||||||
|
|
||||||
TARGET_DDKLIBS = class2.a
|
TARGET_DDKLIBS = class2.a
|
||||||
|
|
||||||
|
TARGET_GCCLIBS = gcc
|
||||||
|
|
||||||
TARGET_OBJECTS = $(TARGET_NAME).o
|
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||||
|
|
||||||
TARGET_CFLAGS = -Werror -Wall
|
TARGET_CFLAGS = -Werror -Wall
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue