Update to new fmifs types.

Implement partition format progress bar.

svn path=/trunk/; revision=8332
This commit is contained in:
Eric Kohl 2004-02-23 11:58:27 +00:00
parent 951f5f360f
commit 95033dafab
5 changed files with 196 additions and 50 deletions

View file

@ -16,7 +16,7 @@
* 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: format.c,v 1.2 2003/08/18 17:39:26 ekohl Exp $ /* $Id: format.c,v 1.3 2004/02/23 11:58:27 ekohl Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup * PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/format.c * FILE: subsys/system/usetup/format.c
@ -28,28 +28,104 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ntdll/rtl.h> #include <ntdll/rtl.h>
#include <fslib/vfatlib.h>
#include "usetup.h"
#include "console.h"
#include "progress.h"
#define NDEBUG #define NDEBUG
#include <debug.h> #include <debug.h>
#include <fslib/vfatlib.h>
PPROGRESSBAR ProgressBar = NULL;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
BOOLEAN STDCALL
FormatCallback (CALLBACKCOMMAND Command,
ULONG Modifier,
PVOID Argument)
{
// DPRINT1 ("FormatCallback() called\n");
switch (Command)
{
case PROGRESS:
{
PULONG Percent;
Percent = (PULONG)Argument;
DPRINT ("%lu percent completed\n", *Percent);
ProgressSetStep (ProgressBar, *Percent);
}
break;
// case OUTPUT:
// {
// PTEXTOUTPUT Output;
// output = (PTEXTOUTPUT) Argument;
// fprintf(stdout, "%s", output->Output);
// }
// break;
case DONE:
{
DPRINT ("Done\n");
// PBOOLEAN Success;
// status = (PBOOLEAN) Argument;
// if ( *status == FALSE )
// {
// wprintf(L"FormatEx was unable to complete successfully.\n\n");
// Error = TRUE;
// }
}
break;
default:
DPRINT ("Unknown callback %lu\n", (ULONG)Command);
break;
}
// DPRINT1 ("FormatCallback() done\n");
return TRUE;
}
NTSTATUS NTSTATUS
FormatPartition(PUNICODE_STRING DriveRoot) FormatPartition (PUNICODE_STRING DriveRoot)
{ {
NTSTATUS Status; NTSTATUS Status;
SHORT xScreen;
SHORT yScreen;
VfatInitialize(); GetScreenSize(&xScreen, &yScreen);
ProgressBar = CreateProgressBar (6,
yScreen - 14,
xScreen - 7,
yScreen - 10);
ProgressSetStepCount (ProgressBar, 100);
VfatInitialize ();
Status = VfatFormat (DriveRoot, Status = VfatFormat (DriveRoot,
0, // MediaFlag 0, /* MediaFlag */
NULL, // Label NULL, /* Label */
TRUE, // QuickFormat TRUE, /* QuickFormat */
0, // ClusterSize 0, /* ClusterSize */
NULL); // Callback (PFMIFSCALLBACK)FormatCallback); /* Callback */
DPRINT1("VfatFormat() status 0x%.08x\n", Status);
VfatCleanup(); VfatCleanup ();
DestroyProgressBar (ProgressBar);
ProgressBar = NULL;
DPRINT ("VfatFormat() status 0x%.08x\n", Status);
return Status; return Status;
} }

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.14 2003/11/14 17:13:33 weiden Exp $ # $Id: makefile,v 1.15 2004/02/23 11:58:27 ekohl Exp $
PATH_TO_TOP = ../../.. PATH_TO_TOP = ../../..
@ -18,9 +18,9 @@ TARGET_INSTALLDIR = system32
TARGET_CFLAGS = -D__NTAPP__ -I$(PATH_TO_TOP)/lib/zlib -Wall -Werror -Wno-format TARGET_CFLAGS = -D__NTAPP__ -I$(PATH_TO_TOP)/lib/zlib -Wall -Werror -Wno-format
TARGET_OBJECTS = $(TARGET_NAME).o bootsup.o cabinet.o console.o drivesup.o \ TARGET_OBJECTS = bootsup.o cabinet.o console.o drivesup.o \
filequeue.o filesup.o format.o fslist.o infcache.o \ filequeue.o filesup.o format.o fslist.o infcache.o \
inicache.o partlist.o progress.o registry.o inicache.o partlist.o progress.o registry.o usetup.o
include $(PATH_TO_TOP)/rules.mak include $(PATH_TO_TOP)/rules.mak

View file

@ -12,7 +12,7 @@
static VOID static VOID
DrawBorder(PPROGRESS Bar) DrawBorder(PPROGRESSBAR Bar)
{ {
COORD coPos; COORD coPos;
ULONG Written; ULONG Written;
@ -86,7 +86,7 @@ DrawBorder(PPROGRESS Bar)
static VOID static VOID
DrawProgressBar(PPROGRESS Bar) DrawProgressBar(PPROGRESSBAR Bar)
{ {
CHAR TextBuffer[8]; CHAR TextBuffer[8];
COORD coPos; COORD coPos;
@ -122,17 +122,17 @@ DrawProgressBar(PPROGRESS Bar)
PPROGRESS PPROGRESSBAR
CreateProgressBar(SHORT Left, CreateProgressBar(SHORT Left,
SHORT Top, SHORT Top,
SHORT Right, SHORT Right,
SHORT Bottom) SHORT Bottom)
{ {
PPROGRESS Bar; PPROGRESSBAR Bar;
Bar = (PPROGRESS)RtlAllocateHeap(ProcessHeap, Bar = (PPROGRESSBAR)RtlAllocateHeap(ProcessHeap,
0, 0,
sizeof(PROGRESS)); sizeof(PROGRESSBAR));
if (Bar == NULL) if (Bar == NULL)
return(NULL); return(NULL);
@ -156,7 +156,7 @@ CreateProgressBar(SHORT Left,
VOID VOID
DestroyProgressBar(PPROGRESS Bar) DestroyProgressBar(PPROGRESSBAR Bar)
{ {
RtlFreeHeap(ProcessHeap, RtlFreeHeap(ProcessHeap,
0, 0,
@ -164,7 +164,7 @@ DestroyProgressBar(PPROGRESS Bar)
} }
VOID VOID
ProgressSetStepCount(PPROGRESS Bar, ProgressSetStepCount(PPROGRESSBAR Bar,
ULONG StepCount) ULONG StepCount)
{ {
Bar->CurrentStep = 0; Bar->CurrentStep = 0;
@ -175,7 +175,7 @@ ProgressSetStepCount(PPROGRESS Bar,
VOID VOID
ProgressNextStep(PPROGRESS Bar) ProgressNextStep(PPROGRESSBAR Bar)
{ {
CHAR TextBuffer[8]; CHAR TextBuffer[8];
COORD coPos; COORD coPos;
@ -243,4 +243,74 @@ ProgressNextStep(PPROGRESS Bar)
} }
} }
VOID
ProgressSetStep (PPROGRESSBAR Bar,
ULONG Step)
{
CHAR TextBuffer[8];
COORD coPos;
ULONG Written;
ULONG NewPercent;
ULONG NewPos;
if (Step > Bar->StepCount)
return;
Bar->CurrentStep = Step;
/* Calculate new percentage */
NewPercent = (ULONG)(((100.0 * (float)Bar->CurrentStep) / (float)Bar->StepCount) + 0.5);
/* Redraw precentage if changed */
if (Bar->Percent != NewPercent)
{
Bar->Percent = NewPercent;
sprintf(TextBuffer, "%-3lu%%", Bar->Percent);
coPos.X = Bar->Left + (Bar->Width - 2) / 2;
coPos.Y = Bar->Top;
WriteConsoleOutputCharacters(TextBuffer,
4,
coPos);
}
/* Calculate bar position */
NewPos = (ULONG)((((float)(Bar->Width - 2) * 2.0 * (float)Bar->CurrentStep) / (float)Bar->StepCount) + 0.5);
/* Redraw bar if changed */
if (Bar->Pos != NewPos)
{
Bar->Pos = NewPos;
for (coPos.Y = Bar->Top + 2; coPos.Y <= Bar->Bottom - 1; coPos.Y++)
{
coPos.X = Bar->Left + 1;
FillConsoleOutputCharacter(0xDB,
Bar->Pos / 2,
coPos,
&Written);
coPos.X += Bar->Pos/2;
if (NewPos & 1)
{
FillConsoleOutputCharacter(0xDD,
1,
coPos,
&Written);
coPos.X++;
}
if (coPos.X <= Bar->Right - 1)
{
FillConsoleOutputCharacter(' ',
Bar->Right - coPos.X,
coPos,
&Written);
}
}
}
}
/* EOF */ /* EOF */

View file

@ -16,7 +16,7 @@
* 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: progress.h,v 1.2 2003/02/27 14:42:43 ekohl Exp $ /* $Id: progress.h,v 1.3 2004/02/23 11:58:27 ekohl Exp $
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS text-mode setup * PROJECT: ReactOS text-mode setup
* FILE: subsys/system/usetup/partlist.h * FILE: subsys/system/usetup/partlist.h
@ -42,25 +42,29 @@ typedef struct _PROGRESS
ULONG StepCount; ULONG StepCount;
ULONG CurrentStep; ULONG CurrentStep;
} PROGRESS, *PPROGRESS; } PROGRESSBAR, *PPROGRESSBAR;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
PPROGRESS PPROGRESSBAR
CreateProgressBar(SHORT Left, CreateProgressBar(SHORT Left,
SHORT Top, SHORT Top,
SHORT Right, SHORT Right,
SHORT Bottom); SHORT Bottom);
VOID VOID
DestroyProgressBar(PPROGRESS Bar); DestroyProgressBar(PPROGRESSBAR Bar);
VOID VOID
ProgressSetStepCount(PPROGRESS Bar, ProgressSetStepCount(PPROGRESSBAR Bar,
ULONG StepCount); ULONG StepCount);
VOID VOID
ProgressNextStep(PPROGRESS Bar); ProgressNextStep(PPROGRESSBAR Bar);
VOID
ProgressSetStep (PPROGRESSBAR Bar,
ULONG Step);
#endif /* __PROGRESS_H__ */ #endif /* __PROGRESS_H__ */

View file

@ -1,6 +1,6 @@
/* /*
* ReactOS kernel * ReactOS kernel
* Copyright (C) 2002, 2003 ReactOS Team * Copyright (C) 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
@ -84,7 +84,7 @@ typedef struct _COPYCONTEXT
{ {
ULONG TotalOperations; ULONG TotalOperations;
ULONG CompletedOperations; ULONG CompletedOperations;
PPROGRESS ProgressBar; PPROGRESSBAR ProgressBar;
} COPYCONTEXT, *PCOPYCONTEXT; } COPYCONTEXT, *PCOPYCONTEXT;
@ -492,6 +492,7 @@ CheckUnattendedSetup()
InfCloseFile(UnattendInf); InfCloseFile(UnattendInf);
return; return;
} }
/* Get pointer 'InstallationDirectory' key */ /* Get pointer 'InstallationDirectory' key */
if (!InfGetData(&Context, NULL, &Value)) if (!InfGetData(&Context, NULL, &Value))
{ {
@ -688,19 +689,15 @@ IntroPage(PINPUT_RECORD Ir)
SetTextXY(6, 12, "computer and prepares the second part of the setup."); SetTextXY(6, 12, "computer and prepares the second part of the setup.");
SetTextXY(8, 15, "\x07 Press ENTER to install ReactOS."); SetTextXY(8, 15, "\x07 Press ENTER to install ReactOS.");
SetTextXY(8, 17, "\x07 Press E to start the emergency console."); SetTextXY(8, 17, "\x07 Press E to start the emergency console.");
SetTextXY(8, 19, "\x07 Press R to repair ReactOS."); SetTextXY(8, 19, "\x07 Press R to repair ReactOS.");
SetTextXY(8, 21, "\x07 Press F3 to quit without installing ReactOS."); SetTextXY(8, 21, "\x07 Press F3 to quit without installing ReactOS.");
SetStatusText(" ENTER = Continue F3 = Quit"); SetStatusText(" ENTER = Continue F3 = Quit");
if (IsUnattendedSetup) if (IsUnattendedSetup)
{ {
return(INSTALL_INTRO_PAGE); return INSTALL_INTRO_PAGE;
} }
while(TRUE) while(TRUE)
@ -711,24 +708,24 @@ IntroPage(PINPUT_RECORD Ir)
(Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */ (Ir->Event.KeyEvent.wVirtualKeyCode == VK_F3)) /* F3 */
{ {
if (ConfirmQuit(Ir) == TRUE) if (ConfirmQuit(Ir) == TRUE)
return(QUIT_PAGE); return QUIT_PAGE;
break; break;
} }
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */ else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{ {
return(INSTALL_INTRO_PAGE); return INSTALL_INTRO_PAGE;
} }
else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'E') /* E */ else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'E') /* E */
{ {
return(EMERGENCY_INTRO_PAGE); return EMERGENCY_INTRO_PAGE;
} }
else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'R') /* R */ else if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'R') /* R */
{ {
return(REPAIR_INTRO_PAGE); return REPAIR_INTRO_PAGE;
} }
} }
return(INTRO_PAGE); return INTRO_PAGE;
} }
@ -1930,8 +1927,8 @@ FormatPartitionPage (PINPUT_RECORD Ir)
wcscpy (PathBuffer, SourceRootPath.Buffer); wcscpy (PathBuffer, SourceRootPath.Buffer);
wcscat (PathBuffer, L"\\loader\\fat32.bin"); wcscat (PathBuffer, L"\\loader\\fat32.bin");
DPRINT1 ("Install FAT32 bootcode: %S ==> %S\n", PathBuffer, DPRINT ("Install FAT32 bootcode: %S ==> %S\n", PathBuffer,
DestinationRootPath.Buffer); DestinationRootPath.Buffer);
Status = InstallFat32BootCodeToDisk (PathBuffer, Status = InstallFat32BootCodeToDisk (PathBuffer,
DestinationRootPath.Buffer); DestinationRootPath.Buffer);
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
@ -1946,8 +1943,8 @@ FormatPartitionPage (PINPUT_RECORD Ir)
wcscpy (PathBuffer, SourceRootPath.Buffer); wcscpy (PathBuffer, SourceRootPath.Buffer);
wcscat (PathBuffer, L"\\loader\\fat.bin"); wcscat (PathBuffer, L"\\loader\\fat.bin");
DPRINT1 ("Install FAT bootcode: %S ==> %S\n", PathBuffer, DPRINT ("Install FAT bootcode: %S ==> %S\n", PathBuffer,
DestinationRootPath.Buffer); DestinationRootPath.Buffer);
Status = InstallFat16BootCodeToDisk (PathBuffer, Status = InstallFat16BootCodeToDisk (PathBuffer,
DestinationRootPath.Buffer); DestinationRootPath.Buffer);
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
@ -3334,7 +3331,6 @@ BootLoaderPage(PINPUT_RECORD Ir)
} }
static PAGE_NUMBER static PAGE_NUMBER
QuitPage(PINPUT_RECORD Ir) QuitPage(PINPUT_RECORD Ir)
{ {
@ -3534,9 +3530,6 @@ NtProcessStartup(PPEB Peb)
Page = RepairIntroPage(&Ir); Page = RepairIntroPage(&Ir);
break; break;
case REBOOT_PAGE:
break;
/* Emergency pages */ /* Emergency pages */
case EMERGENCY_INTRO_PAGE: case EMERGENCY_INTRO_PAGE:
@ -3555,6 +3548,9 @@ NtProcessStartup(PPEB Peb)
case QUIT_PAGE: case QUIT_PAGE:
Page = QuitPage(&Ir); Page = QuitPage(&Ir);
break; break;
case REBOOT_PAGE:
break;
} }
} }