/* /DELETE command line option */ void Command_Line_Delete() { Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; /* Delete the primary partition */ if(0==strcmp(arg[1].choice,"PRI")) { if (arg[1].value != 0) /* specified what to delete */ { if (arg[1].value < 1 || arg[1].value >4) { printf("primary partition # (%ld) must be 1..4\n",(long)arg[1].value); exit(9);} Delete_Primary_Partition((int)(arg[1].value - 1)); } else { /* no number given, delete 'the' partition */ int index,found,count; for (count = 0, index = 0; index < 4; index++) { if(IsRecognizedFatPartition(pDrive->pri_part[index].num_type)) { count++; found = index; } } if (count == 0) printf("no partition to delete found\n"); /* but continue */ else if (count > 1) { printf("%d primary partitions found, you must specify number to delete\n",count); exit(9); } else { Delete_Primary_Partition(found); } } } /* end PRI */ /* Delete the extended partition */ if(0==strcmp(arg[1].choice,"EXT")) { int index=3; do { if( ( (flags.version==FOUR) || (flags.version==FIVE) || (flags.version==SIX) ) && (pDrive->pri_part[index].num_type==5) ) { Delete_Primary_Partition(index); break; } if( ( (flags.version==W95) || (flags.version==W95B) || (flags.version==W98) ) && ( (pDrive->pri_part[index].num_type==5) || (pDrive->pri_part[index].num_type==15) ) ) { Delete_Primary_Partition(index); break; } index--; }while(index>=0); if(index<0) { printf("\nExtended DOS Partition not found...no partition deleted.\n"); exit(9); } } /* Delete a Logical DOS Drive */ if(0==strcmp(arg[1].choice,"LOG")) { if( (arg[1].value>=1) && (arg[1].value<=23) ) { Delete_Logical_Drive( (int)(arg[1].value-1) ); } else { printf("\nLogical drive number (%d) is out of range...Operation Terminated\n",arg[1].value); exit(9); } } /* Delete the partition by the number of the partition */ if(0==strcmp(arg[1].choice,"NUM")) { if( (arg[1].value>=1) && (arg[1].value<=4) ) { Delete_Primary_Partition( (int)(arg[1].value-1) ); } else if( (arg[1].value>=5) && (arg[1].value<=28) ) { Delete_Logical_Drive( (int)(arg[1].value-5) ); } else { printf("\nPartition number is out of range...Operation Terminated\n"); exit(9); } } Shift_Command_Line_Options(2); }
/* Determine drive letters */ int Determine_Drive_Letters() /* Returns last used drive letter as ASCII number. */ { // int active_found=FALSE; int current_letter='C'; // int drive_found=FALSE; int index=0; int non_dos_partition; int non_dos_partition_counter; int sub_index=0; int active_part_found[8]; Load_Brief_Partition_Table(); /* Clear drive_lettering_buffer[8] [27] */ index=0; do { sub_index=0; do { drive_lettering_buffer[index] [sub_index]=0; sub_index++; }while(sub_index<27); index++; }while(index<8); /* Set all active_part_found[] values to 0. */ index=0; do { active_part_found[index]=0; index++; }while(index<8); /* Begin placement of drive letters */ /* First, look for and assign drive letters to all active */ /* primary partitions. */ index=0; do { Partition_Table *pDrive = &part_table[index]; sub_index=0; do { if( (IsRecognizedFatPartition(brief_partition_table[index] [sub_index])) && (pDrive->pri_part[sub_index].active_status==0x80) ) { drive_lettering_buffer[index] [sub_index]=current_letter; active_part_found[index]=1; sub_index=5; /* get out of loop */ current_letter++; } sub_index++; }while(sub_index<4); index++; }while(index<8); /* Next, assign one drive letter for one existing primary partition */ /* if an active partition does not exist on that hard disk. */ index=0; do { if(active_part_found[index]==0) { sub_index=0; do { if(IsRecognizedFatPartition(brief_partition_table[index] [sub_index])) { drive_lettering_buffer[index] [sub_index]=current_letter; current_letter++; sub_index=5; /* Set sub_index = 5 to break out of loop early. */ } sub_index++; }while(sub_index<4); } index++; }while(index<8); /* Next assign drive letters to applicable extended partitions... */ index=0; do { sub_index=4; do { if(IsRecognizedFatPartition (brief_partition_table[index] [sub_index])) { drive_lettering_buffer[index] [sub_index]=current_letter; current_letter++; } sub_index++; }while(sub_index<27); index++; }while(index<8); /* Return to the primary partitions... */ index=0; do { sub_index=0; do { if( drive_lettering_buffer[index] [sub_index]==0) { if (IsRecognizedFatPartition(brief_partition_table[index] [sub_index])) { drive_lettering_buffer[index] [sub_index]=current_letter; current_letter++; } } sub_index++; }while(sub_index<4); index++; }while(index<8); /* Find the Non-DOS Logical Drives in the Extended Partition Table */ non_dos_partition_counter='1'; index=0; do { Partition_Table *pDrive = &part_table[index]; pDrive->num_of_non_dos_log_drives=0; sub_index=4; do { if(brief_partition_table[index] [sub_index]>0) { non_dos_partition=TRUE; if( IsRecognizedFatPartition(brief_partition_table[index] [sub_index])) { non_dos_partition=FALSE; } if( (non_dos_partition==TRUE) && (non_dos_partition_counter<='9') ) { drive_lettering_buffer[index] [sub_index]=non_dos_partition_counter; pDrive->num_of_non_dos_log_drives++; non_dos_partition_counter++; } } sub_index++; }while(sub_index<27); non_dos_partition_counter='1'; index++; }while(index<8); return(current_letter-1); }
void Display_CL_Partition_Table() { int index=0; unsigned long usage=0; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; Determine_Drive_Letters(); printf("\n\nCurrent fixed disk drive: %1d",(flags.drive_number-127)); if(flags.extended_options_flag==TRUE) { printf(" (TC: %4d",pDrive->total_cyl); printf(" TH: %3d",pDrive->total_head); printf(" TS: %3d)",pDrive->total_sect); } printf("\n\nPartition Status Mbytes Description Usage "); if(flags.extended_options_flag==TRUE) printf("Start Cyl End Cyl"); printf("\n"); index=0; do { if(pDrive->pri_part[index].num_type>0) { /* Drive Letter of Partition */ if( IsRecognizedFatPartition(pDrive->pri_part[index].num_type)) { printf(" %1c:",drive_lettering_buffer[(flags.drive_number-128)] [index]); } else printf(" "); /* Partition Number */ printf(" %1d",(index+1)); if(flags.extended_options_flag==TRUE) { /* Partition Type */ printf(" %3d",(pDrive->pri_part[index].num_type)); } else printf(" "); /* Status */ if(pDrive->pri_part[index].active_status>0) { printf(" A"); } else printf(" "); /* Mbytes */ printf(" "); Print_UL(pDrive->pri_part[index].size_in_MB); /* Description */ printf(" %15s",partition_lookup_table_buffer_long[pDrive->pri_part[index].num_type]); /* Usage */ usage = Convert_To_Percentage(pDrive->pri_part[index].size_in_MB, pDrive->total_hard_disk_size_in_MB); printf(" %3d%%",usage); if(flags.extended_options_flag==TRUE) { /* Starting Cylinder */ printf(" %4d",pDrive->pri_part[index].start_cyl); /* Ending Cylinder */ printf(" %4d",pDrive->pri_part[index].end_cyl); } printf("\n"); } index++; }while(index<4); /* Check to see if there are any drives to display */ if( (brief_partition_table[(flags.drive_number-128)] [4]>0) || (brief_partition_table[(flags.drive_number-128)] [5]>0) ) { printf("\nContents of Extended DOS Partition:\n"); printf("Drv Volume Label Mbytes System Usage\n"); /* Display information for each Logical DOS Drive */ index=4; do { if (brief_partition_table[(flags.drive_number-128)] [index] > 0) { if (IsRecognizedFatPartition(brief_partition_table[(flags.drive_number-128)] [index])) { /* Display drive letter */ printf(" %1c:",drive_lettering_buffer[(flags.drive_number-128)] [index]); /* Display volume label */ printf(" %11s",pDrive->log_drive[index-4].vol_label); } else printf(" "); /* Display size in MB */ printf(" "); Print_UL(pDrive->log_drive[(index-4)].size_in_MB); /* Display file system type */ printf(" %-8s",partition_lookup_table_buffer_short[pDrive->log_drive[(index-4)].num_type]); /* Display usage in % */ usage = Convert_To_Percentage(pDrive->log_drive[index-4].num_sect, pDrive->ext_part_num_sect); printf(" %3d%%",usage); printf("\n"); } index++; }while(index<27); } }
/* Display Extended Partition Information Sub Screen */ void Display_Extended_Partition_Information_SS() { int column_index=0; int index; int print_index=4; unsigned long usage; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; Determine_Drive_Letters(); /* Check to see if there are any drives to display */ if( (brief_partition_table[(flags.drive_number-128)] [4]>0) || (brief_partition_table[(flags.drive_number-128)] [5]>0) ) { printAt(0,3,"Drv Volume Label Mbytes System Usage"); /* Display information for each Logical DOS Drive */ index=4; print_index=4; do { if(print_index>15) { column_index=41; print_index=4; printAt(41,3,"Drv Volume Label Mbytes System Usage"); } if(brief_partition_table[(flags.drive_number-128)] [index]>0) { if( IsRecognizedFatPartition(brief_partition_table[(flags.drive_number-128)] [index])) { /* Display drive letter */ cprintAt(column_index+0,print_index,"%c",drive_lettering_buffer[(flags.drive_number-128)] [index]); cprintAt(column_index+1,print_index,":"); /* Display volume label */ printAt(column_index+4,print_index,"%11s",pDrive->log_drive[index-4].vol_label); } else { if(flags.del_non_dos_log_drives==TRUE) { /* Display drive number */ cprintAt(column_index+0,print_index,"%c",drive_lettering_buffer[(flags.drive_number-128)] [index]); } } /* Display size in MB */ Position_Cursor((column_index+17),print_index); Print_UL(pDrive->log_drive[(index-4)].size_in_MB); /* Display file system type */ printAt(column_index+25,print_index,"%s", partition_lookup_table_buffer_short[pDrive->log_drive[(index-4)].num_type]); /* Display usage in % */ usage = Convert_To_Percentage(pDrive->log_drive[index-4].num_sect, pDrive->ext_part_num_sect); printAt(column_index+35,print_index,"%3d%%",usage); print_index++; } index++; }while(index<27); } else { cprintAt(4,10,"No logical drives defined"); } printAt(4,17,"Total Extended DOS Partition size is "); if( (flags.version==W95) || (flags.version==W95B) || (flags.version==W98) ) Print_UL_B(part_table[flags.drive_number-128].ext_part_size_in_MB); else cprintf("%4d",(part_table[flags.drive_number-128].ext_part_size_in_MB) ); printf(" Mbytes (1 Mbyte = 1048576 bytes)"); }
/* Display Primary Partition information Sub-screen */ void Display_Primary_Partition_Information_SS() { int cursor_offset=0; int index=0; char *type; unsigned long usage=0; Partition_Table *pDrive = &part_table[flags.drive_number-0x80]; Determine_Drive_Letters(); printAt(4,6,"Current fixed disk drive: "); cprintf("%d",(flags.drive_number-127)); if( (pDrive->pri_part[0].num_type>0) || (pDrive->pri_part[1].num_type>0) || (pDrive->pri_part[2].num_type>0) || (pDrive->pri_part[3].num_type>0) ) { if(flags.extended_options_flag==FALSE) { printAt(4,8,"Partition Status Type Volume Label Mbytes System Usage"); for (index=0; index < 4; index++) { if(pDrive->pri_part[index].num_type>0) { /* Drive Letter of Partition */ if( IsRecognizedFatPartition(pDrive->pri_part[index].num_type) ) { printAt(5,(cursor_offset+9),"%c:",drive_lettering_buffer[(flags.drive_number-128)] [index]); } /* Partition Number */ cprintAt(8,(cursor_offset+9),"%d",(index+1)); /* Status */ if(pDrive->pri_part[index].active_status>0) { printAt(18,(cursor_offset+9),"A"); } /* Type */ type = "Non-DOS"; if( IsRecognizedFatPartition(pDrive->pri_part[index].num_type) ) { type = "PRI DOS"; } else if(pDrive->pri_part[index].num_type==5) { type = "EXT DOS"; } else if( (pDrive->pri_part[index].num_type==0x0f) && ( flags.version==W95 || flags.version==W95B || flags.version==W98 ) ) { type = "EXT DOS"; } printAt(23,(cursor_offset+9),type); /* Volume Label */ printAt(33,(cursor_offset+9),"%11s",pDrive->pri_part[index].vol_label); /* Mbytes */ Position_Cursor(45,(cursor_offset+9)); Print_UL(pDrive->pri_part[index].size_in_MB); /* System */ printAt(54,(cursor_offset+9),"%s",partition_lookup_table_buffer_short[pDrive->pri_part[index].num_type]); /* Usage */ usage = Convert_To_Percentage(pDrive->pri_part[index].size_in_MB, pDrive->total_hard_disk_size_in_MB); printAt(65,(cursor_offset+9),"%3d%%",usage); cursor_offset++; } } /* while(index<4);*/ } else { printAt(4,8,"Partition Status Mbytes Description Usage Start Cyl End Cyl"); for (index=0; index < 4; index++) { if(pDrive->pri_part[index].num_type>0) { /* Drive Letter of Partition */ if (IsRecognizedFatPartition (pDrive->pri_part[index].num_type)) { printAt(5,(cursor_offset+9),"%c:",drive_lettering_buffer[flags.drive_number-128] [index]); } /* Partition Number */ cprintAt(8,(cursor_offset+9),"%d",index+1); /* Partition Type */ printAt(10,(cursor_offset+9),"%3d",pDrive->pri_part[index].num_type); /* Status */ if(pDrive->pri_part[index].active_status>0) { printAt(19,(cursor_offset+9),"A"); } /* Mbytes */ Position_Cursor(24,(cursor_offset+9)); Print_UL(pDrive->pri_part[index].size_in_MB); /* Description */ printAt(33,(cursor_offset+9),"%15s",partition_lookup_table_buffer_long[pDrive->pri_part[index].num_type]); /* Usage */ usage = Convert_To_Percentage(pDrive->pri_part[index].size_in_MB, pDrive->total_hard_disk_size_in_MB); printAt(51,(cursor_offset+9),"%3d%%",usage); /* Starting Cylinder */ printAt(59,(cursor_offset+9),"%4d",pDrive->pri_part[index].start_cyl); /* Ending Cylinder */ printAt(69,(cursor_offset+9),"%4d",pDrive->pri_part[index].end_cyl); cursor_offset++; } } /*while(index<4);*/ } } else { cprintAt(4,21,"No partitions defined"); } printAt(4,14,"Total disk space is "); if( (flags.version==W95) || (flags.version==W95B) || (flags.version==W98) ) Print_UL_B(pDrive->total_hard_disk_size_in_MB); else cprintf("%4d",pDrive->total_hard_disk_size_in_MB); printf(" Mbytes (1 Mbyte = 1048576 bytes)"); }