[gparted] Enable resize/move for encrypted file systems (#774818)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Enable resize/move for encrypted file systems (#774818)
- Date: Sat, 14 Jan 2017 15:54:01 +0000 (UTC)
commit e2c70d56390525727744c42b402c3c835b658954
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Wed Nov 9 17:59:02 2016 +0000
Enable resize/move for encrypted file systems (#774818)
A partition containing LUKS encryption can only be moved when closed and
the Device Mapper encryption mapping only exists to be resized when
open. As GParted can't yet open or close LUKS encryption these
restrictions have to be adhered to when composing operations. Also as
encrypted partitions are only being resized when open, additionally
libparted and the kernel have to both be capable of resizing a partition
while in use.
Bug 774818 - Implement LUKS read-write actions NOT requiring a
passphrase
src/Win_GParted.cc | 48 ++++++++++++++++++++++++++++++++++++++----------
src/luks.cc | 10 ++++++++++
2 files changed, 48 insertions(+), 10 deletions(-)
---
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 33b1118..9478906 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1080,9 +1080,9 @@ void Win_GParted::set_valid_operations()
// Reference to the Partition object directly containing the file system.
const Partition & selected_filesystem = selected_partition_ptr->get_filesystem_partition();
- // Get filesystem capabilities
- fs = gparted_core.get_fs( selected_partition_ptr->filesystem );
+ // Get file system and LUKS encryption capabilities
const FS & fs_cap = gparted_core.get_fs( selected_filesystem.filesystem );
+ const FS & enc_cap = gparted_core.get_fs( FS_LUKS );
//if there's something, there's some info ;)
allow_info( true ) ;
@@ -1137,11 +1137,21 @@ void Win_GParted::set_valid_operations()
allow_manage_flags( true );
#ifdef ENABLE_ONLINE_RESIZE
- // Find out if online resizing is possible
- if ( selected_partition_ptr->busy )
- {
- if ( ( fs .online_grow || fs .online_shrink ) && ! devices[ current_device ] .readonly )
- allow_resize( true ) ;
+ // Online resizing always required the ability to update the partition table ...
+ if ( ! devices[current_device].readonly &&
+ selected_filesystem.busy )
+ {
+ // Can the plain file system be online resized?
+ if ( selected_partition_ptr->filesystem != FS_LUKS &&
+ ( fs_cap.online_grow || fs_cap.online_shrink ) )
+ allow_resize( true );
+ // Is resizing an open LUKS mapping and the online file system within
+ // supported?
+ if ( selected_partition_ptr->filesystem == FS_LUKS &&
+ selected_partition_ptr->busy &&
+ ( ( enc_cap.online_grow && fs_cap.online_grow ) ||
+ ( enc_cap.online_shrink && fs_cap.online_shrink ) ) )
+ allow_resize( true );
}
#endif
@@ -1238,10 +1248,28 @@ void Win_GParted::set_valid_operations()
if ( ! selected_partition_ptr->whole_device )
allow_delete( true );
- //find out if resizing/moving is possible
- if ( (fs .grow || fs .shrink || fs .move ) && ! devices[ current_device ] .readonly )
- allow_resize( true ) ;
-
+ // Resizing/moving always requires the ability to update the partition
+ // table ...
+ if ( ! devices[current_device].readonly )
+ {
+ // Can the plain file system be resized or moved?
+ if ( selected_partition_ptr->filesystem != FS_LUKS &&
+ ( fs_cap.grow || fs_cap.shrink || fs_cap.move ) )
+ allow_resize( true );
+ // Is moving this closed LUKS mapping permitted?
+ if ( selected_partition_ptr->filesystem == FS_LUKS &&
+ ! selected_partition_ptr->busy &&
+ enc_cap.move )
+ allow_resize( true );
+ // Is resizing an open LUKS mapping and the file system within
+ // supported?
+ if ( selected_partition_ptr->filesystem == FS_LUKS &&
+ selected_partition_ptr->busy &&
+ ( ( enc_cap.online_grow && fs_cap.grow ) ||
+ ( enc_cap.online_shrink && fs_cap.shrink ) ) )
+ allow_resize( true );
+ }
+
// Only allow copying of real partitions, excluding closed encryption
// (which are only copied while open).
if ( selected_partition_ptr->status == STAT_REAL &&
diff --git a/src/luks.cc b/src/luks.cc
index 8047210..2ec4ef7 100644
--- a/src/luks.cc
+++ b/src/luks.cc
@@ -34,6 +34,16 @@ FS luks::get_filesystem_support()
fs.copy = FS::GPARTED;
fs.online_read = FS::EXTERNAL;
+ fs.move = FS::GPARTED;
+
+#ifdef ENABLE_ONLINE_RESIZE
+ if ( ! Glib::find_program_in_path( "cryptsetup" ).empty() &&
+ Utils::kernel_version_at_least( 3, 6, 0 ) )
+ {
+ fs.online_grow = FS::EXTERNAL;
+ fs.online_shrink = FS::EXTERNAL;
+ }
+#endif
return fs;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]