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 BOOLEAN LogicalPartition
;
69 /* Partition is partitioned disk space */
70 BOOLEAN IsPartitioned
;
72 /* Partition is new, table does not exist on disk yet */
75 /* Partition was created automatically */
78 FORMATSTATE FormatState
;
80 /* Partition must be checked */
83 struct _FILE_SYSTEM_ITEM
*FileSystem
;
84 } PARTENTRY
, *PPARTENTRY
;
87 typedef struct _BIOSDISKENTRY
94 CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
;
95 CM_INT13_DRIVE_PARAMETER Int13DiskData
;
96 } BIOSDISKENTRY
, *PBIOSDISKENTRY
;
99 typedef struct _DISKENTRY
101 LIST_ENTRY ListEntry
;
104 ULONG TracksPerCylinder
;
105 ULONG SectorsPerTrack
;
106 ULONG BytesPerSector
;
108 ULARGE_INTEGER SectorCount
;
109 ULONG SectorAlignment
;
110 ULONG CylinderAlignment
;
113 ULONG BiosDiskNumber
;
122 /* Has the partition list been modified? */
126 BOOLEAN NoMbr
; /* MBR is absent */
128 UNICODE_STRING DriverName
;
130 PDRIVE_LAYOUT_INFORMATION LayoutBuffer
;
132 PPARTENTRY ExtendedPartition
;
134 LIST_ENTRY PrimaryPartListHead
;
135 LIST_ENTRY LogicalPartListHead
;
137 } DISKENTRY
, *PDISKENTRY
;
140 typedef struct _PARTLIST
150 PDISKENTRY CurrentDisk
;
151 PPARTENTRY CurrentPartition
;
153 /* The system disk and partition where the boot manager resides */
154 PDISKENTRY SystemDisk
;
155 PPARTENTRY SystemPartition
;
157 * The original system disk and partition in case we are redefining them
158 * because we do not have write support on them.
159 * Please not that this is partly a HACK and MUST NEVER happen on
160 * architectures where real system partitions are mandatory (because then
161 * they are formatted in FAT FS and we support write operation on them).
163 PDISKENTRY OriginalSystemDisk
;
164 PPARTENTRY OriginalSystemPartition
;
167 PPARTENTRY TempPartition
;
168 FORMATMACHINESTATE FormatState
;
170 LIST_ENTRY DiskListHead
;
171 LIST_ENTRY BiosDiskListHead
;
173 } PARTLIST
, *PPARTLIST
;
175 #define PARTITION_TBL_SIZE 4
177 #include <pshpack1.h>
179 typedef struct _PARTITION
181 unsigned char BootFlags
; /* bootable? 0=no, 128=yes */
182 unsigned char StartingHead
; /* beginning head number */
183 unsigned char StartingSector
; /* beginning sector number */
184 unsigned char StartingCylinder
; /* 10 bit nmbr, with high 2 bits put in begsect */
185 unsigned char PartitionType
; /* Operating System type indicator code */
186 unsigned char EndingHead
; /* ending head number */
187 unsigned char EndingSector
; /* ending sector number */
188 unsigned char EndingCylinder
; /* also a 10 bit nmbr, with same high 2 bit trick */
189 unsigned int StartingBlock
; /* first sector relative to start of disk */
190 unsigned int SectorCount
; /* number of sectors in partition */
191 } PARTITION
, *PPARTITION
;
193 typedef struct _PARTITION_SECTOR
195 UCHAR BootCode
[440]; /* 0x000 */
196 ULONG Signature
; /* 0x1B8 */
197 UCHAR Reserved
[2]; /* 0x1BC */
198 PARTITION Partition
[PARTITION_TBL_SIZE
]; /* 0x1BE */
199 USHORT Magic
; /* 0x1FE */
200 } PARTITION_SECTOR
, *PPARTITION_SECTOR
;
206 LIST_ENTRY ListEntry
;
210 } BIOS_DISK
, *PBIOS_DISK
;
220 DestroyPartitionList(
231 ULONG PartitionNumber
);
234 SetMountedDeviceValues(
238 ScrollDownPartitionList(
242 ScrollUpPartitionList(
246 CreatePrimaryPartition(
248 ULONGLONG SectorCount
,
252 CreateExtendedPartition(
254 ULONGLONG SectorCount
);
257 CreateLogicalPartition(
259 ULONGLONG SectorCount
,
263 DeleteCurrentPartition(
267 CheckActiveSystemPartition(
269 IN PFILE_SYSTEM_LIST FileSystemList
);
272 WritePartitionsToDisk(
276 PrimaryPartitionCreationChecks(
280 ExtendedPartitionCreationChecks(
284 LogicalPartitionCreationChecks(
288 GetNextUnformattedPartition(
290 OUT PDISKENTRY
*pDiskEntry
,
291 OUT PPARTENTRY
*pPartEntry
);
294 GetNextUncheckedPartition(
296 OUT PDISKENTRY
*pDiskEntry
,
297 OUT PPARTENTRY
*pPartEntry
);
300 GetPartTypeStringFromPartitionType(