/* 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,999999); /* 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') ); } }
/* /PRI and /PRIO command line options */ void Command_Line_Create_Primary_Partition() { int maximum_possible_percentage; int option_count=1; long maximum_partition_size_in_MB; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; if(arg[0].value<=0) { printf("\n"); printf(catgets(cat,2,6,"Invalid partition size specifed")); printf("\n"); printf(catgets(cat,2,2,"Program Terminated")); printf("\n"); exit(9); } Determine_Free_Space(); maximum_partition_size_in_MB = Max_Pri_Part_Size_In_MB(PRIMARY); maximum_possible_percentage = Convert_To_Percentage(maximum_partition_size_in_MB ,pDrive->total_hard_disk_size_in_MB); if(arg[0].extra_value==100) { /* Set limit on percentage. */ if(arg[0].value > 100) arg[0].value = 100; if(arg[0].value > maximum_possible_percentage) arg[0].value = maximum_possible_percentage; /* Determine partition size. */ arg[0].value = (arg[0].value * maximum_partition_size_in_MB) / maximum_possible_percentage; } if(0!=strcmp(arg[1].choice,"SPEC")) { /* If no special partition type is defined. */ Set_Active_Partition_If_None_Is_Active( Create_Primary_Partition( Partition_Type_To_Create(arg[0].value,0),arg[0].value)); } else { /* If a special partition type is defined. */ option_count=2; Create_Primary_Partition((int)arg[1].value,arg[0].value); } Shift_Command_Line_Options(option_count); }
/* /EXT command line options */ void Command_Line_Create_Extended_Partition() { int maximum_possible_percentage; long maximum_partition_size_in_MB; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; if(arg[0].value<=0) { printf("\n"); printf(catgets(cat,2,6,"Invalid partition size specifed")); printf("\n"); printf(catgets(cat,2,2,"Program Terminated")); printf("\n"); exit(9); } Determine_Free_Space(); maximum_partition_size_in_MB = Max_Pri_Part_Size_In_MB(EXTENDED); maximum_possible_percentage = Convert_To_Percentage(maximum_partition_size_in_MB ,pDrive->total_hard_disk_size_in_MB); // ,pDrive->ext_part_size_in_MB); if(arg[0].extra_value==100) { /* Set limit on percentage. */ if(arg[0].value > 100) arg[0].value = 100; if(arg[0].value > maximum_possible_percentage) arg[0].value = maximum_possible_percentage; /* Determine partition size. */ arg[0].value = (arg[0].value * maximum_partition_size_in_MB) / maximum_possible_percentage; /* arg[0].value = Convert_Percent_To_MB(arg[0].value ,(pDrive->total_cyl+1) ); */ } Create_Primary_Partition(5,arg[0].value); Shift_Command_Line_Options(1); }
/* /LOG and /LOGO command line options */ void Command_Line_Create_Logical_DOS_Drive() { int maximum_possible_percentage; int option_count=1; // long ext_part_size; long maximum_partition_size_in_MB; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; if(arg[0].value<=0) { printf("\n"); printf(catgets(cat,2,6,"Invalid partition size specifed")); printf("\n"); printf(catgets(cat,2,2,"Program Terminated")); printf("\n"); exit(9); } Determine_Free_Space(); maximum_partition_size_in_MB = Max_Log_Part_Size_In_MB(); maximum_possible_percentage = Convert_To_Percentage(maximum_partition_size_in_MB ,pDrive->ext_part_size_in_MB); if(arg[0].extra_value==100) { /* Set limit on percentage. */ if(arg[0].value > 100) arg[0].value = 100; if(arg[0].value > maximum_possible_percentage) arg[0].value = maximum_possible_percentage; /* Determine partition size. */ arg[0].value = (arg[0].value * maximum_partition_size_in_MB) / maximum_possible_percentage; /* Compute the partition size as a percentage. */ // arg[0].value = Convert_Percent_To_MB(arg[0].value,ext_part_size); } if(0!=strcmp(arg[1].choice,"SPEC")) { /* If no special partition type is defined. */ Create_Logical_Drive( Partition_Type_To_Create(arg[0].value,0),arg[0].value); } else { /* If a special partition type is defined. */ option_count=2; Create_Logical_Drive((int)arg[1].value,arg[0].value); } Shift_Command_Line_Options(option_count); }
/* Returns a 0 if successful and a 1 if unsuccessful */ int Create_Logical_Drive_Interface() { long input=0; int drive_created=FALSE; int maximum_possible_percentage; int numeric_type; long maximum_partition_size_in_MB; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; Determine_Free_Space(); if(pDrive->ext_part_largest_free_space>=2) { do { if(flags.fprmt==TRUE) flags.fat32=TRUE; maximum_partition_size_in_MB = Max_Log_Part_Size_In_MB(); Clear_Screen(0); if(drive_created==TRUE) { cprintAt(4,22,"Logical DOS Drive created, drive letters changed or added"); } Print_Centered(1,"Create Logical DOS Drive in the Extended DOS Partition",BOLD); Display_Extended_Partition_Information_SS(); if('Z'==Determine_Drive_Letters()) { printAt(4,22," "); cprintAt(4,22,"Maximum number of Logical DOS Drives installed."); Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); if(flags.fprmt==TRUE) flags.fat32=FALSE; return(1); } printAt(4,17,"Total Extended DOS Partition size is "); if( (flags.version==4) || (flags.version==5) || (flags.version==6) ) cprintf("%4d",pDrive->ext_part_size_in_MB); else Print_UL_B(pDrive->ext_part_size_in_MB); printf(" Mbytes (1 Mbyte = 1048576 bytes)"); printAt(4,18,"Maximum space available for partition is "); if( (flags.version==4) || (flags.version==5) || (flags.version==6) ) cprintf("%4d",maximum_partition_size_in_MB); else Print_UL_B(maximum_partition_size_in_MB); printf(" Mbytes "); maximum_possible_percentage = Convert_To_Percentage(maximum_partition_size_in_MB ,pDrive->ext_part_size_in_MB); cprintf("(%3d%%)",maximum_possible_percentage); printAt(4,20,"Enter logical drive size in Mbytes or percent of disk space (%)..."); flags.esc=FALSE; if( (flags.version==4) || (flags.version==5) || (flags.version==6) ) input=Input(4,70,20,NUMP,1,maximum_partition_size_in_MB,ESCR ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL); else input=Input(6,70,20,NUMP,1,maximum_partition_size_in_MB,ESCR ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL); if(flags.esc==TRUE) { if(flags.fprmt==TRUE) flags.fat32=FALSE; return(1); } if( (flags.fprmt==TRUE) && (input>=128) && (input<=2048) ) { printAt(4,21,"This drive is a FAT32 by default, switch to FAT16 (Y/N)? "); flags.fat32=!Input(1,61,21,YN,0,0,NONE,1,0,NULL,NULL); } numeric_type=6; numeric_type=Partition_Type_To_Create(input,numeric_type); Create_Logical_Drive(numeric_type,input); drive_created=TRUE; }while(pDrive->ext_part_largest_free_space>=2); } Clear_Screen(0); Print_Centered(1,"Create Logical DOS Drive in the Extended DOS Partition",BOLD); Display_Extended_Partition_Information_SS(); cprintAt(4,22,"All available space in the Extended DOS Partition"); cprintAt(4,23,"is assigned to logical drives."); Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL); if(flags.fprmt==TRUE) flags.fat32=FALSE; return(0); }