Fix off by 1 sector math when looking for unallocated space
This commit is contained in:
parent
87e48efe88
commit
be53cf584b
|
@ -1229,10 +1229,10 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
|
||||||
//look for gaps in between
|
//look for gaps in between
|
||||||
for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
|
for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
|
||||||
{
|
{
|
||||||
if ( ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end ) > (MEBIBYTE / sector_size) )
|
if ( ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end - 1 ) > (MEBIBYTE / sector_size) )
|
||||||
|| ( ( partitions[ t + 1 ] .type != TYPE_LOGICAL ) // Only show exactly 1 MiB if following partition is not logical.
|
|| ( ( partitions[ t + 1 ] .type != TYPE_LOGICAL ) // Only show exactly 1 MiB if following partition is not logical.
|
||||||
&& ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end ) == (MEBIBYTE / sector_size)
|
&& ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end - 1 ) == (MEBIBYTE / sector_size) )
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
partition_temp .sector_start = partitions[ t ] .sector_end +1 ;
|
partition_temp .sector_start = partitions[ t ] .sector_end +1 ;
|
||||||
|
@ -1243,7 +1243,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
|
||||||
}
|
}
|
||||||
|
|
||||||
//last partition end <---> end
|
//last partition end <---> end
|
||||||
if ( (end - partitions .back() .sector_end ) >= (MEBIBYTE / sector_size) )
|
if ( (end - partitions .back() .sector_end) >= (MEBIBYTE / sector_size) )
|
||||||
{
|
{
|
||||||
partition_temp .sector_start = partitions .back() .sector_end +1 ;
|
partition_temp .sector_start = partitions .back() .sector_end +1 ;
|
||||||
partition_temp .sector_end = end ;
|
partition_temp .sector_end = end ;
|
||||||
|
|
|
@ -71,9 +71,9 @@ void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector
|
||||||
//look for gaps in between
|
//look for gaps in between
|
||||||
for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
|
for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
|
||||||
{
|
{
|
||||||
if ( ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end ) > (MEBIBYTE / sector_size) )
|
if ( ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end - 1 ) > (MEBIBYTE / sector_size) )
|
||||||
|| ( ( partitions[ t + 1 ] .type != TYPE_LOGICAL ) // Only show exactly 1 MiB if following partition is not logical.
|
|| ( ( partitions[ t + 1 ] .type != TYPE_LOGICAL ) // Only show exactly 1 MiB if following partition is not logical.
|
||||||
&& ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end ) == (MEBIBYTE / sector_size)
|
&& ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end - 1 ) == (MEBIBYTE / sector_size) )
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue