Query and pass struct FS_Limits into Dialog_Partition_Resize_Resize_Move (#787204)

Refactor Win_GParted::activate_resize() to query the file system size
limits using the new get_filesystem_limits() method and pass those
limits into the dialog class as struct FS_Limits.

Bug 787204 - Minimum and maximum size of the UDF partition/disk
This commit is contained in:
Mike Fleetwood 2018-01-12 11:53:08 +00:00 committed by Curtis Gedak
parent fe7b734792
commit 53b7a75894
3 changed files with 19 additions and 9 deletions

View file

@ -20,6 +20,7 @@
#include "Dialog_Base_Partition.h"
#include "Partition.h"
#include "PartitionVector.h"
#include "Utils.h"
namespace GParted
{
@ -27,7 +28,8 @@ namespace GParted
class Dialog_Partition_Resize_Move : public Dialog_Base_Partition
{
public:
Dialog_Partition_Resize_Move( const FS & fs, const Partition & selected_partition,
Dialog_Partition_Resize_Move( const FS & fs, const FS_Limits & fs_limits,
const Partition & selected_partition,
const PartitionVector & partitions );
~Dialog_Partition_Resize_Move();

View file

@ -24,11 +24,12 @@
namespace GParted
{
Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move( const FS & fs, const Partition & selected_partition,
Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move( const FS & fs, const FS_Limits & fs_limits,
const Partition & selected_partition,
const PartitionVector & partitions )
{
this ->fs = fs ;
fs_limits = FS_Limits( fs.MIN, fs.MAX );
this->fs_limits = fs_limits;
set_data( selected_partition, partitions );
}

View file

@ -1793,8 +1793,14 @@ void Win_GParted::activate_resize()
display_partitions_ptr = &display_partitions[index_extended].logicals;
}
FS fs_cap = gparted_core.get_fs( selected_partition_ptr->get_filesystem_partition().filesystem );
Partition * working_ptn;
const FILESYSTEM fstype = selected_partition_ptr->get_filesystem_partition().filesystem;
FS fs_cap = gparted_core.get_fs( fstype );
const FileSystem *filesystem_object = gparted_core.get_filesystem_object( fstype );
FS_Limits fs_limits;
if ( filesystem_object != NULL )
fs_limits = filesystem_object->get_filesystem_limits();
if ( selected_partition_ptr->filesystem == FS_LUKS && selected_partition_ptr->busy )
{
const FS & enc_cap = gparted_core.get_fs( FS_LUKS );
@ -1818,19 +1824,20 @@ void Win_GParted::activate_resize()
fs_cap.shrink = FS::NONE;
fs_cap.online_shrink = FS::NONE;
}
// Adjust file system size limits accounting for LUKS encryption overhead.
Sector luks_header_size = static_cast<const PartitionLUKS *>( selected_partition_ptr )->get_header_size();
fs_cap.MIN = luks_header_size * working_ptn->sector_size +
( fs_cap.MIN < MEBIBYTE ) ? MEBIBYTE : fs_cap.MIN;
if ( fs_cap.MAX > 0 )
fs_cap.MAX += luks_header_size * working_ptn->sector_size;
fs_limits.min_size = luks_header_size * working_ptn->sector_size +
( fs_limits.min_size < MEBIBYTE ) ? MEBIBYTE : fs_limits.min_size;
if ( fs_limits.max_size > 0 )
fs_limits.max_size += luks_header_size * working_ptn->sector_size;
}
else
{
working_ptn = selected_partition_ptr->clone();
}
Dialog_Partition_Resize_Move dialog( fs_cap, *working_ptn, *display_partitions_ptr );
Dialog_Partition_Resize_Move dialog( fs_cap, fs_limits, *working_ptn, *display_partitions_ptr );
dialog .set_transient_for( *this ) ;
delete working_ptn;