improved disabling of automounting. It's still somewhat crude, but right
* include/GParted_Core.h, src/GParted_Core.cc: improved disabling of automounting. It's still somewhat crude, but right now it's ok for some semi-public testing. I'll do some cleanups tomorrow morning. * src/Dialog_Progress.cc: added FIXME
This commit is contained in:
parent
26da768ee0
commit
3a918a337b
|
@ -1,3 +1,11 @@
|
|||
2006-04-02 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/GParted_Core.h,
|
||||
src/GParted_Core.cc: improved disabling of automounting. It's still
|
||||
somewhat crude, but right now it's ok for some semi-public testing.
|
||||
I'll do some cleanups tomorrow morning.
|
||||
* src/Dialog_Progress.cc: added FIXME
|
||||
|
||||
2006-04-02 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/GParted_Core.h,
|
||||
|
|
|
@ -94,7 +94,7 @@ private:
|
|||
void set_proper_filesystem( const FILESYSTEM & filesystem ) ;
|
||||
bool set_partition_type( const Partition & partition,
|
||||
std::vector<OperationDetails> & operation_details ) ;
|
||||
bool wait_for_node( const Glib::ustring & node ) ;
|
||||
bool wait_for_node( const Glib::ustring & node, bool disable_automount = false ) ;
|
||||
bool erase_filesystem_signatures( const Partition & partition ) ;
|
||||
|
||||
bool open_device( const Glib::ustring & device_path ) ;
|
||||
|
@ -120,6 +120,7 @@ private:
|
|||
std::map< Glib::ustring, std::vector<Glib::ustring> >::iterator iter_mp ;
|
||||
|
||||
std::vector<Glib::ustring> pmount_locked_partitions ;
|
||||
Glib::ustring PID ;
|
||||
|
||||
PedDevice *lp_device ;
|
||||
PedDisk *lp_disk ;
|
||||
|
|
|
@ -249,9 +249,9 @@ void Dialog_Progress::on_expander_changed()
|
|||
}
|
||||
|
||||
void Dialog_Progress::on_cell_data_description( Gtk::CellRenderer * renderer, const Gtk::TreeModel::iterator & iter )
|
||||
{
|
||||
{//FIXME: markup tags in the text should be escaped (e.g. <device> will interfere with the real tags)
|
||||
dynamic_cast<Gtk::CellRendererText *>( renderer ) ->property_markup() =
|
||||
static_cast<Gtk::TreeRow>( * iter )[ treeview_operations_columns .operation_description ] ;
|
||||
static_cast<Gtk::TreeRow>( *iter )[ treeview_operations_columns .operation_description ] ;
|
||||
}
|
||||
|
||||
void * Dialog_Progress::static_pthread_apply_operation( void * p_dialog_progress )
|
||||
|
|
|
@ -51,6 +51,8 @@ GParted_Core::GParted_Core()
|
|||
lp_disk = NULL ;
|
||||
lp_partition = NULL ;
|
||||
p_filesystem = NULL ;
|
||||
|
||||
PID = Utils::num_to_str( getpid() ) ;
|
||||
|
||||
ped_exception_set_handler( ped_exception_handler ) ;
|
||||
|
||||
|
@ -444,11 +446,12 @@ void GParted_Core::disable_automount( const std::vector<Partition> & partitions
|
|||
if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
|
||||
disable_automount( partitions[ t ] .logicals ) ;
|
||||
|
||||
if ( std::find( pmount_locked_partitions .begin(),
|
||||
if ( partitions[ t ] .type != GParted::TYPE_UNALLOCATED &&
|
||||
std::find( pmount_locked_partitions .begin(),
|
||||
pmount_locked_partitions .end(),
|
||||
partitions[ t ] .get_path() ) == pmount_locked_partitions .end() )
|
||||
{
|
||||
Utils::execute_command( "pmount --lock " + partitions[ t ] .get_path() + " " + Utils::num_to_str( getpid() ) ) ;
|
||||
Utils::execute_command( "pmount --lock " + partitions[ t ] .get_path() + " " + PID ) ;
|
||||
|
||||
pmount_locked_partitions .push_back( partitions[ t ] .get_path() ) ;
|
||||
}
|
||||
|
@ -683,6 +686,10 @@ bool GParted_Core::Delete( const Partition & partition, std::vector<OperationDet
|
|||
lp_disk,
|
||||
(partition .sector_end + partition .sector_start) / 2 ) ;
|
||||
|
||||
//remove the lock (if it exists)
|
||||
if ( ! Glib::find_program_in_path( "pmount" ) .empty() )
|
||||
Utils::execute_command( "pmount --unlock " + partition .get_path() + " " + PID ) ;
|
||||
|
||||
return_value = ped_disk_delete_partition( lp_disk, lp_partition ) && commit() ;
|
||||
sleep( 1 ) ; //give the kernel some time to reread the partitiontable
|
||||
|
||||
|
@ -1009,17 +1016,17 @@ bool GParted_Core::create_empty_partition( Partition & new_partition,
|
|||
|
||||
ped_constraint_destroy( constraint );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
close_device_and_disk() ;
|
||||
}
|
||||
|
||||
|
||||
if ( new_partition .partition_number > 0 &&
|
||||
(
|
||||
new_partition .type == GParted::TYPE_EXTENDED ||
|
||||
(
|
||||
wait_for_node( new_partition .get_path() ) &&
|
||||
wait_for_node( new_partition .get_path(), ! Glib::find_program_in_path( "pmount" ) .empty() ) &&
|
||||
erase_filesystem_signatures( new_partition )
|
||||
)
|
||||
)
|
||||
|
@ -1027,7 +1034,7 @@ bool GParted_Core::create_empty_partition( Partition & new_partition,
|
|||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
return new_partition .partition_number > 0 ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1038,7 +1045,7 @@ bool GParted_Core::create_empty_partition( Partition & new_partition,
|
|||
operation_details .back() .status = OperationDetails::ERROR ;
|
||||
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool GParted_Core::resize_container_partition( const Partition & partition_old,
|
||||
|
@ -1262,20 +1269,38 @@ bool GParted_Core::set_partition_type( const Partition & partition,
|
|||
return return_value ;
|
||||
}
|
||||
|
||||
bool GParted_Core::wait_for_node( const Glib::ustring & node )
|
||||
bool GParted_Core::wait_for_node( const Glib::ustring & node, bool disable_automount )
|
||||
{
|
||||
//we'll loop for 10 seconds or till 'node' appeares...
|
||||
for( short t = 0 ; t < 50 ; t++ )
|
||||
if ( disable_automount )
|
||||
{
|
||||
//FIXME: find a better way to check if a file exists
|
||||
//the current way is suboptimal (at best)
|
||||
if ( Glib::file_test( node, Glib::FILE_TEST_EXISTS ) )
|
||||
{
|
||||
sleep( 2 ) ; //apperantly the node isn't available immediatly after file_test returns succesfully :/
|
||||
return true ;
|
||||
for( short t = 0 ; t < 50 ; t++ )
|
||||
{
|
||||
if ( ! Utils::execute_command( "pmount --lock " + node + " " + PID ) )
|
||||
{
|
||||
//apperantly the node isn't available immediatly after file_test returns succesfully :/
|
||||
sleep( 2 ) ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
usleep( 200000 ) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( short t = 0 ; t < 50 ; t++ )
|
||||
{
|
||||
//FIXME: find a better way to check if a file exists
|
||||
//the current way is suboptimal (at best)
|
||||
if ( Glib::file_test( node, Glib::FILE_TEST_EXISTS ) )
|
||||
{
|
||||
//same issue
|
||||
sleep( 2 ) ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
usleep( 200000 ) ; //200 milliseconds
|
||||
}
|
||||
else
|
||||
usleep( 200000 ) ; //200 milliseconds
|
||||
}
|
||||
|
||||
return false ;
|
||||
|
@ -1371,7 +1396,7 @@ GParted_Core::~GParted_Core()
|
|||
delete p_filesystem ;
|
||||
|
||||
for ( unsigned int t = 0 ; t < pmount_locked_partitions .size() ; t++ )
|
||||
Utils::execute_command( "pmount --unlock " + pmount_locked_partitions[ t ] + " " + Utils::num_to_str( getpid() ) ) ;
|
||||
Utils::execute_command( "pmount --unlock " + pmount_locked_partitions[ t ] + " " + PID ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
Loading…
Reference in New Issue