1 /* 2 * ReactOS kernel 3 * Copyright (C) 2002, 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 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. 18 */ 19 /* COPYRIGHT: See COPYING in the top level directory 20 * PROJECT: ReactOS text-mode setup 21 * FILE: subsys/system/usetup/partlist.h 22 * PURPOSE: Partition list functions 23 * PROGRAMMER: Eric Kohl 24 */ 25 26 #pragma once 27 28 /* We have to define it there, because it is not in the MS DDK */ 29 #define PARTITION_EXT2 0x83 30 31 typedef enum _FORMATSTATE 32 { 33 Unformatted, 34 UnformattedOrDamaged, 35 UnknownFormat, 36 Preformatted, 37 Formatted 38 } FORMATSTATE, *PFORMATSTATE; 39 40 41 typedef struct _PARTENTRY 42 { 43 LIST_ENTRY ListEntry; 44 45 CHAR DriveLetter[4]; 46 CHAR VolumeLabel[17]; 47 CHAR FileSystemName[9]; 48 49 /* Partition is unused disk space */ 50 BOOLEAN Unpartitioned; 51 52 /* Partition is new. Table does not exist on disk yet */ 53 BOOLEAN New; 54 55 /* Partition was created automatically. */ 56 BOOLEAN AutoCreate; 57 58 FORMATSTATE FormatState; 59 60 /* 61 * Raw offset and length of the unpartitioned disk space. 62 * Includes the leading, not yet existing, partition table. 63 */ 64 ULONGLONG UnpartitionedOffset; 65 ULONGLONG UnpartitionedLength; 66 67 PARTITION_INFORMATION PartInfo[4]; 68 69 } PARTENTRY, *PPARTENTRY; 70 71 72 typedef struct _BIOSDISKENTRY 73 { 74 LIST_ENTRY ListEntry; 75 ULONG DiskNumber; 76 ULONG Signature; 77 ULONG Checksum; 78 BOOLEAN Recognized; 79 CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry; 80 CM_INT13_DRIVE_PARAMETER Int13DiskData; 81 } BIOSDISKENTRY, *PBIOSDISKENTRY; 82 83 84 typedef struct _DISKENTRY 85 { 86 LIST_ENTRY ListEntry; 87 88 ULONGLONG Cylinders; 89 ULONGLONG TracksPerCylinder; 90 ULONGLONG SectorsPerTrack; 91 ULONGLONG BytesPerSector; 92 93 ULONGLONG DiskSize; 94 ULONGLONG CylinderSize; 95 ULONGLONG TrackSize; 96 97 BOOLEAN BiosFound; 98 ULONG BiosDiskNumber; 99 ULONG Signature; 100 ULONG Checksum; 101 102 ULONG DiskNumber; 103 USHORT Port; 104 USHORT Bus; 105 USHORT Id; 106 107 /* Has the partition list been modified? */ 108 BOOLEAN Modified; 109 110 BOOLEAN NewDisk; 111 BOOLEAN NoMbr; /* MBR is absent */ 112 113 UNICODE_STRING DriverName; 114 115 LIST_ENTRY PartListHead; 116 117 } DISKENTRY, *PDISKENTRY; 118 119 120 typedef struct _PARTLIST 121 { 122 SHORT Left; 123 SHORT Top; 124 SHORT Right; 125 SHORT Bottom; 126 127 SHORT Line; 128 SHORT Offset; 129 130 ULONG TopDisk; 131 ULONG TopPartition; 132 133 PDISKENTRY CurrentDisk; 134 PPARTENTRY CurrentPartition; 135 UCHAR CurrentPartitionNumber; 136 137 PDISKENTRY ActiveBootDisk; 138 PPARTENTRY ActiveBootPartition; 139 UCHAR ActiveBootPartitionNumber; 140 141 LIST_ENTRY DiskListHead; 142 LIST_ENTRY BiosDiskListHead; 143 144 } PARTLIST, *PPARTLIST; 145 146 #define PARTITION_TBL_SIZE 4 147 148 #include <pshpack1.h> 149 150 typedef struct _PARTITION 151 { 152 unsigned char BootFlags; /* bootable? 0=no, 128=yes */ 153 unsigned char StartingHead; /* beginning head number */ 154 unsigned char StartingSector; /* beginning sector number */ 155 unsigned char StartingCylinder; /* 10 bit nmbr, with high 2 bits put in begsect */ 156 unsigned char PartitionType; /* Operating System type indicator code */ 157 unsigned char EndingHead; /* ending head number */ 158 unsigned char EndingSector; /* ending sector number */ 159 unsigned char EndingCylinder; /* also a 10 bit nmbr, with same high 2 bit trick */ 160 unsigned int StartingBlock; /* first sector relative to start of disk */ 161 unsigned int SectorCount; /* number of sectors in partition */ 162 } PARTITION, *PPARTITION; 163 164 typedef struct _PARTITION_SECTOR 165 { 166 UCHAR BootCode[440]; /* 0x000 */ 167 ULONG Signature; /* 0x1B8 */ 168 UCHAR Reserved[2]; /* 0x1BC */ 169 PARTITION Partition[PARTITION_TBL_SIZE]; /* 0x1BE */ 170 USHORT Magic; /* 0x1FE */ 171 } PARTITION_SECTOR, *PPARTITION_SECTOR; 172 173 #include <poppack.h> 174 175 typedef struct 176 { 177 LIST_ENTRY ListEntry; 178 ULONG DiskNumber; 179 ULONG Idendifier; 180 ULONG Signature; 181 } BIOS_DISK, *PBIOS_DISK; 182 183 PPARTLIST 184 CreatePartitionList (SHORT Left, 185 SHORT Top, 186 SHORT Right, 187 SHORT Bottom); 188 189 VOID 190 DestroyPartitionList (PPARTLIST List); 191 192 VOID 193 DrawPartitionList (PPARTLIST List); 194 195 DWORD 196 SelectPartition(PPARTLIST List, ULONG DiskNumber, ULONG PartitionNumber); 197 198 BOOL 199 SetMountedDeviceValues(PPARTLIST List); 200 201 VOID 202 ScrollDownPartitionList (PPARTLIST List); 203 204 VOID 205 ScrollUpPartitionList (PPARTLIST List); 206 207 VOID 208 CreateNewPartition (PPARTLIST List, 209 ULONGLONG PartitionSize, 210 BOOLEAN AutoCreate); 211 212 VOID 213 DeleteCurrentPartition (PPARTLIST List); 214 215 VOID 216 CheckActiveBootPartition (PPARTLIST List); 217 218 BOOLEAN 219 CheckForLinuxFdiskPartitions (PPARTLIST List); 220 221 BOOLEAN 222 WritePartitionsToDisk (PPARTLIST List); 223 224 /* EOF */ 225