[gparted] Prevent partition table creation if partitions are active
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Prevent partition table creation if partitions are active
- Date: Tue, 10 Aug 2010 19:02:12 +0000 (UTC)
commit 2d4c4017ca740cd46eb89e1b36f40ed7c8aef1e0
Author: Curtis Gedak <gedakc gmail com>
Date: Tue Aug 10 12:59:26 2010 -0600
Prevent partition table creation if partitions are active
Prevent creating new partition tables on devices that have
mounted file systems, or enabled swap space.
Closes Ubuntu launchpad bug #503125 - gparted allows user to
overwrite active mounted partition
https://bugs.launchpad.net/ubuntu/+source/gparted/+bug/503125
src/Win_GParted.cc | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index 2350966..52d4269 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -1937,6 +1937,39 @@ void Win_GParted::activate_mount_partition( unsigned int index )
void Win_GParted::activate_disklabel()
{
+ //If there are active mounted partitions on the device then warn
+ // the user that all partitions must be unactive before creating
+ // a new partition table
+ int active_count = active_partitions_on_device_count( devices[ current_device ] ) ;
+ if ( active_count > 0 )
+ {
+ Glib::ustring tmp_msg =
+ String::ucompose( /*TO TRANSLATORS: Singular case looks like 1 partition is currently active on device /dev/sda. */
+ ngettext( "%1 partition is currently active on device %2."
+ /*TO TRANSLATORS: Plural case looks like 3 partitions are currently active on device /dev/sda. */
+ , "%1 partitions are currently active on device %2."
+ , active_count
+ )
+ , active_count
+ , devices[ current_device ] .get_path()
+ ) ;
+ Gtk::MessageDialog dialog( *this
+ , tmp_msg
+ , false
+ , Gtk::MESSAGE_INFO
+ , Gtk::BUTTONS_OK
+ , true
+ ) ;
+ tmp_msg = _( "A new partition table cannot be created when there are active partitions." ) ;
+ tmp_msg += " " ;
+ tmp_msg += _( "Active partitions are those that are in use, such as a mounted file system, or enabled swap space." ) ;
+ tmp_msg += "\n" ;
+ tmp_msg += _( "Use Partition menu options, such as unmount or swapoff, to deactivate all partitions on this device before creating a new partition table." ) ;
+ dialog .set_secondary_text( tmp_msg ) ;
+ dialog .run() ;
+ return ;
+ }
+
//If there are pending operations then warn the user that these
// operations must either be applied or cleared before creating
// a new partition table.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]