2002-10-18 20:04:00 +00:00
/*
2002-10-29 18:40:02 +00:00
* ReactOS kernel
2003-08-04 15:54:05 +00:00
* Copyright ( C ) 2002 , 2003 ReactOS Team
2002-10-29 18:40:02 +00:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
2009-10-27 10:34:16 +00:00
* You should have received a copy of the GNU General Public License along
* with this program ; if not , write to the Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA .
2002-10-29 18:40:02 +00:00
*/
2008-02-11 16:52:49 +00:00
/* COPYRIGHT: See COPYING in the top level directory
2002-10-29 18:40:02 +00:00
* PROJECT : ReactOS text - mode setup
2015-09-13 16:40:36 +00:00
* FILE : base / setup / usetup / partlist . h
2002-10-29 18:40:02 +00:00
* PURPOSE : Partition list functions
* PROGRAMMER : Eric Kohl
2002-10-18 20:04:00 +00:00
*/
2010-02-26 11:43:19 +00:00
# pragma once
2002-10-18 20:04:00 +00:00
2003-08-25 11:56:07 +00:00
typedef enum _FORMATSTATE
{
2014-05-04 22:03:00 +00:00
Unformatted ,
UnformattedOrDamaged ,
UnknownFormat ,
Preformatted ,
Formatted
2003-08-25 11:56:07 +00:00
} FORMATSTATE , * PFORMATSTATE ;
2015-06-12 21:51:57 +00:00
typedef enum _FORMATMACHINESTATE
{
Start ,
FormatSystemPartition ,
FormatInstallPartition ,
FormatOtherPartition ,
FormatDone ,
CheckSystemPartition ,
CheckInstallPartition ,
CheckOtherPartition ,
CheckDone
} FORMATMACHINESTATE , * PFORMATMACHINESTATE ;
2002-10-18 20:04:00 +00:00
typedef struct _PARTENTRY
{
2014-05-04 22:03:00 +00:00
LIST_ENTRY ListEntry ;
2002-11-02 23:17:06 +00:00
2017-05-13 16:40:30 +00:00
/* The disk this partition belongs to */
2014-05-18 15:14:24 +00:00
struct _DISKENTRY * DiskEntry ;
2017-05-13 16:40:30 +00:00
/* Partition geometry */
2014-05-18 15:14:24 +00:00
ULARGE_INTEGER StartSector ;
ULARGE_INTEGER SectorCount ;
BOOLEAN BootIndicator ;
UCHAR PartitionType ;
ULONG HiddenSectors ;
2017-05-13 16:40:30 +00:00
ULONG PartitionNumber ; /* Enumerated partition number (primary partitions first -- excluding the extended partition container --, then the logical partitions) */
ULONG PartitionIndex ; /* Index in the LayoutBuffer->PartitionEntry[] cached array of the corresponding DiskEntry */
2014-05-18 15:14:24 +00:00
CHAR DriveLetter ;
2002-11-13 18:25:18 +00:00
2014-05-22 14:55:04 +00:00
BOOLEAN LogicalPartition ;
2014-05-21 20:20:18 +00:00
2014-05-18 15:14:24 +00:00
/* Partition is partitioned disk space */
BOOLEAN IsPartitioned ;
2003-08-03 12:20:22 +00:00
2016-02-28 15:25:22 +00:00
/* Partition is new, table does not exist on disk yet */
2015-01-04 13:53:45 +00:00
BOOLEAN New ;
2003-08-05 20:39:24 +00:00
2016-02-28 15:25:22 +00:00
/* Partition was created automatically */
2014-05-04 22:03:00 +00:00
BOOLEAN AutoCreate ;
2003-08-09 16:32:26 +00:00
2015-06-12 21:51:57 +00:00
/* Partition must be checked */
BOOLEAN NeedsCheck ;
2017-05-13 16:40:30 +00:00
FORMATSTATE FormatState ;
2015-06-12 21:51:57 +00:00
struct _FILE_SYSTEM_ITEM * FileSystem ;
2017-05-13 16:40:30 +00:00
2002-10-18 20:04:00 +00:00
} PARTENTRY , * PPARTENTRY ;
2003-08-02 16:49:36 +00:00
2005-09-15 17:19:31 +00:00
typedef struct _BIOSDISKENTRY
{
2014-05-04 22:03:00 +00:00
LIST_ENTRY ListEntry ;
ULONG DiskNumber ;
ULONG Signature ;
ULONG Checksum ;
BOOLEAN Recognized ;
CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry ;
CM_INT13_DRIVE_PARAMETER Int13DiskData ;
2007-10-19 23:21:45 +00:00
} BIOSDISKENTRY , * PBIOSDISKENTRY ;
2005-09-15 17:19:31 +00:00
2002-10-18 20:04:00 +00:00
typedef struct _DISKENTRY
{
2014-05-04 22:03:00 +00:00
LIST_ENTRY ListEntry ;
2003-08-02 16:49:36 +00:00
2017-05-13 16:40:30 +00:00
/* Disk geometry */
2014-05-04 22:03:00 +00:00
ULONGLONG Cylinders ;
2014-05-18 15:14:24 +00:00
ULONG TracksPerCylinder ;
ULONG SectorsPerTrack ;
ULONG BytesPerSector ;
2003-08-03 12:20:22 +00:00
2014-05-18 15:14:24 +00:00
ULARGE_INTEGER SectorCount ;
ULONG SectorAlignment ;
2015-08-09 13:14:00 +00:00
ULONG CylinderAlignment ;
2003-08-03 12:20:22 +00:00
2017-05-13 16:40:30 +00:00
/* BIOS parameters */
2014-05-04 22:03:00 +00:00
BOOLEAN BiosFound ;
ULONG BiosDiskNumber ;
2014-05-18 15:14:24 +00:00
// ULONG Signature;
// ULONG Checksum;
2005-09-15 17:19:31 +00:00
2017-05-13 16:40:30 +00:00
/* SCSI parameters */
2014-05-04 22:03:00 +00:00
ULONG DiskNumber ;
USHORT Port ;
USHORT Bus ;
USHORT Id ;
2002-10-18 20:04:00 +00:00
2014-05-04 22:03:00 +00:00
/* Has the partition list been modified? */
2014-05-18 15:14:24 +00:00
BOOLEAN Dirty ;
2003-08-06 16:37:46 +00:00
2014-05-04 22:03:00 +00:00
BOOLEAN NewDisk ;
2017-05-13 16:40:30 +00:00
BOOLEAN NoMbr ; /* MBR is absent */ // See r40437
2003-08-19 15:54:47 +00:00
2014-05-04 22:03:00 +00:00
UNICODE_STRING DriverName ;
2002-11-28 19:20:38 +00:00
2014-05-18 15:14:24 +00:00
PDRIVE_LAYOUT_INFORMATION LayoutBuffer ;
2017-05-13 16:40:30 +00:00
// TODO: When adding support for GPT disks:
// Use PDRIVE_LAYOUT_INFORMATION_EX which indicates whether
// the disk is MBR, GPT, or unknown (uninitialized).
// Depending on the style, either use the MBR or GPT partition info.
2014-05-18 15:14:24 +00:00
2017-05-13 16:40:30 +00:00
/* Pointer to the unique extended partition on this disk */
2014-05-22 14:55:04 +00:00
PPARTENTRY ExtendedPartition ;
2014-05-18 15:14:24 +00:00
LIST_ENTRY PrimaryPartListHead ;
2014-05-22 14:55:04 +00:00
LIST_ENTRY LogicalPartListHead ;
2002-10-18 20:04:00 +00:00
} DISKENTRY , * PDISKENTRY ;
typedef struct _PARTLIST
{
2017-05-13 16:40:30 +00:00
/* UI stuff */
2014-05-04 22:03:00 +00:00
SHORT Left ;
SHORT Top ;
SHORT Right ;
SHORT Bottom ;
2002-10-18 20:04:00 +00:00
2014-05-04 22:03:00 +00:00
SHORT Line ;
SHORT Offset ;
2002-10-29 18:40:02 +00:00
2017-05-13 16:40:30 +00:00
/*
* NOTE that when CurrentPartition ! = NULL , then CurrentPartition - > DiskEntry
* must be the same as CurrentDisk . We should however keep the two members
* separated as we can have a current ( selected ) disk without any current
* partition , if the former does not contain any .
*/
2014-05-04 22:03:00 +00:00
PDISKENTRY CurrentDisk ;
PPARTENTRY CurrentPartition ;
2002-10-18 20:04:00 +00:00
2017-05-13 16:40:30 +00:00
/*
* The system partition where the boot manager resides .
* The corresponding system disk is obtained via :
* SystemPartition - > DiskEntry .
*/
2016-02-28 15:25:22 +00:00
PPARTENTRY SystemPartition ;
[USETUP]
- bootsup.c/.h, usetup.c: Save the old MBR sector in the system partition (this makes easier to restore the old one).
- fslist.c/.h, usetup.h: Fix header inclusion order.
- partlist.c/.h, usetup.c: On BIOS-PC architectures, the system partition can be formatted in any FS as long as it is the active partition (on the contrary, on architectures where such system partition is required, it is formatted in FAT). We currently do not have write support for all FSes out there (apart for FAT until now), so do a "clever" "trick" to work around this problem: on initialized disks, find the active partition and check its FS. If we support write access to this FS then we're OK, otherwise we change the (active) system partition for the one on which we are going to install ReactOS (which is, by construction, formatted with a FS on which we support write access).
The MBR (resp. the VBR) of the disk (resp. of the system partition) are always saved into files, making easy for people to boot on them (using FreeLdr) or restoring them.
CORE-10898
svn path=/trunk/; revision=70837
2016-03-01 15:00:56 +00:00
/*
2017-05-13 16:40:30 +00:00
* The original system partition in case we are redefining it because
* we do not have write support on it .
* Please note that this is partly a HACK and MUST NEVER happen on
[USETUP]
- bootsup.c/.h, usetup.c: Save the old MBR sector in the system partition (this makes easier to restore the old one).
- fslist.c/.h, usetup.h: Fix header inclusion order.
- partlist.c/.h, usetup.c: On BIOS-PC architectures, the system partition can be formatted in any FS as long as it is the active partition (on the contrary, on architectures where such system partition is required, it is formatted in FAT). We currently do not have write support for all FSes out there (apart for FAT until now), so do a "clever" "trick" to work around this problem: on initialized disks, find the active partition and check its FS. If we support write access to this FS then we're OK, otherwise we change the (active) system partition for the one on which we are going to install ReactOS (which is, by construction, formatted with a FS on which we support write access).
The MBR (resp. the VBR) of the disk (resp. of the system partition) are always saved into files, making easy for people to boot on them (using FreeLdr) or restoring them.
CORE-10898
svn path=/trunk/; revision=70837
2016-03-01 15:00:56 +00:00
* architectures where real system partitions are mandatory ( because then
* they are formatted in FAT FS and we support write operation on them ) .
2017-05-13 16:40:30 +00:00
* The corresponding original system disk is obtained via :
* OriginalSystemPartition - > DiskEntry .
[USETUP]
- bootsup.c/.h, usetup.c: Save the old MBR sector in the system partition (this makes easier to restore the old one).
- fslist.c/.h, usetup.h: Fix header inclusion order.
- partlist.c/.h, usetup.c: On BIOS-PC architectures, the system partition can be formatted in any FS as long as it is the active partition (on the contrary, on architectures where such system partition is required, it is formatted in FAT). We currently do not have write support for all FSes out there (apart for FAT until now), so do a "clever" "trick" to work around this problem: on initialized disks, find the active partition and check its FS. If we support write access to this FS then we're OK, otherwise we change the (active) system partition for the one on which we are going to install ReactOS (which is, by construction, formatted with a FS on which we support write access).
The MBR (resp. the VBR) of the disk (resp. of the system partition) are always saved into files, making easy for people to boot on them (using FreeLdr) or restoring them.
CORE-10898
svn path=/trunk/; revision=70837
2016-03-01 15:00:56 +00:00
*/
PPARTENTRY OriginalSystemPartition ;
2015-06-12 21:51:57 +00:00
PPARTENTRY TempPartition ;
FORMATMACHINESTATE FormatState ;
2003-08-04 15:54:05 +00:00
2014-05-04 22:03:00 +00:00
LIST_ENTRY DiskListHead ;
LIST_ENTRY BiosDiskListHead ;
2002-10-18 20:04:00 +00:00
} PARTLIST , * PPARTLIST ;
2005-09-15 17:19:31 +00:00
# define PARTITION_TBL_SIZE 4
2002-10-18 20:04:00 +00:00
2005-09-15 17:19:31 +00:00
# include <pshpack1.h>
typedef struct _PARTITION
{
2014-05-04 22:03:00 +00:00
unsigned char BootFlags ; /* bootable? 0=no, 128=yes */
unsigned char StartingHead ; /* beginning head number */
unsigned char StartingSector ; /* beginning sector number */
unsigned char StartingCylinder ; /* 10 bit nmbr, with high 2 bits put in begsect */
unsigned char PartitionType ; /* Operating System type indicator code */
unsigned char EndingHead ; /* ending head number */
unsigned char EndingSector ; /* ending sector number */
unsigned char EndingCylinder ; /* also a 10 bit nmbr, with same high 2 bit trick */
unsigned int StartingBlock ; /* first sector relative to start of disk */
unsigned int SectorCount ; /* number of sectors in partition */
2005-09-15 17:19:31 +00:00
} PARTITION , * PPARTITION ;
typedef struct _PARTITION_SECTOR
{
2014-05-04 22:03:00 +00:00
UCHAR BootCode [ 440 ] ; /* 0x000 */
ULONG Signature ; /* 0x1B8 */
UCHAR Reserved [ 2 ] ; /* 0x1BC */
PARTITION Partition [ PARTITION_TBL_SIZE ] ; /* 0x1BE */
USHORT Magic ; /* 0x1FE */
2005-09-15 17:19:31 +00:00
} PARTITION_SECTOR , * PPARTITION_SECTOR ;
# include <poppack.h>
typedef struct
{
2014-05-04 22:03:00 +00:00
LIST_ENTRY ListEntry ;
ULONG DiskNumber ;
2016-11-05 14:55:55 +00:00
ULONG Identifier ;
2014-05-04 22:03:00 +00:00
ULONG Signature ;
2005-09-15 17:19:31 +00:00
} BIOS_DISK , * PBIOS_DISK ;
2002-10-18 20:04:00 +00:00
2017-05-13 16:32:53 +00:00
VOID
GetPartTypeStringFromPartitionType (
IN UCHAR partitionType ,
OUT PCHAR strPartType ,
IN ULONG cchPartType ) ;
2002-10-18 20:04:00 +00:00
PPARTLIST
2014-05-04 22:03:00 +00:00
CreatePartitionList (
SHORT Left ,
SHORT Top ,
SHORT Right ,
SHORT Bottom ) ;
2002-10-18 20:04:00 +00:00
VOID
2014-05-04 22:03:00 +00:00
DestroyPartitionList (
2017-05-13 16:32:53 +00:00
IN PPARTLIST List ) ;
2002-10-18 20:04:00 +00:00
VOID
2014-05-04 22:03:00 +00:00
DrawPartitionList (
2017-05-13 16:32:53 +00:00
IN PPARTLIST List ) ;
2002-10-18 20:04:00 +00:00
2017-05-13 16:32:53 +00:00
ULONG
2014-05-04 22:03:00 +00:00
SelectPartition (
2017-05-13 16:32:53 +00:00
IN PPARTLIST List ,
IN ULONG DiskNumber ,
IN ULONG PartitionNumber ) ;
2005-09-21 17:28:14 +00:00
2014-06-07 20:02:26 +00:00
BOOL
2014-05-04 22:03:00 +00:00
ScrollDownPartitionList (
2017-05-13 16:32:53 +00:00
IN PPARTLIST List ) ;
2002-10-18 20:04:00 +00:00
2014-06-07 20:02:26 +00:00
BOOL
2014-05-04 22:03:00 +00:00
ScrollUpPartitionList (
2017-05-13 16:32:53 +00:00
IN PPARTLIST List ) ;
2002-10-18 20:04:00 +00:00
2003-08-06 16:37:46 +00:00
VOID
2014-05-20 23:48:36 +00:00
CreatePrimaryPartition (
2017-05-13 16:32:53 +00:00
IN PPARTLIST List ,
IN ULONGLONG SectorCount ,
IN BOOLEAN AutoCreate ) ;
2003-04-28 19:44:13 +00:00
2014-05-20 23:48:36 +00:00
VOID
CreateExtendedPartition (
2017-05-13 16:32:53 +00:00
IN PPARTLIST List ,
IN ULONGLONG SectorCount ) ;
2014-05-20 23:48:36 +00:00
2014-06-09 01:49:24 +00:00
VOID
CreateLogicalPartition (
2017-05-13 16:32:53 +00:00
IN PPARTLIST List ,
IN ULONGLONG SectorCount ,
IN BOOLEAN AutoCreate ) ;
2014-06-09 01:49:24 +00:00
2003-08-06 16:37:46 +00:00
VOID
2014-05-04 22:03:00 +00:00
DeleteCurrentPartition (
2017-05-13 16:32:53 +00:00
IN PPARTLIST List ) ;
2003-08-04 15:54:05 +00:00
2003-08-19 15:54:47 +00:00
VOID
2016-02-28 15:25:22 +00:00
CheckActiveSystemPartition (
[USETUP]
- bootsup.c/.h, usetup.c: Save the old MBR sector in the system partition (this makes easier to restore the old one).
- fslist.c/.h, usetup.h: Fix header inclusion order.
- partlist.c/.h, usetup.c: On BIOS-PC architectures, the system partition can be formatted in any FS as long as it is the active partition (on the contrary, on architectures where such system partition is required, it is formatted in FAT). We currently do not have write support for all FSes out there (apart for FAT until now), so do a "clever" "trick" to work around this problem: on initialized disks, find the active partition and check its FS. If we support write access to this FS then we're OK, otherwise we change the (active) system partition for the one on which we are going to install ReactOS (which is, by construction, formatted with a FS on which we support write access).
The MBR (resp. the VBR) of the disk (resp. of the system partition) are always saved into files, making easy for people to boot on them (using FreeLdr) or restoring them.
CORE-10898
svn path=/trunk/; revision=70837
2016-03-01 15:00:56 +00:00
IN PPARTLIST List ,
IN PFILE_SYSTEM_LIST FileSystemList ) ;
2003-08-19 15:54:47 +00:00
2015-01-04 13:53:45 +00:00
BOOLEAN
WritePartitionsToDisk (
2017-05-13 16:32:53 +00:00
IN PPARTLIST List ) ;
BOOLEAN
SetMountedDeviceValues (
IN PPARTLIST List ) ;
2003-08-12 15:56:21 +00:00
2017-05-13 16:40:30 +00:00
VOID
SetPartitionType (
IN PPARTENTRY PartEntry ,
IN UCHAR PartitionType ) ;
2014-05-20 23:48:36 +00:00
ULONG
PrimaryPartitionCreationChecks (
IN PPARTLIST List ) ;
ULONG
ExtendedPartitionCreationChecks (
IN PPARTLIST List ) ;
2014-06-08 19:05:03 +00:00
ULONG
LogicalPartitionCreationChecks (
IN PPARTLIST List ) ;
2017-05-13 16:32:53 +00:00
BOOLEAN
2015-06-12 21:51:57 +00:00
GetNextUnformattedPartition (
IN PPARTLIST List ,
2017-05-13 16:32:53 +00:00
OUT PDISKENTRY * pDiskEntry OPTIONAL ,
2015-06-12 21:51:57 +00:00
OUT PPARTENTRY * pPartEntry ) ;
2017-05-13 16:32:53 +00:00
BOOLEAN
2015-06-12 21:51:57 +00:00
GetNextUncheckedPartition (
IN PPARTLIST List ,
2017-05-13 16:32:53 +00:00
OUT PDISKENTRY * pDiskEntry OPTIONAL ,
2015-06-12 21:51:57 +00:00
OUT PPARTENTRY * pPartEntry ) ;
2003-02-27 14:42:43 +00:00
/* EOF */