From d7a16d3c2ff2975d317f4cb88fb03660ae9a9c59 Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Wed, 15 Feb 2006 22:32:54 +0000 Subject: [PATCH] support partitions with multiple mountpoints (see also #330327) * include/GParted_Core.h, include/Partition.h, src/Dialog_Partition_Info.cc, src/GParted_Core.cc, src/Partition.cc, src/TreeView_Detail.cc, src/Win_GParted.cc: support partitions with multiple mountpoints (see also #330327) --- ChangeLog | 11 +++++++++++ include/GParted_Core.h | 13 +++++++------ include/Partition.h | 2 +- src/Dialog_Partition_Info.cc | 7 ++++--- src/GParted_Core.cc | 14 +++++++------- src/Partition.cc | 3 ++- src/TreeView_Detail.cc | 9 +++++---- src/Win_GParted.cc | 11 ++++++----- 8 files changed, 43 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7ab2fbc7..f27c3ead 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-02-15 Bart Hakvoort + + * include/GParted_Core.h, + include/Partition.h, + src/Dialog_Partition_Info.cc, + src/GParted_Core.cc, + src/Partition.cc, + src/TreeView_Detail.cc, + src/Win_GParted.cc: support partitions with multiple mountpoints + (see also #330327) + 2006-02-15 Bart Hakvoort * wrap mount/umount/swapon/swapoff instead of implementing it diff --git a/include/GParted_Core.h b/include/GParted_Core.h index cb86050d..91be41e1 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -99,21 +99,22 @@ private: bool open_device( const Glib::ustring & device_path ) ; bool open_device_and_disk( const Glib::ustring & device_path, bool strict = true ) ; - void close_device_and_disk( ) ; - bool commit( ) ; + void close_device_and_disk() ; + bool commit() ; std::vector FILESYSTEMS ; FileSystem * p_filesystem ; - std::vector flags; + std::vector flags; Glib::ustring temp ; Partition partition_temp ; FS fs ; std::vector device_paths ; bool probe_devices ; - std::map mount_info ; - std::map short_paths ; - std::map::iterator iter ; + std::map< Glib::ustring, std::vector > mount_info ; + std::map< Glib::ustring, Glib::ustring > short_paths ; + std::map< Glib::ustring, Glib::ustring >::iterator iter ; + std::map< Glib::ustring, std::vector >::iterator iter_mp ; PedDevice *lp_device ; PedDisk *lp_disk ; diff --git a/include/Partition.h b/include/Partition.h index 93d319a1..e703e998 100644 --- a/include/Partition.h +++ b/include/Partition.h @@ -94,7 +94,7 @@ public: bool busy; Glib::ustring error; Glib::ustring flags; - Glib::ustring mountpoint ; + std::vector mountpoints ; std::vector logicals ; diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc index cf1fcfee..4cf47882 100644 --- a/src/Dialog_Partition_Info.cc +++ b/src/Dialog_Partition_Info.cc @@ -183,14 +183,15 @@ void Dialog_Partition_Info::Display_Info( ) //status Glib::ustring str_temp ; table ->attach( * Utils::mk_label( "" + (Glib::ustring) _( "Status:" ) + "" ), 0,1, top, bottom, Gtk::FILL) ; - if ( partition.busy ) + if ( partition .busy ) { if ( partition .type == GParted::TYPE_EXTENDED ) str_temp = _("Busy (At least one logical partition is mounted)" ) ; else if ( partition .filesystem == FS_LINUX_SWAP ) str_temp = _("Active") ; - else if ( ! partition .mountpoint .empty() ) - str_temp = String::ucompose( _("Mounted on %1"), partition .mountpoint ) ; + else if ( partition .mountpoints .size() ) + str_temp = String::ucompose( _("Mounted on %1"), + Glib::build_path( ", ", partition .mountpoints ) ) ; else str_temp = _("Unable to find mountpoint") ; } diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 625eb061..02d0d76e 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -195,7 +195,7 @@ void GParted_Core::init_maps() if ( index < line .length() ) line .replace( index, 4, " " ) ; - mount_info[ node ] = line ; + mount_info[ node ] .push_back( line ) ; } proc_mounts .close() ; @@ -211,7 +211,7 @@ void GParted_Core::init_maps() sscanf( line .c_str(), "%255s %255s", node, mountpoint ) == 2 && static_cast( mountpoint ) == "/" ) { - mount_info[ node ] = "/" ; + mount_info[ node ] .push_back( "/" ) ; break ; } @@ -377,11 +377,11 @@ void GParted_Core::set_mountpoints( std::vector & partitions ) { if ( partitions[ t ] .type == GParted::TYPE_PRIMARY || partitions[ t ] .type == GParted::TYPE_LOGICAL ) { - iter = mount_info .find( partitions[ t ] .partition ); - if ( iter != mount_info .end() ) + iter_mp = mount_info .find( partitions[ t ] .partition ); + if ( iter_mp != mount_info .end() ) { - partitions[ t ] .mountpoint = iter ->second ; - mount_info .erase( iter ) ; + partitions[ t ] .mountpoints = iter_mp ->second ; + mount_info .erase( iter_mp ) ; } } else if ( partitions[ t ] .type == GParted::TYPE_EXTENDED ) @@ -433,7 +433,7 @@ void GParted_Core::set_used_sectors( std::vector & partitions ) { if ( partitions[ t ] .busy ) { - if ( statvfs( partitions[ t ] .mountpoint .c_str(), &sfs ) == 0 ) + if ( statvfs( partitions[ t ] .mountpoints .back() .c_str(), &sfs ) == 0 ) partitions[ t ] .Set_Unused( sfs .f_bfree * (sfs .f_bsize / 512) ) ; } else diff --git a/src/Partition.cc b/src/Partition.cc index 4b965acb..5dc80545 100644 --- a/src/Partition.cc +++ b/src/Partition.cc @@ -27,7 +27,7 @@ Partition::Partition() void Partition::Reset() { - partition = realpath = error = flags = mountpoint = "" ; + partition = realpath = error = flags = "" ; status = GParted::STAT_REAL ; type = GParted::TYPE_UNALLOCATED ; filesystem = GParted::FS_UNALLOCATED ; @@ -35,6 +35,7 @@ void Partition::Reset() color .set( "black" ) ; inside_extended = busy = strict = false ; logicals .clear() ; + mountpoints .clear() ; } void Partition::Set( const Glib::ustring & device_path, diff --git a/src/TreeView_Detail.cc b/src/TreeView_Detail.cc index b46cbcf0..c5bf092d 100644 --- a/src/TreeView_Detail.cc +++ b/src/TreeView_Detail.cc @@ -91,12 +91,12 @@ void TreeView_Detail::load_partitions( const std::vector & partitions childrow = *( treestore_detail ->append( row.children() ) ); create_row( childrow, partitions[ i ] .logicals[ t ] ); - if ( ! partitions[ i ] .logicals[ t ] .mountpoint .empty() ) + if ( partitions[ i ] .logicals[ t ] .mountpoints .size() ) mount_info = true ; } } - if ( ! partitions[ i ] .mountpoint .empty() ) + if ( partitions[ i ] .mountpoints .size() ) mount_info = true ; } @@ -161,8 +161,9 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition Utils::Get_Filesystem_String( partition .filesystem ) ; //mountpoint - treerow[ treeview_detail_columns .mountpoint ] = partition .mountpoint ; - + treerow[ treeview_detail_columns .mountpoint ] = + Glib::build_path( ", ", partition .mountpoints ) ; + //size treerow[ treeview_detail_columns .size ] = Utils::format_size( partition .get_length() ) ; diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index d60ef0ae..8e0b01fc 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -1346,15 +1346,16 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs ) void Win_GParted::thread_unmount_partition( bool * succes, Glib::ustring * error ) { - //FIXME: umount all targets of this device.. the aim is to get it free.. - *succes = ! Utils::execute_command( "umount " + selected_partition .partition, str_temp, *error ) ; + *succes = true ; + for ( unsigned int t = 0 ; t < selected_partition .mountpoints .size() && *succes ; t++ ) + *succes = ! Utils::execute_command( "umount -v " + selected_partition .mountpoints[ t ], str_temp, *error ) ; pulse = false ; } void Win_GParted::activate_unmount() { - bool succes = false ; + bool succes ; Glib::ustring error ; pulse = true ; @@ -1383,9 +1384,9 @@ void Win_GParted::activate_unmount() void Win_GParted::thread_toggle_swap( bool * succes, Glib::ustring * error ) { if ( selected_partition .busy ) - *succes = ! Utils::execute_command( "swapoff " + selected_partition .partition, str_temp, *error ) ; + *succes = ! Utils::execute_command( "swapoff -v " + selected_partition .partition, str_temp, *error ) ; else - *succes = ! Utils::execute_command( "swapon " + selected_partition .partition, str_temp, *error ) ; + *succes = ! Utils::execute_command( "swapon -v " + selected_partition .partition, str_temp, *error ) ; pulse = false ; }