3 * Copyright (C) 2002, 2003 ReactOS Team
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.
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.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 /* COPYRIGHT: See COPYING in the top level directory
20 * PROJECT: ReactOS text-mode setup
21 * FILE: base/setup/usetup/partlist.h
22 * PURPOSE: Partition list functions
23 * PROGRAMMER: Eric Kohl
28 typedef enum _FORMATSTATE
35 } FORMATSTATE
, *PFORMATSTATE
;
37 typedef enum _FORMATMACHINESTATE
40 FormatSystemPartition
,
41 FormatInstallPartition
,
45 CheckInstallPartition
,
48 } FORMATMACHINESTATE
, *PFORMATMACHINESTATE
;
50 typedef struct _PARTENTRY
54 struct _DISKENTRY
*DiskEntry
;
56 ULARGE_INTEGER StartSector
;
57 ULARGE_INTEGER SectorCount
;
59 BOOLEAN BootIndicator
;
62 ULONG PartitionNumber
;
67 CHAR FileSystemName
[9];
69 BOOLEAN LogicalPartition
;
71 /* Partition is partitioned disk space */
72 BOOLEAN IsPartitioned
;
74 /* Partition is new, table does not exist on disk yet */
77 /* Partition was created automatically */
80 FORMATSTATE FormatState
;
82 /* Partition must be checked */
85 struct _FILE_SYSTEM_ITEM
*FileSystem
;
86 } PARTENTRY
, *PPARTENTRY
;
89 typedef struct _BIOSDISKENTRY
96 CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
;
97 CM_INT13_DRIVE_PARAMETER Int13DiskData
;
98 } BIOSDISKENTRY
, *PBIOSDISKENTRY
;
101 typedef struct _DISKENTRY
103 LIST_ENTRY ListEntry
;
106 ULONG TracksPerCylinder
;
107 ULONG SectorsPerTrack
;
108 ULONG BytesPerSector
;
110 ULARGE_INTEGER SectorCount
;
111 ULONG SectorAlignment
;
112 ULONG CylinderAlignment
;
115 ULONG BiosDiskNumber
;
124 /* Has the partition list been modified? */
128 BOOLEAN NoMbr
; /* MBR is absent */
130 UNICODE_STRING DriverName
;
132 PDRIVE_LAYOUT_INFORMATION LayoutBuffer
;
134 PPARTENTRY ExtendedPartition
;
136 LIST_ENTRY PrimaryPartListHead
;
137 LIST_ENTRY LogicalPartListHead
;
139 } DISKENTRY
, *PDISKENTRY
;
142 typedef struct _PARTLIST
152 PDISKENTRY CurrentDisk
;
153 PPARTENTRY CurrentPartition
;
155 /* The system disk and partition where the boot manager resides */
156 PDISKENTRY SystemDisk
;
157 PPARTENTRY SystemPartition
;
160 PPARTENTRY TempPartition
;
161 FORMATMACHINESTATE FormatState
;
163 LIST_ENTRY DiskListHead
;
164 LIST_ENTRY BiosDiskListHead
;
166 } PARTLIST
, *PPARTLIST
;
168 #define PARTITION_TBL_SIZE 4
170 #include <pshpack1.h>
172 typedef struct _PARTITION
174 unsigned char BootFlags
; /* bootable? 0=no, 128=yes */
175 unsigned char StartingHead
; /* beginning head number */
176 unsigned char StartingSector
; /* beginning sector number */
177 unsigned char StartingCylinder
; /* 10 bit nmbr, with high 2 bits put in begsect */
178 unsigned char PartitionType
; /* Operating System type indicator code */
179 unsigned char EndingHead
; /* ending head number */
180 unsigned char EndingSector
; /* ending sector number */
181 unsigned char EndingCylinder
; /* also a 10 bit nmbr, with same high 2 bit trick */
182 unsigned int StartingBlock
; /* first sector relative to start of disk */
183 unsigned int SectorCount
; /* number of sectors in partition */
184 } PARTITION
, *PPARTITION
;
186 typedef struct _PARTITION_SECTOR
188 UCHAR BootCode
[440]; /* 0x000 */
189 ULONG Signature
; /* 0x1B8 */
190 UCHAR Reserved
[2]; /* 0x1BC */
191 PARTITION Partition
[PARTITION_TBL_SIZE
]; /* 0x1BE */
192 USHORT Magic
; /* 0x1FE */
193 } PARTITION_SECTOR
, *PPARTITION_SECTOR
;
199 LIST_ENTRY ListEntry
;
203 } BIOS_DISK
, *PBIOS_DISK
;
213 DestroyPartitionList(
224 ULONG PartitionNumber
);
227 SetMountedDeviceValues(
231 ScrollDownPartitionList(
235 ScrollUpPartitionList(
239 CreatePrimaryPartition(
241 ULONGLONG SectorCount
,
245 CreateExtendedPartition(
247 ULONGLONG SectorCount
);
250 CreateLogicalPartition(
252 ULONGLONG SectorCount
,
256 DeleteCurrentPartition(
260 CheckActiveSystemPartition(
264 WritePartitionsToDisk(
268 PrimaryPartitionCreationChecks(
272 ExtendedPartitionCreationChecks(
276 LogicalPartitionCreationChecks(
280 GetNextUnformattedPartition(
282 OUT PDISKENTRY
*pDiskEntry
,
283 OUT PPARTENTRY
*pPartEntry
);
286 GetNextUncheckedPartition(
288 OUT PDISKENTRY
*pDiskEntry
,
289 OUT PPARTENTRY
*pPartEntry
);
292 GetPartTypeStringFromPartitionType(