[gparted] Pass Partition object to get_filesystem_limits() (#787204)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Pass Partition object to get_filesystem_limits() (#787204)
- Date: Sun, 28 Jan 2018 17:15:46 +0000 (UTC)
commit 668957c0a40e74cdcb988d8d837084d459169172
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Tue Jan 16 09:28:06 2018 +0000
Pass Partition object to get_filesystem_limits() (#787204)
As described in the previous commit, this is so that file system
specific implementations can dynamically determine size limits based on
Partition object attributes: such as the device sector size and the file
system block size. (Assuming set_used_sectors() sets
partition.fs_block_size for the type of file system in question).
Bug 787204 - Minimum and maximum size of the UDF partition/disk
include/FileSystem.h | 6 ++++--
src/Dialog_Partition_New.cc | 4 ++--
src/GParted_Core.cc | 2 +-
src/Win_GParted.cc | 12 ++++++++----
4 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/include/FileSystem.h b/include/FileSystem.h
index 0462eb7..43d3675 100644
--- a/include/FileSystem.h
+++ b/include/FileSystem.h
@@ -62,7 +62,7 @@ public:
static const Glib::ustring get_generic_text( CUSTOM_TEXT ttype, int index = 0 ) ;
virtual FS get_filesystem_support() = 0 ;
- virtual FS_Limits get_filesystem_limits() const { return fs_limits; };
+ virtual FS_Limits get_filesystem_limits( const Partition & partition ) const { return fs_limits; };
virtual bool is_busy( const Glib::ustring & path ) { return false ; } ;
virtual void set_used_sectors( Partition & partition ) {};
virtual void read_label( Partition & partition ) {};
@@ -100,7 +100,9 @@ protected:
Glib::ustring mk_temp_dir( const Glib::ustring & infix, OperationDetail & operationdetail ) ;
void rm_temp_dir( const Glib::ustring dir_name, OperationDetail & operationdetail ) ;
- FS_Limits fs_limits; // File system minimum and maximum size limits
+ FS_Limits fs_limits; // File system minimum and maximum size limits. In derived
+ // classes either assign fixed values in get_filesystem_support()
+ // or implement get_filesystem_limits() for dynamic values.
//those are used in several places..
Glib::ustring output, error ;
diff --git a/src/Dialog_Partition_New.cc b/src/Dialog_Partition_New.cc
index c7bc656..b7dce44 100644
--- a/src/Dialog_Partition_New.cc
+++ b/src/Dialog_Partition_New.cc
@@ -343,7 +343,7 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
FileSystem *filesystem_object = GParted_Core::get_filesystem_object( fs.filesystem );
fs_limits = FS_Limits(); // Copy new default no limits struct
if ( filesystem_object != NULL )
- fs_limits = filesystem_object->get_filesystem_limits();
+ fs_limits = filesystem_object->get_filesystem_limits( *new_partition );
if ( fs_limits.min_size < MEBIBYTE )
fs_limits.min_size = MEBIBYTE;
@@ -438,7 +438,7 @@ Byte_Value Dialog_Partition_New::get_filesystem_min_limit( FILESYSTEM fstype )
FileSystem *filesystem_object = GParted_Core::get_filesystem_object( fstype );
FS_Limits fs_limits;
if ( filesystem_object != NULL )
- fs_limits = filesystem_object->get_filesystem_limits();
+ fs_limits = filesystem_object->get_filesystem_limits( *new_partition );
return fs_limits.min_size;
}
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 3c493cb..22345ac 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1869,7 +1869,7 @@ bool GParted_Core::create( Partition & new_partition, OperationDetail & operatio
FileSystem *p_filesystem = get_filesystem_object( new_partition.filesystem );
FS_Limits fs_limits;
if ( p_filesystem != NULL )
- fs_limits = p_filesystem->get_filesystem_limits();
+ fs_limits = p_filesystem->get_filesystem_limits( new_partition );
success = create_partition( new_partition, operationdetail,
fs_limits.min_size / new_partition.sector_size );
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index dc7a974..00e2fb0 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1794,12 +1794,13 @@ void Win_GParted::activate_resize()
}
Partition * working_ptn;
- const FILESYSTEM fstype = selected_partition_ptr->get_filesystem_partition().filesystem;
+ const Partition & selected_filesystem_ptn = selected_partition_ptr->get_filesystem_partition();
+ const FILESYSTEM fstype = selected_filesystem_ptn.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();
+ fs_limits = filesystem_object->get_filesystem_limits( selected_filesystem_ptn );
if ( selected_partition_ptr->filesystem == FS_LUKS && selected_partition_ptr->busy )
{
@@ -1945,7 +1946,7 @@ void Win_GParted::activate_paste()
copied_filesystem_ptn.filesystem );
FS_Limits fs_limits;
if ( filesystem_object != NULL )
- fs_limits = filesystem_object->get_filesystem_limits();
+ fs_limits = filesystem_object->get_filesystem_limits( copied_filesystem_ptn );
// We don't want the messages, mount points or name of the source
// partition for the new partition being created.
@@ -2304,6 +2305,9 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
false );
// Leave sector usage figures as new Partition object defaults of
// -1, -1, 0 (_used, _unused, _unallocated) representing unknown.
+ // Also leaves fs_block_size default of -1 so that FileSystem derived
+ // get_filesystem_limits() call below can differentiate reformat to same
+ // file system case apart from resize case.
}
temp_ptn->name = selected_partition_ptr->name;
temp_ptn->status = STAT_FORMATTED;
@@ -2312,7 +2316,7 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
const FileSystem *filesystem_object = gparted_core.get_filesystem_object( new_fs );
FS_Limits fs_limits;
if ( filesystem_object != NULL )
- fs_limits = filesystem_object->get_filesystem_limits();
+ fs_limits = filesystem_object->get_filesystem_limits( temp_ptn->get_filesystem_partition() );
bool encrypted = false;
if ( selected_partition_ptr->filesystem == FS_LUKS && selected_partition_ptr->busy )
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]