2003-05-11 Casper S. Hornstrup <chorns@users.sourceforge.net>

* lib/fslib/vfatlib/vfatlib.c (VfatFormat): Set hidden sectors.
	* ntoskrnl/io/xhaldrv.c (xHalIoWritePartitionTable): Implement support
	for primary partitions.
	* subsys/system/usetup/partlist.c (CreateSelectedPartition): Compute
	hidden sectors.
	* subsys/system/usetup/usetup.c (SelectPartitionPage,
	DrawFileSystemList, FormatPartitionPage): Don't use conditional define
	ENABLE_FORMAT.
	(CreateFileSystemList): Don't draw "Keep current file system" option if
	formatting is needed.
	(SelectFileSystemPage): Figure out if partition must be formatted.
	* subsys/system/usetup/usetup.h (ENABLE_FORMAT): Remove.
	(FILE_SYSTEM_LIST): Add ForceFormat field.

svn path=/trunk/; revision=4675
This commit is contained in:
Casper Hornstrup 2003-05-11 18:31:09 +00:00
parent 67e99cf820
commit 0c6f80f830
6 changed files with 130 additions and 64 deletions

View file

@ -1,3 +1,19 @@
2003-05-11 Casper S. Hornstrup <chorns@users.sourceforge.net>
* lib/fslib/vfatlib/vfatlib.c (VfatFormat): Set hidden sectors.
* ntoskrnl/io/xhaldrv.c (xHalIoWritePartitionTable): Implement support
for primary partitions.
* subsys/system/usetup/partlist.c (CreateSelectedPartition): Compute
hidden sectors.
* subsys/system/usetup/usetup.c (SelectPartitionPage,
DrawFileSystemList, FormatPartitionPage): Don't use conditional define
ENABLE_FORMAT.
(CreateFileSystemList): Don't draw "Keep current file system" option if
formatting is needed.
(SelectFileSystemPage): Figure out if partition must be formatted.
* subsys/system/usetup/usetup.h (ENABLE_FORMAT): Remove.
(FILE_SYSTEM_LIST): Add ForceFormat field.
2003-05-11 Casper S. Hornstrup <chorns@users.sourceforge.net>
* lib/user32/windows/font.c (TEXT_PathEllipsify, TEXT_Reprefix): Fix

View file

@ -427,7 +427,7 @@ VfatFormat(
BootSector.FATSectors = 0;
BootSector.SectorsPerTrack = DiskGeometry.SectorsPerTrack;
BootSector.Heads = DiskGeometry.TracksPerCylinder;
BootSector.HiddenSectors = 63; /* FIXME: */
BootSector.HiddenSectors = PartitionInfo.HiddenSectors;
BootSector.SectorsHuge = PartitionInfo.PartitionLength.QuadPart >>
GetShiftCount(BootSector.BytesPerSector); /* Use shifting to avoid 64-bit division */
BootSector.FATSectors32 = 0; /* Set later */
@ -436,7 +436,7 @@ VfatFormat(
BootSector.RootCluster = 2;
BootSector.FSInfoSector = 1;
BootSector.BootBackup = 6;
BootSector.Drive = 0xff; /* No BIOS boot drive available */ //0x80; /* FIXME: */
BootSector.Drive = 0xff; /* No BIOS boot drive available */
BootSector.ExtBootSignature = 0x29;
BootSector.VolumeID = 0x45768798; /* FIXME: */
if ((Label == NULL) || (Label->Buffer == NULL))

View file

@ -1,10 +1,11 @@
/* $Id: xhaldrv.c,v 1.31 2003/04/28 21:15:07 ekohl Exp $
/* $Id: xhaldrv.c,v 1.32 2003/05/11 18:31:09 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/io/xhaldrv.c
* PURPOSE: Hal drive routines
* PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
* Casper S. Hornstrup (chorns@users.sourceforge.net)
* UPDATE HISTORY:
* Created 19/06/2000
*/
@ -831,8 +832,9 @@ xHalIoReadPartitionTable(PDEVICE_OBJECT DeviceObject,
(((PartitionSector->Partition[i].StartingSector) & 0xc0) << 2) +
PartitionSector->Partition[i].StartingCylinder,
PartitionSector->Partition[i].EndingHead,
PartitionSector->Partition[i].EndingSector,
PartitionSector->Partition[i].EndingCylinder,
PartitionSector->Partition[i].EndingSector & 0x3f,
(((PartitionSector->Partition[i].EndingSector) & 0xc0) << 2) +
PartitionSector->Partition[i].EndingCylinder,
PartitionSector->Partition[i].StartingBlock,
PartitionSector->Partition[i].SectorCount);
}
@ -949,10 +951,22 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
NTSTATUS Status;
ULONG i;
DPRINT("xHalIoWritePartitionTable(%p %lu %lu %p)\n",
ULONG StartBlock;
ULONG SectorCount;
ULONG StartCylinder;
ULONG StartSector;
ULONG StartHead;
ULONG EndCylinder;
ULONG EndSector;
ULONG EndHead;
ULONG lba;
ULONG x;
DPRINT("xHalIoWritePartitionTable(%p %lu %lu %lu %p)\n",
DeviceObject,
SectorSize,
SectorsPerTrack,
NumberOfHeads,
PartitionBuffer);
assert(DeviceObject);
@ -1005,28 +1019,75 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
return Status;
}
DPRINT1("WARNING: Only 'BootFlags' is implemented\n");
for (i = 0; i < PartitionBuffer->PartitionCount; i++)
{
//= PartitionBuffer->PartitionEntry[i].StartingOffset;
//= PartitionBuffer->PartitionEntry[i].PartitionLength;
//= PartitionBuffer->PartitionEntry[i].HiddenSectors;
//= PartitionBuffer->PartitionEntry[i].PartitionType;
//= PartitionBuffer->PartitionEntry[i].PartitionType;
if (PartitionBuffer->PartitionEntry[i].BootIndicator)
if (PartitionBuffer->PartitionEntry[i].PartitionType != PARTITION_ENTRY_UNUSED)
{
PartitionSector->Partition[i].BootFlags |= 0x80;
/*
* CHS formulas:
* x = LBA DIV SectorsPerTrack
* cylinder = x DIV NumberOfHeads
* head = x MOD NumberOfHeads
* sector = (LBA MOD SectorsPerTrack) + 1
*/
if (PartitionBuffer->PartitionEntry[i].BootIndicator)
{
PartitionSector->Partition[i].BootFlags |= 0x80;
}
else
{
PartitionSector->Partition[i].BootFlags &= ~0x80;
}
PartitionSector->Partition[i].PartitionType = PartitionBuffer->PartitionEntry[i].PartitionType;
/* Compute starting CHS values */
lba = (PartitionBuffer->PartitionEntry[i].StartingOffset.QuadPart / SectorSize);
StartBlock = lba; /* Save this for later */
x = lba / SectorsPerTrack;
StartCylinder = x / NumberOfHeads;
StartHead = x % NumberOfHeads;
StartSector = (lba % SectorsPerTrack) + 1;
DPRINT("StartingOffset (LBA:%d C:%d H:%d S:%d)\n", lba, StartCylinder, StartHead, StartSector);
/* Compute ending CHS values */
lba = (PartitionBuffer->PartitionEntry[i].StartingOffset.QuadPart
+ (PartitionBuffer->PartitionEntry[i].PartitionLength.QuadPart - 1)) / SectorSize;
SectorCount = lba - StartBlock; /* Save this for later */
x = lba / SectorsPerTrack;
EndCylinder = x / NumberOfHeads;
EndHead = x % NumberOfHeads;
EndSector = (lba % SectorsPerTrack) + 1;
DPRINT("EndingOffset (LBA:%d C:%d H:%d S:%d)\n", lba, EndCylinder, EndHead, EndSector);
/* Set startsector and sectorcount */
PartitionSector->Partition[i].StartingBlock = StartBlock;
PartitionSector->Partition[i].SectorCount = SectorCount;
/* Set starting CHS values */
PartitionSector->Partition[i].StartingCylinder = StartCylinder & 0xff;
PartitionSector->Partition[i].StartingHead = StartHead;
PartitionSector->Partition[i].StartingSector = ((StartCylinder & 0x0300) >> 2) + (StartSector & 0x3f);
/* Set ending CHS values */
PartitionSector->Partition[i].EndingCylinder = EndCylinder & 0xff;
PartitionSector->Partition[i].EndingHead = EndHead;
PartitionSector->Partition[i].EndingSector = ((EndCylinder & 0x0300) >> 2) + (EndSector & 0x3f);
}
else
{
PartitionSector->Partition[i].BootFlags &= ~0x80;
PartitionSector->Partition[i].BootFlags = 0;
PartitionSector->Partition[i].PartitionType = PARTITION_ENTRY_UNUSED;
PartitionSector->Partition[i].StartingHead = 0;
PartitionSector->Partition[i].StartingSector = 0;
PartitionSector->Partition[i].StartingCylinder = 0;
PartitionSector->Partition[i].EndingHead = 0;
PartitionSector->Partition[i].EndingSector = 0;
PartitionSector->Partition[i].EndingCylinder = 0;
PartitionSector->Partition[i].StartingBlock = 0;
PartitionSector->Partition[i].SectorCount = 0;
}
//= PartitionBuffer->PartitionEntry[i].RecognizedPartition;
//= PartitionBuffer->PartitionEntry[i].RewritePartition;
}
@ -1054,8 +1115,9 @@ xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject,
(((PartitionSector->Partition[i].StartingSector) & 0xc0) << 2) +
PartitionSector->Partition[i].StartingCylinder,
PartitionSector->Partition[i].EndingHead,
PartitionSector->Partition[i].EndingSector,
PartitionSector->Partition[i].EndingCylinder,
PartitionSector->Partition[i].EndingSector & 0x3f,
(((PartitionSector->Partition[i].EndingSector) & 0xc0) << 2) +
PartitionSector->Partition[i].EndingCylinder,
PartitionSector->Partition[i].StartingBlock,
PartitionSector->Partition[i].SectorCount);
}

View file

@ -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: partlist.c,v 1.9 2003/04/28 19:44:13 chorns Exp $
/* $Id: partlist.c,v 1.10 2003/05/11 18:31:09 chorns Exp $
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/partlist.c
@ -1245,9 +1245,11 @@ CreateSelectedPartition(PPARTLIST List,
li.QuadPart = PartEntry->StartingOffset;
LayoutBuffer->PartitionEntry[PartEntryNumber].StartingOffset = li;
/* FIXME: Adjust PartitionLength so the partition will end on the last sector of a track */
li.QuadPart = NewPartSize;
LayoutBuffer->PartitionEntry[PartEntryNumber].PartitionLength = li;
LayoutBuffer->PartitionEntry[PartEntryNumber].HiddenSectors = 0; /* FIXME: ? */
LayoutBuffer->PartitionEntry[PartEntryNumber].HiddenSectors =
PartEntry->StartingOffset / DiskEntry->BytesPerSector;
LayoutBuffer->PartitionEntry[PartEntryNumber].PartitionType = PartType;
LayoutBuffer->PartitionEntry[PartEntryNumber].RecognizedPartition = TRUE;
LayoutBuffer->PartitionEntry[PartEntryNumber].RewritePartition = TRUE;

View file

@ -812,20 +812,16 @@ SelectPartitionPage(PINPUT_RECORD Ir)
}
else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_C) /* C */
{
#ifdef ENABLE_FORMAT
/* Don't destroy the parition list here */;
return(CREATE_PARTITION_PAGE);
#endif
}
else if (Ir->Event.KeyEvent.wVirtualKeyCode == VK_D) /* D */
{
#ifdef ENABLE_FORMAT
if (ConfirmDeletePartition(Ir) == TRUE)
{
(BOOLEAN) DeleteSelectedPartition(CurrentPartitionList);
}
return(SELECT_PARTITION_PAGE);
#endif
}
/* FIXME: Update status text */
@ -1151,11 +1147,8 @@ CreateFileSystemList(SHORT Left,
List->Left = Left;
List->Top = Top;
#ifdef ENABLE_FORMAT
List->ForceFormat = ForceFormat;
List->FileSystemCount = 1;
#else
List->FileSystemCount = 0;
#endif
if (ForceFormat)
{
List->CurrentFileSystem = ForceFileSystem;
@ -1185,7 +1178,6 @@ DrawFileSystemList(PFILE_SYSTEM_LIST List)
index = 0;
#ifdef ENABLE_FORMAT
coPos.X = List->Left;
coPos.Y = List->Top + index;
FillConsoleOutputAttribute(0x17,
@ -1206,26 +1198,28 @@ DrawFileSystemList(PFILE_SYSTEM_LIST List)
SetTextXY(List->Left, List->Top + index, " Format partition as FAT file system ");
}
index++;
#endif
coPos.X = List->Left;
coPos.Y = List->Top + index;
FillConsoleOutputAttribute(0x17,
50,
coPos,
&Written);
FillConsoleOutputCharacter(' ',
50,
coPos,
&Written);
if (!List->ForceFormat)
{
coPos.X = List->Left;
coPos.Y = List->Top + index;
FillConsoleOutputAttribute(0x17,
50,
coPos,
&Written);
FillConsoleOutputCharacter(' ',
50,
coPos,
&Written);
if (List->CurrentFileSystem == FsKeep)
{
SetInvertedTextXY(List->Left, List->Top + index, " Keep current file system (no changes) ");
}
else
{
SetTextXY(List->Left, List->Top + index, " Keep current file system (no changes) ");
if (List->CurrentFileSystem == FsKeep)
{
SetInvertedTextXY(List->Left, List->Top + index, " Keep current file system (no changes) ");
}
else
{
SetTextXY(List->Left, List->Top + index, " Keep current file system (no changes) ");
}
}
}
@ -1256,6 +1250,7 @@ static PAGE_NUMBER
SelectFileSystemPage(PINPUT_RECORD Ir)
{
PFILE_SYSTEM_LIST FileSystemList;
BOOLEAN ForceFormat;
ULONGLONG DiskSize;
ULONGLONG PartSize;
PCHAR DiskUnit;
@ -1342,7 +1337,8 @@ SelectFileSystemPage(PINPUT_RECORD Ir)
SetTextXY(8, 21, "\xfa Press ENTER to format the partition.");
SetTextXY(8, 23, "\xfa Press ESC to select another partition.");
FileSystemList = CreateFileSystemList(6, 26, FALSE, FsKeep);
ForceFormat = (PartData.PartType == PARTITION_ENTRY_UNUSED);
FileSystemList = CreateFileSystemList(6, 26, ForceFormat, FsFat);
if (FileSystemList == NULL)
{
/* FIXME: show an error dialog */
@ -1429,11 +1425,9 @@ FormatPartitionPage(PINPUT_RECORD Ir)
switch (CurrentFileSystemList->CurrentFileSystem)
{
#ifdef ENABLE_FORMAT
case FsFat:
PartType = PARTITION_FAT32_XINT13;
break;
#endif
case FsKeep:
break;
default:
@ -1453,7 +1447,6 @@ FormatPartitionPage(PINPUT_RECORD Ir)
switch (CurrentFileSystemList->CurrentFileSystem)
{
#ifdef ENABLE_FORMAT
case FsFat:
Status = FormatPartition(&DestinationRootPath);
if (!NT_SUCCESS(Status))
@ -1463,7 +1456,6 @@ FormatPartitionPage(PINPUT_RECORD Ir)
return(QUIT_PAGE);
}
break;
#endif
case FsKeep:
break;
default:

View file

@ -27,9 +27,6 @@
#ifndef __USETUP_H__
#define __USETUP_H__
// Define to allow creating a new partition and format it
//#define ENABLE_FORMAT
#define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
#define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
@ -38,18 +35,15 @@
typedef enum
{
#ifdef ENABLE_FORMAT
FsFat = 0,
FsKeep = 1
#else
FsKeep = 0
#endif
} FILE_SYSTEM;
typedef struct _FILE_SYSTEM_LIST
{
SHORT Left;
SHORT Top;
BOOLEAN ForceFormat;
FILE_SYSTEM CurrentFileSystem;
ULONG FileSystemCount;
} FILE_SYSTEM_LIST, *PFILE_SYSTEM_LIST;