- Do only allow to install reactos on disks which are visible by the bios.
[reactos.git] / reactos / subsys / system / usetup / format.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2003 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id$
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS text-mode setup
22 * FILE: subsys/system/usetup/format.c
23 * PURPOSE: Filesystem format support functions
24 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
25 */
26
27 /* INCLUDES *****************************************************************/
28
29 #include <usetup.h>
30
31 #define NDEBUG
32 #include <debug.h>
33
34 PPROGRESSBAR ProgressBar = NULL;
35
36 /* FUNCTIONS ****************************************************************/
37
38
39 BOOLEAN STDCALL
40 FormatCallback (CALLBACKCOMMAND Command,
41 ULONG Modifier,
42 PVOID Argument)
43 {
44 // DPRINT1 ("FormatCallback() called\n");
45
46 switch (Command)
47 {
48 case PROGRESS:
49 {
50 PULONG Percent;
51
52 Percent = (PULONG)Argument;
53 DPRINT ("%lu percent completed\n", *Percent);
54
55 ProgressSetStep (ProgressBar, *Percent);
56 }
57 break;
58
59 // case OUTPUT:
60 // {
61 // PTEXTOUTPUT Output;
62 // output = (PTEXTOUTPUT) Argument;
63 // fprintf(stdout, "%s", output->Output);
64 // }
65 // break;
66
67 case DONE:
68 {
69 DPRINT ("Done\n");
70 // PBOOLEAN Success;
71 // status = (PBOOLEAN) Argument;
72 // if ( *status == FALSE )
73 // {
74 // wprintf(L"FormatEx was unable to complete successfully.\n\n");
75 // Error = TRUE;
76 // }
77 }
78 break;
79
80 default:
81 DPRINT ("Unknown callback %lu\n", (ULONG)Command);
82 break;
83 }
84
85 // DPRINT1 ("FormatCallback() done\n");
86
87 return TRUE;
88 }
89
90
91 NTSTATUS
92 FormatPartition (PUNICODE_STRING DriveRoot)
93 {
94 NTSTATUS Status;
95 SHORT xScreen;
96 SHORT yScreen;
97
98 GetScreenSize(&xScreen, &yScreen);
99
100 ProgressBar = CreateProgressBar (6,
101 yScreen - 14,
102 xScreen - 7,
103 yScreen - 10,
104 "Setup is formatting your disk");
105
106 ProgressSetStepCount (ProgressBar, 100);
107
108 VfatInitialize ();
109
110 Status = VfatFormat (DriveRoot,
111 0, /* MediaFlag */
112 NULL, /* Label */
113 TRUE, /* QuickFormat */
114 0, /* ClusterSize */
115 (PFMIFSCALLBACK)FormatCallback); /* Callback */
116
117 VfatCleanup ();
118
119 DestroyProgressBar (ProgressBar);
120 ProgressBar = NULL;
121
122 DPRINT ("VfatFormat() status 0x%.08x\n", Status);
123
124 return Status;
125 }
126
127 /* EOF */