Example #1
0
/* /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);
}
Example #2
0
/* /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);
}
Example #3
0
/* Create DOS Partition Interface */
int Create_DOS_Partition_Interface(int type)
{
  int numeric_type;
  int partition_created=FALSE;
  int partition_slot_just_used;

  long maximum_partition_size_in_MB;
  long maximum_possible_percentage;

  unsigned long input=0;
  Partition_Table *pDrive = &part_table[flags.drive_number-0x80];

  maximum_partition_size_in_MB
   = Max_Pri_Part_Size_In_MB(type);

  if(type==PRIMARY)
    {
    Clear_Screen(0);

    Print_Centered(4,"Create Primary DOS Partition",BOLD);

    printAt(4,6,"Current fixed disk drive: ");
    cprintf("%d",(flags.drive_number-127));

    printAt(4,8,"Do you wish to use the maximum available size for a Primary DOS Partition");

    if((flags.drive_number-128)==0)
      {
      printAt(4,9,"and make the partition active (Y/N).....................? ");
      }
    else
      {
      printAt(4,9,"(Y/N)...................................................? ");
      }

    flags.esc=FALSE;
    input=Input(1,62,9,YN,0,0,ESCR,1,0,NULL,NULL);
    if(flags.esc==TRUE) return(1);

    if(input==1)
      {
      input=maximum_partition_size_in_MB;
      numeric_type=6;  /* Set the numeric type to 6 so that it will be    */
                       /* decided by Partition_Type_To_Create().          */

      if( (flags.fprmt==TRUE) && (type==PRIMARY) && (input>=128) && (input<=2048) )
        {
        printAt(4,22,"This drive is a FAT32 by default, switch to FAT16 (Y/N)?    ");
	flags.fat32=!Input(1,61,22,YN,0,0,NONE,1,0,NULL,NULL);
        }

      /* Use the maximum available free space to create a DOS Partition */

      /* Adjust numeric type depending upon partition size and the FDISK */
      /* version emulated.                                               */
      numeric_type=Partition_Type_To_Create(input,numeric_type);

      partition_slot_just_used=Create_Primary_Partition(numeric_type,input);
      if((flags.drive_number-128)==0) Set_Active_Partition(partition_slot_just_used);
      partition_created=TRUE;
      }
    }

  if(partition_created==FALSE)
    {
    Clear_Screen(0);

    if(type==PRIMARY) Print_Centered(4,"Create Primary DOS Partition",BOLD);
    else              Print_Centered(4,"Create Extended DOS Partition",BOLD);

    printAt(4,6,"Current fixed disk drive: ");
    cprintf("%d",(flags.drive_number-127));

    Display_Primary_Partition_Information_SS();

    printAt(4,15,"Maximum space available for partition is ");

    if( (flags.version==W95) || (flags.version==W95B) || (flags.version==W98) )
      Print_UL_B(maximum_partition_size_in_MB);
    else cprintf("%4d",maximum_partition_size_in_MB);

    printf(" Mbytes ");

    maximum_possible_percentage
     = Convert_To_Percentage(maximum_partition_size_in_MB
      ,pDrive->total_hard_disk_size_in_MB);

    cprintf("(%3d%%)",maximum_possible_percentage);

    printAt(4,18,"Enter partition size in Mbytes or percent of disk space (%) to");

    if(type==PRIMARY) printAt(4,19,"create a Primary DOS Partition.................................: ");
    else              printAt(4,19,"create an Extended DOS Partition...............................: ");

    flags.esc=FALSE;

    if( (flags.version==4) || (flags.version==5) || (flags.version==6) )
     input=Input(4,69,19,NUMP,1,maximum_partition_size_in_MB,ESCR
     ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL);
    else input=Input(6,69,19,NUMP,1,maximum_partition_size_in_MB,ESCR
     ,maximum_partition_size_in_MB,maximum_possible_percentage,NULL,NULL);

    if(flags.esc==TRUE) return(1);

    if( (flags.fprmt==TRUE) && (type==PRIMARY) && (input>=128) && (input<=2048) )
      {
      printAt(4,22,"This drive is a FAT32 by default, switch to FAT16 (Y/N)?    ");
      flags.fat32=!Input(1,61,22,YN,0,0,NONE,1,0,NULL,NULL);
      }

    if(type==PRIMARY) numeric_type=Partition_Type_To_Create(input,0);
    else numeric_type=5;

    Create_Primary_Partition(numeric_type,input);
    }

  if(flags.fprmt==TRUE) flags.fat32=FALSE;

  Clear_Screen(0);

  if(type==PRIMARY) Print_Centered(4,"Create Primary DOS Partition",BOLD);
  else              Print_Centered(4,"Create Extended DOS Partition",BOLD);

  printAt(4,6,"Current fixed disk drive: ");
  cprintf("%d",(flags.drive_number-127));

  Display_Primary_Partition_Information_SS();

  Position_Cursor(4,21);
  if(type==PRIMARY) cprintf("Primary DOS Partition created");
  else              cprintf("Extended DOS Partition created");

  Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);

  if(type==EXTENDED) Create_Logical_Drive_Interface();

  return(0);
}