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)
This commit is contained in:
Bart Hakvoort 2006-02-15 22:32:54 +00:00
parent a4a5914d15
commit d7a16d3c2f
8 changed files with 43 additions and 27 deletions

View File

@ -1,3 +1,14 @@
2006-02-15 Bart Hakvoort <hakvoort@cvs.gnome.org>
* 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 <hakvoort@cvs.gnome.org> 2006-02-15 Bart Hakvoort <hakvoort@cvs.gnome.org>
* wrap mount/umount/swapon/swapoff instead of implementing it * wrap mount/umount/swapon/swapoff instead of implementing it

View File

@ -99,21 +99,22 @@ private:
bool open_device( const Glib::ustring & device_path ) ; bool open_device( const Glib::ustring & device_path ) ;
bool open_device_and_disk( const Glib::ustring & device_path, bool strict = true ) ; bool open_device_and_disk( const Glib::ustring & device_path, bool strict = true ) ;
void close_device_and_disk( ) ; void close_device_and_disk() ;
bool commit( ) ; bool commit() ;
std::vector<FS> FILESYSTEMS ; std::vector<FS> FILESYSTEMS ;
FileSystem * p_filesystem ; FileSystem * p_filesystem ;
std::vector <PedPartitionFlag> flags; std::vector<PedPartitionFlag> flags;
Glib::ustring temp ; Glib::ustring temp ;
Partition partition_temp ; Partition partition_temp ;
FS fs ; FS fs ;
std::vector<Glib::ustring> device_paths ; std::vector<Glib::ustring> device_paths ;
bool probe_devices ; bool probe_devices ;
std::map<Glib::ustring, Glib::ustring> mount_info ; std::map< Glib::ustring, std::vector<Glib::ustring> > mount_info ;
std::map<Glib::ustring, Glib::ustring> short_paths ; std::map< Glib::ustring, Glib::ustring > short_paths ;
std::map<Glib::ustring, Glib::ustring>::iterator iter ; std::map< Glib::ustring, Glib::ustring >::iterator iter ;
std::map< Glib::ustring, std::vector<Glib::ustring> >::iterator iter_mp ;
PedDevice *lp_device ; PedDevice *lp_device ;
PedDisk *lp_disk ; PedDisk *lp_disk ;

View File

@ -94,7 +94,7 @@ public:
bool busy; bool busy;
Glib::ustring error; Glib::ustring error;
Glib::ustring flags; Glib::ustring flags;
Glib::ustring mountpoint ; std::vector<Glib::ustring> mountpoints ;
std::vector<Partition> logicals ; std::vector<Partition> logicals ;

View File

@ -183,14 +183,15 @@ void Dialog_Partition_Info::Display_Info( )
//status //status
Glib::ustring str_temp ; Glib::ustring str_temp ;
table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Status:" ) + "</b>" ), 0,1, top, bottom, Gtk::FILL) ; table ->attach( * Utils::mk_label( "<b>" + (Glib::ustring) _( "Status:" ) + "</b>" ), 0,1, top, bottom, Gtk::FILL) ;
if ( partition.busy ) if ( partition .busy )
{ {
if ( partition .type == GParted::TYPE_EXTENDED ) if ( partition .type == GParted::TYPE_EXTENDED )
str_temp = _("Busy (At least one logical partition is mounted)" ) ; str_temp = _("Busy (At least one logical partition is mounted)" ) ;
else if ( partition .filesystem == FS_LINUX_SWAP ) else if ( partition .filesystem == FS_LINUX_SWAP )
str_temp = _("Active") ; str_temp = _("Active") ;
else if ( ! partition .mountpoint .empty() ) else if ( partition .mountpoints .size() )
str_temp = String::ucompose( _("Mounted on %1"), partition .mountpoint ) ; str_temp = String::ucompose( _("Mounted on %1"),
Glib::build_path( ", ", partition .mountpoints ) ) ;
else else
str_temp = _("Unable to find mountpoint") ; str_temp = _("Unable to find mountpoint") ;
} }

View File

@ -195,7 +195,7 @@ void GParted_Core::init_maps()
if ( index < line .length() ) if ( index < line .length() )
line .replace( index, 4, " " ) ; line .replace( index, 4, " " ) ;
mount_info[ node ] = line ; mount_info[ node ] .push_back( line ) ;
} }
proc_mounts .close() ; proc_mounts .close() ;
@ -211,7 +211,7 @@ void GParted_Core::init_maps()
sscanf( line .c_str(), "%255s %255s", node, mountpoint ) == 2 && sscanf( line .c_str(), "%255s %255s", node, mountpoint ) == 2 &&
static_cast<Glib::ustring>( mountpoint ) == "/" ) static_cast<Glib::ustring>( mountpoint ) == "/" )
{ {
mount_info[ node ] = "/" ; mount_info[ node ] .push_back( "/" ) ;
break ; break ;
} }
@ -377,11 +377,11 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
{ {
if ( partitions[ t ] .type == GParted::TYPE_PRIMARY || partitions[ t ] .type == GParted::TYPE_LOGICAL ) if ( partitions[ t ] .type == GParted::TYPE_PRIMARY || partitions[ t ] .type == GParted::TYPE_LOGICAL )
{ {
iter = mount_info .find( partitions[ t ] .partition ); iter_mp = mount_info .find( partitions[ t ] .partition );
if ( iter != mount_info .end() ) if ( iter_mp != mount_info .end() )
{ {
partitions[ t ] .mountpoint = iter ->second ; partitions[ t ] .mountpoints = iter_mp ->second ;
mount_info .erase( iter ) ; mount_info .erase( iter_mp ) ;
} }
} }
else if ( partitions[ t ] .type == GParted::TYPE_EXTENDED ) else if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
@ -433,7 +433,7 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions )
{ {
if ( partitions[ t ] .busy ) 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) ) ; partitions[ t ] .Set_Unused( sfs .f_bfree * (sfs .f_bsize / 512) ) ;
} }
else else

View File

@ -27,7 +27,7 @@ Partition::Partition()
void Partition::Reset() void Partition::Reset()
{ {
partition = realpath = error = flags = mountpoint = "" ; partition = realpath = error = flags = "" ;
status = GParted::STAT_REAL ; status = GParted::STAT_REAL ;
type = GParted::TYPE_UNALLOCATED ; type = GParted::TYPE_UNALLOCATED ;
filesystem = GParted::FS_UNALLOCATED ; filesystem = GParted::FS_UNALLOCATED ;
@ -35,6 +35,7 @@ void Partition::Reset()
color .set( "black" ) ; color .set( "black" ) ;
inside_extended = busy = strict = false ; inside_extended = busy = strict = false ;
logicals .clear() ; logicals .clear() ;
mountpoints .clear() ;
} }
void Partition::Set( const Glib::ustring & device_path, void Partition::Set( const Glib::ustring & device_path,

View File

@ -91,12 +91,12 @@ void TreeView_Detail::load_partitions( const std::vector<Partition> & partitions
childrow = *( treestore_detail ->append( row.children() ) ); childrow = *( treestore_detail ->append( row.children() ) );
create_row( childrow, partitions[ i ] .logicals[ t ] ); create_row( childrow, partitions[ i ] .logicals[ t ] );
if ( ! partitions[ i ] .logicals[ t ] .mountpoint .empty() ) if ( partitions[ i ] .logicals[ t ] .mountpoints .size() )
mount_info = true ; mount_info = true ;
} }
} }
if ( ! partitions[ i ] .mountpoint .empty() ) if ( partitions[ i ] .mountpoints .size() )
mount_info = true ; mount_info = true ;
} }
@ -161,8 +161,9 @@ void TreeView_Detail::create_row( const Gtk::TreeRow & treerow, const Partition
Utils::Get_Filesystem_String( partition .filesystem ) ; Utils::Get_Filesystem_String( partition .filesystem ) ;
//mountpoint //mountpoint
treerow[ treeview_detail_columns .mountpoint ] = partition .mountpoint ; treerow[ treeview_detail_columns .mountpoint ] =
Glib::build_path( ", ", partition .mountpoints ) ;
//size //size
treerow[ treeview_detail_columns .size ] = Utils::format_size( partition .get_length() ) ; treerow[ treeview_detail_columns .size ] = Utils::format_size( partition .get_length() ) ;

View File

@ -1346,15 +1346,16 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
void Win_GParted::thread_unmount_partition( bool * succes, Glib::ustring * error ) 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 = true ;
*succes = ! Utils::execute_command( "umount " + selected_partition .partition, str_temp, *error ) ; 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 ; pulse = false ;
} }
void Win_GParted::activate_unmount() void Win_GParted::activate_unmount()
{ {
bool succes = false ; bool succes ;
Glib::ustring error ; Glib::ustring error ;
pulse = true ; pulse = true ;
@ -1383,9 +1384,9 @@ void Win_GParted::activate_unmount()
void Win_GParted::thread_toggle_swap( bool * succes, Glib::ustring * error ) void Win_GParted::thread_toggle_swap( bool * succes, Glib::ustring * error )
{ {
if ( selected_partition .busy ) 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 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 ; pulse = false ;
} }