コード例 #1
0
ファイル: cmd.c プロジェクト: CivilPol/sdcboot
/* /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);
}
コード例 #2
0
ファイル: USERINT2.C プロジェクト: Dosercyan/fdisk
/* 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);
}
コード例 #3
0
ファイル: cmd.c プロジェクト: CivilPol/sdcboot
/* /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);
}
コード例 #4
0
ファイル: USERINT2.C プロジェクト: Dosercyan/fdisk
/* 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);
}