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
;
159 * The original system disk and partition in case we are redefining them
160 * because we do not have write support on them.
161 * Please not that this is partly a HACK and MUST NEVER happen on
162 * architectures where real system partitions are mandatory (because then
163 * they are formatted in FAT FS and we support write operation on them).
165 PDISKENTRY OriginalSystemDisk
;
166 PPARTENTRY OriginalSystemPartition
;
169 PPARTENTRY TempPartition
;
170 FORMATMACHINESTATE FormatState
;
172 LIST_ENTRY DiskListHead
;
173 LIST_ENTRY BiosDiskListHead
;
175 } PARTLIST
, *PPARTLIST
;
177 #define PARTITION_TBL_SIZE 4
179 #include <pshpack1.h>
181 typedef struct _PARTITION
183 unsigned char BootFlags
; /* bootable? 0=no, 128=yes */
184 unsigned char StartingHead
; /* beginning head number */
185 unsigned char StartingSector
; /* beginning sector number */
186 unsigned char StartingCylinder
; /* 10 bit nmbr, with high 2 bits put in begsect */
187 unsigned char PartitionType
; /* Operating System type indicator code */
188 unsigned char EndingHead
; /* ending head number */
189 unsigned char EndingSector
; /* ending sector number */
190 unsigned char EndingCylinder
; /* also a 10 bit nmbr, with same high 2 bit trick */
191 unsigned int StartingBlock
; /* first sector relative to start of disk */
192 unsigned int SectorCount
; /* number of sectors in partition */
193 } PARTITION
, *PPARTITION
;
195 typedef struct _PARTITION_SECTOR
197 UCHAR BootCode
[440]; /* 0x000 */
198 ULONG Signature
; /* 0x1B8 */
199 UCHAR Reserved
[2]; /* 0x1BC */
200 PARTITION Partition
[PARTITION_TBL_SIZE
]; /* 0x1BE */
201 USHORT Magic
; /* 0x1FE */
202 } PARTITION_SECTOR
, *PPARTITION_SECTOR
;
208 LIST_ENTRY ListEntry
;
212 } BIOS_DISK
, *PBIOS_DISK
;
222 DestroyPartitionList(
233 ULONG PartitionNumber
);
236 SetMountedDeviceValues(
240 ScrollDownPartitionList(
244 ScrollUpPartitionList(
248 CreatePrimaryPartition(
250 ULONGLONG SectorCount
,
254 CreateExtendedPartition(
256 ULONGLONG SectorCount
);
259 CreateLogicalPartition(
261 ULONGLONG SectorCount
,
265 DeleteCurrentPartition(
269 CheckActiveSystemPartition(
271 IN PFILE_SYSTEM_LIST FileSystemList
);
274 WritePartitionsToDisk(
278 PrimaryPartitionCreationChecks(
282 ExtendedPartitionCreationChecks(
286 LogicalPartitionCreationChecks(
290 GetNextUnformattedPartition(
292 OUT PDISKENTRY
*pDiskEntry
,
293 OUT PPARTENTRY
*pPartEntry
);
296 GetNextUncheckedPartition(
298 OUT PDISKENTRY
*pDiskEntry
,
299 OUT PPARTENTRY
*pPartEntry
);
302 GetPartTypeStringFromPartitionType(