Replace constant MEBIBYTE with appropriate MEBI_FACTOR math
This change is in preparation for supporting sectors sizes > 512 bytes.
This commit is contained in:
parent
f46fbedd34
commit
81a903cda2
|
@ -127,11 +127,11 @@ Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
|
|||
//FIXME: Partition size is limited to just less than 1024 TeraBytes due
|
||||
// to the maximum value of signed 4 byte integer.
|
||||
if ( ORIG_BEFORE != spinbutton_before .get_value_as_int() )
|
||||
selected_partition .sector_start = START + Sector(spinbutton_before .get_value_as_int()) * MEBIBYTE ;
|
||||
selected_partition .sector_start = START + Sector(spinbutton_before .get_value_as_int()) * (MEBI_FACTOR / sector_size) ;
|
||||
|
||||
if ( ORIG_AFTER != spinbutton_after .get_value_as_int() )
|
||||
selected_partition .sector_end =
|
||||
selected_partition .sector_start + Sector(spinbutton_size .get_value_as_int()) * MEBIBYTE ;
|
||||
selected_partition .sector_start + Sector(spinbutton_size .get_value_as_int()) * (MEBI_FACTOR / sector_size) ;
|
||||
|
||||
//due to loss of precision during calcs from Sector -> MiB and back, it is possible
|
||||
//the new partition thinks it's bigger then it can be. Here we solve this.
|
||||
|
@ -141,9 +141,9 @@ Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
|
|||
selected_partition .sector_end = START + total_length -1 ;
|
||||
|
||||
//grow a bit into small freespace ( < 1MiB )
|
||||
if ( (selected_partition .sector_start - START) < MEBIBYTE )
|
||||
if ( (selected_partition .sector_start - START) < (MEBI_FACTOR / sector_size) )
|
||||
selected_partition .sector_start = START ;
|
||||
if ( ( START + total_length -1 - selected_partition .sector_end ) < MEBIBYTE )
|
||||
if ( ( START + total_length -1 - selected_partition .sector_end ) < (MEBI_FACTOR / sector_size) )
|
||||
selected_partition .sector_end = START + total_length -1 ;
|
||||
|
||||
//set new value of unused..
|
||||
|
|
|
@ -155,7 +155,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
|
|||
spinbutton_before .set_value( 0 ) ;
|
||||
|
||||
//euhrm, this wil only happen when there's a very small free space (usually the effect of a bad partitionmanager)
|
||||
if ( TOTAL_MB * MEBIBYTE < this ->cylinder_size )
|
||||
if ( TOTAL_MB * (MEBI_FACTOR / this ->selected_partition .sector_size) < this ->cylinder_size )
|
||||
frame_resizer_base ->set_sensitive( false ) ;
|
||||
|
||||
this ->show_all_children() ;
|
||||
|
@ -178,8 +178,8 @@ Partition Dialog_Partition_New::Get_New_Partition( Byte_Value sector_size )
|
|||
|
||||
//FIXME: Partition size is limited to just less than 1024 TeraBytes due
|
||||
// to the maximum value of signed 4 byte integer.
|
||||
new_start = START + (Sector(spinbutton_before .get_value_as_int()) * MEBIBYTE) ;
|
||||
new_end = new_start + (Sector(spinbutton_size .get_value_as_int()) * MEBIBYTE) - 1 ;
|
||||
new_start = START + (Sector(spinbutton_before .get_value_as_int()) * (MEBI_FACTOR / sector_size)) ;
|
||||
new_end = new_start + (Sector(spinbutton_size .get_value_as_int()) * (MEBI_FACTOR / sector_size)) - 1 ;
|
||||
|
||||
/* due to loss of precision during calcs from Sector -> MiB and back, it is possible the new
|
||||
* partition thinks it's bigger then it can be. Here we try to solve this.*/
|
||||
|
@ -201,9 +201,9 @@ Partition Dialog_Partition_New::Get_New_Partition( Byte_Value sector_size )
|
|||
part_temp .label = Utils::trim( entry .get_text() );
|
||||
|
||||
//grow new partition a bit if freespaces are < 1 MiB
|
||||
if ( (part_temp.sector_start - selected_partition.sector_start) < MEBIBYTE )
|
||||
if ( (part_temp.sector_start - selected_partition.sector_start) < (MEBI_FACTOR / sector_size) )
|
||||
part_temp.sector_start = selected_partition.sector_start ;
|
||||
if ( (selected_partition.sector_end - part_temp.sector_end) < MEBIBYTE )
|
||||
if ( (selected_partition.sector_end - part_temp.sector_end) < (MEBI_FACTOR / sector_size) )
|
||||
part_temp.sector_end = selected_partition.sector_end ;
|
||||
|
||||
//if new is extended...
|
||||
|
|
|
@ -305,8 +305,8 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
|
|||
temp_device .cylsize = temp_device .heads * temp_device .sectors ;
|
||||
|
||||
//make sure cylsize is at least 1 MiB
|
||||
if ( temp_device .cylsize < MEBIBYTE )
|
||||
temp_device .cylsize = MEBIBYTE ;
|
||||
if ( temp_device .cylsize < (MEBI_FACTOR / temp_device .sector_size) )
|
||||
temp_device .cylsize = (MEBI_FACTOR / temp_device .sector_size) ;
|
||||
|
||||
//normal harddisk
|
||||
if ( lp_disk )
|
||||
|
@ -1101,7 +1101,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
|
|||
}
|
||||
|
||||
//start <---> first partition start
|
||||
if ( (partitions .front() .sector_start - start) >= MEBIBYTE )
|
||||
if ( (partitions .front() .sector_start - start) >= (MEBI_FACTOR / sector_size) )
|
||||
{
|
||||
partition_temp .sector_start = start ;
|
||||
partition_temp .sector_end = partitions .front() .sector_start -1 ;
|
||||
|
@ -1111,7 +1111,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
|
|||
|
||||
//look for gaps in between
|
||||
for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
|
||||
if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= MEBIBYTE )
|
||||
if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= (MEBI_FACTOR / sector_size) )
|
||||
{
|
||||
partition_temp .sector_start = partitions[ t ] .sector_end +1 ;
|
||||
partition_temp .sector_end = partitions[ t +1 ] .sector_start -1 ;
|
||||
|
@ -1120,7 +1120,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
|
|||
}
|
||||
|
||||
//last partition end <---> end
|
||||
if ( (end - partitions .back() .sector_end ) >= MEBIBYTE )
|
||||
if ( (end - partitions .back() .sector_end ) >= (MEBI_FACTOR / sector_size) )
|
||||
{
|
||||
partition_temp .sector_start = partitions .back() .sector_end +1 ;
|
||||
partition_temp .sector_end = end ;
|
||||
|
|
|
@ -60,7 +60,7 @@ void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector
|
|||
}
|
||||
|
||||
//start <---> first partition start
|
||||
if ( (partitions .front() .sector_start - start) >= MEBIBYTE )
|
||||
if ( (partitions .front() .sector_start - start) >= (MEBI_FACTOR / sector_size) )
|
||||
{
|
||||
UNALLOCATED .sector_start = start ;
|
||||
UNALLOCATED .sector_end = partitions .front() .sector_start -1 ;
|
||||
|
@ -70,7 +70,7 @@ void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector
|
|||
|
||||
//look for gaps in between
|
||||
for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
|
||||
if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= MEBIBYTE )
|
||||
if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= (MEBI_FACTOR / sector_size) )
|
||||
{
|
||||
UNALLOCATED .sector_start = partitions[ t ] .sector_end +1 ;
|
||||
UNALLOCATED .sector_end = partitions[ t +1 ] .sector_start -1 ;
|
||||
|
@ -79,7 +79,7 @@ void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector
|
|||
}
|
||||
|
||||
//last partition end <---> end
|
||||
if ( (end - partitions .back() .sector_end ) >= MEBIBYTE )
|
||||
if ( (end - partitions .back() .sector_end ) >= (MEBI_FACTOR / sector_size) )
|
||||
{
|
||||
UNALLOCATED .sector_start = partitions .back() .sector_end +1 ;
|
||||
UNALLOCATED .sector_end = end ;
|
||||
|
|
Loading…
Reference in New Issue