an initial solution for the automount problem. I still need to add
* include/GParted_Core.h, src/GParted_Core.cc: an initial solution for the automount problem. I still need to add something to prevent just created partitions from getting mounted. (see #324220 for more info)
This commit is contained in:
parent
e933473cfa
commit
26da768ee0
|
@ -1,3 +1,10 @@
|
|||
2006-04-02 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/GParted_Core.h,
|
||||
src/GParted_Core.cc: an initial solution for the automount problem.
|
||||
I still need to add something to prevent just created partitions from
|
||||
getting mounted. (see #324220 for more info)
|
||||
|
||||
2006-04-02 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||
|
||||
* include/Dialog_Filesystems.h,
|
||||
|
|
|
@ -66,6 +66,7 @@ private:
|
|||
GParted::FILESYSTEM get_filesystem() ;
|
||||
bool check_device_path( const Glib::ustring & device_path ) ;
|
||||
void set_device_partitions( Device & device ) ;
|
||||
void disable_automount( const std::vector<Partition> & partitions ) ;
|
||||
void read_mountpoints_from_file( const Glib::ustring & filename,
|
||||
std::map< Glib::ustring, std::vector<Glib::ustring> > & map ) ;
|
||||
void init_maps() ;
|
||||
|
@ -118,6 +119,8 @@ private:
|
|||
std::map< Glib::ustring, Glib::ustring >::iterator iter ;
|
||||
std::map< Glib::ustring, std::vector<Glib::ustring> >::iterator iter_mp ;
|
||||
|
||||
std::vector<Glib::ustring> pmount_locked_partitions ;
|
||||
|
||||
PedDevice *lp_device ;
|
||||
PedDisk *lp_disk ;
|
||||
PedPartition *lp_partition ;
|
||||
|
|
|
@ -185,9 +185,13 @@ void GParted_Core::get_devices( std::vector<Device> & devices )
|
|||
temp_device .max_prims = ped_disk_get_max_primary_partition_count( lp_disk ) ;
|
||||
|
||||
set_device_partitions( temp_device ) ;
|
||||
|
||||
if ( ! Glib::find_program_in_path( "pmount" ) .empty() )
|
||||
disable_automount( temp_device .partitions ) ;
|
||||
|
||||
set_mountpoints( temp_device .partitions ) ;
|
||||
set_used_sectors( temp_device .partitions ) ;
|
||||
|
||||
|
||||
if ( temp_device .highest_busy )
|
||||
temp_device .readonly = ! ped_disk_commit_to_os( lp_disk ) ;
|
||||
}
|
||||
|
@ -432,6 +436,24 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
|
||||
insert_unallocated( device .get_path(), device .partitions, 0, device .length -1, false ) ;
|
||||
}
|
||||
|
||||
void GParted_Core::disable_automount( const std::vector<Partition> & partitions )
|
||||
{
|
||||
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
|
||||
{
|
||||
if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
|
||||
disable_automount( partitions[ t ] .logicals ) ;
|
||||
|
||||
if ( 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() ) ) ;
|
||||
|
||||
pmount_locked_partitions .push_back( partitions[ t ] .get_path() ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
|
||||
{
|
||||
|
@ -1002,7 +1024,7 @@ bool GParted_Core::create_empty_partition( Partition & new_partition,
|
|||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
{
|
||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||
|
||||
return new_partition .partition_number > 0 ;
|
||||
|
@ -1331,7 +1353,7 @@ bool GParted_Core::commit()
|
|||
bool return_value = ped_disk_commit_to_dev( lp_disk ) ;
|
||||
|
||||
ped_disk_commit_to_os( lp_disk ) ;
|
||||
|
||||
|
||||
return return_value ;
|
||||
}
|
||||
|
||||
|
@ -1347,6 +1369,9 @@ GParted_Core::~GParted_Core()
|
|||
{
|
||||
if ( p_filesystem )
|
||||
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() ) ) ;
|
||||
}
|
||||
|
||||
} //GParted
|
||||
|
|
Loading…
Reference in New Issue