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>
|
2006-04-02 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
* include/GParted_Core.h,
|
* include/GParted_Core.h,
|
||||||
|
|
|
@ -94,7 +94,7 @@ private:
|
||||||
void set_proper_filesystem( const FILESYSTEM & filesystem ) ;
|
void set_proper_filesystem( const FILESYSTEM & filesystem ) ;
|
||||||
bool set_partition_type( const Partition & partition,
|
bool set_partition_type( const Partition & partition,
|
||||||
std::vector<OperationDetails> & operation_details ) ;
|
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 erase_filesystem_signatures( const Partition & partition ) ;
|
||||||
|
|
||||||
bool open_device( const Glib::ustring & device_path ) ;
|
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::map< Glib::ustring, std::vector<Glib::ustring> >::iterator iter_mp ;
|
||||||
|
|
||||||
std::vector<Glib::ustring> pmount_locked_partitions ;
|
std::vector<Glib::ustring> pmount_locked_partitions ;
|
||||||
|
Glib::ustring PID ;
|
||||||
|
|
||||||
PedDevice *lp_device ;
|
PedDevice *lp_device ;
|
||||||
PedDisk *lp_disk ;
|
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 )
|
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() =
|
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 )
|
void * Dialog_Progress::static_pthread_apply_operation( void * p_dialog_progress )
|
||||||
|
|
|
@ -51,6 +51,8 @@ GParted_Core::GParted_Core()
|
||||||
lp_disk = NULL ;
|
lp_disk = NULL ;
|
||||||
lp_partition = NULL ;
|
lp_partition = NULL ;
|
||||||
p_filesystem = NULL ;
|
p_filesystem = NULL ;
|
||||||
|
|
||||||
|
PID = Utils::num_to_str( getpid() ) ;
|
||||||
|
|
||||||
ped_exception_set_handler( ped_exception_handler ) ;
|
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 )
|
if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
|
||||||
disable_automount( partitions[ t ] .logicals ) ;
|
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(),
|
pmount_locked_partitions .end(),
|
||||||
partitions[ t ] .get_path() ) == 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() ) ;
|
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,
|
lp_disk,
|
||||||
(partition .sector_end + partition .sector_start) / 2 ) ;
|
(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() ;
|
return_value = ped_disk_delete_partition( lp_disk, lp_partition ) && commit() ;
|
||||||
sleep( 1 ) ; //give the kernel some time to reread the partitiontable
|
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 );
|
ped_constraint_destroy( constraint );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
close_device_and_disk() ;
|
close_device_and_disk() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( new_partition .partition_number > 0 &&
|
if ( new_partition .partition_number > 0 &&
|
||||||
(
|
(
|
||||||
new_partition .type == GParted::TYPE_EXTENDED ||
|
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 )
|
erase_filesystem_signatures( new_partition )
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -1027,7 +1034,7 @@ bool GParted_Core::create_empty_partition( Partition & new_partition,
|
||||||
{
|
{
|
||||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
|
|
||||||
return new_partition .partition_number > 0 ;
|
return true ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1038,7 +1045,7 @@ bool GParted_Core::create_empty_partition( Partition & new_partition,
|
||||||
operation_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
|
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GParted_Core::resize_container_partition( const Partition & partition_old,
|
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 ;
|
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...
|
//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
|
for( short t = 0 ; t < 50 ; t++ )
|
||||||
//the current way is suboptimal (at best)
|
{
|
||||||
if ( Glib::file_test( node, Glib::FILE_TEST_EXISTS ) )
|
if ( ! Utils::execute_command( "pmount --lock " + node + " " + PID ) )
|
||||||
{
|
{
|
||||||
sleep( 2 ) ; //apperantly the node isn't available immediatly after file_test returns succesfully :/
|
//apperantly the node isn't available immediatly after file_test returns succesfully :/
|
||||||
return true ;
|
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 ;
|
return false ;
|
||||||
|
@ -1371,7 +1396,7 @@ GParted_Core::~GParted_Core()
|
||||||
delete p_filesystem ;
|
delete p_filesystem ;
|
||||||
|
|
||||||
for ( unsigned int t = 0 ; t < pmount_locked_partitions .size() ; t++ )
|
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
|
} //GParted
|
||||||
|
|
Loading…
Reference in New Issue