As the function to autoformat in fdisk is relatively small, let me copy it here:
First function in the file:
https://gitlab.com/FDOS/base/fdisk/-/blob/master/SOURCE/FDISK/FDISK/FDISKIO.C
/* Automatically partition the selected hard drive */
void Automatically_Partition_Hard_Drive()
{
int index=0;
/* unsigned long maximum_partition_size_in_MB; */
Partition_Table *pDrive = &part_table[(flags.drive_number-128)];
Determine_Drive_Letters();
/* First, make sure no primary or extended partitions exist. */
/* Compaq diagnostic partitions are ok, though. */
do
{
if( (brief_partition_table[(flags.drive_number-128)] [index]>0) &&
(brief_partition_table[(flags.drive_number-128)][index]!=18) )
{
printf("\nThe hard drive has already been partitioned...Program
Terminated.\n");
exit(7);
}
index++;
}while(index<4);
/* Create a primary partition...if the size or type is incorrect, */
/* int Create_Primary_Partition(...) will adjust it automatically. */
Determine_Free_Space();
Set_Active_Partition(Create_Primary_Partition(6,2048));
/* Create an extended partition, if space allows. */
Determine_Free_Space();
if( pDrive->pri_part_largest_free_space > 0)
{
Create_Primary_Partition(5,999999ul);
/* Fill the extended partition with logical drives. */
Determine_Free_Space();
do
{
Create_Logical_Drive(6,2048);
Determine_Free_Space();
/* maximum_partition_size_in_MB
= (pDrive->ext_part_largest_free_space+1)*
(pDrive->total_head+1)*
pDrive->total_sect / 2048; */
}while( (pDrive->ext_part_largest_free_space > 0)
&& (Determine_Drive_Letters()<'Z') );
}
}
So, at first glance it confirms the idea: Make a primary 2 GB partition, then
add 2 GB logical partitions until there is no free space.
It's better than what I expected... I mean it is written in C not in
assembler... except for boot sector code ... of course.
_______________________________________________
Freedos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-devel