Every devicescan now tests on beforehand if the kernel is able to reread
* Every devicescan now tests on beforehand if the kernel is able to reread the partitiontable. If the kernel is unable to do this, i disallow most operations. This may seem weird and even a bad thing to do, but the fact is it protects the innocent user from a lot of potential damage. Till the linuxkernel is able to reread partitiontables no matter what, this seems to be the best option. Of course a dialog with information will popup whenever such a situation is encountered. In a next release i might consider adding an 'advanced mode' for users who know what they're doing.
This commit is contained in:
parent
8e5f36dcbf
commit
286579d578
|
@ -1,3 +1,11 @@
|
|||
2004-11-29 Bart Hakvoort <gparted@users.sf.net>
|
||||
|
||||
* Every devicescan now tests on beforehand if the kernel is able to reread the partitiontable. If the kernel is unable to do
|
||||
this, i disallow most operations. This may seem weird and even a bad thing to do, but the fact is it protects
|
||||
the innocent user from a lot of potential damage. Till the linuxkernel is able to reread partitiontables no matter what, this seems
|
||||
to be the best option. Of course a dialog with information will popup whenever such a situation is encountered.
|
||||
In a next release i might consider adding an 'advanced mode' for users who know what they're doing.
|
||||
|
||||
2004-11-28 Alessio Frusciante <algol@firenze.linux.it>
|
||||
|
||||
* configure.in: Added "it" (Italian) to ALL_LINGUAS.
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
Glib::ustring disktype;
|
||||
int max_prims ;
|
||||
bool busy ;
|
||||
bool readonly ;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ class Dialog_Partition_New : public Dialog_Base_Partition
|
|||
{
|
||||
public:
|
||||
Dialog_Partition_New() ;
|
||||
void Set_Data( const Partition & partition, bool any_extended, unsigned short new_count, const std::vector <FS> & FILESYSTEMS );
|
||||
void Set_Data( const Partition & partition, bool any_extended, unsigned short new_count, const std::vector <FS> & FILESYSTEMS, bool only_unformatted );
|
||||
Partition Get_New_Partition() ;//overridden function
|
||||
|
||||
|
||||
private:
|
||||
void Build_Filesystems_Menu() ;
|
||||
void Build_Filesystems_Menu( bool only_unformatted ) ;
|
||||
|
||||
Gtk::Table table_create;
|
||||
Gtk::OptionMenu optionmenu_type, optionmenu_filesystem;
|
||||
|
@ -46,7 +46,7 @@ private:
|
|||
void optionmenu_changed( bool );
|
||||
|
||||
Gdk::Color color_temp;
|
||||
unsigned short new_count ;
|
||||
unsigned short new_count, first_creatable_fs ;
|
||||
};
|
||||
|
||||
} //GParted
|
||||
|
|
|
@ -32,7 +32,7 @@ void Device::Reset( )
|
|||
heads = sectors = cylinders = 0 ;
|
||||
model = path = realpath = disktype = "" ;
|
||||
max_prims = 0 ;
|
||||
busy = false ;
|
||||
busy = readonly = false ;
|
||||
}
|
||||
|
||||
int Device::Get_Highest_Logical_Busy( )
|
||||
|
|
|
@ -37,7 +37,7 @@ Dialog_Partition_New::Dialog_Partition_New( )
|
|||
frame_resizer_base ->set_used( 0 ) ;
|
||||
}
|
||||
|
||||
void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_extended, unsigned short new_count, const std::vector <FS> & FILESYSTEMS )
|
||||
void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_extended, unsigned short new_count, const std::vector <FS> & FILESYSTEMS, bool only_unformatted )
|
||||
{
|
||||
this ->new_count = new_count;
|
||||
this ->selected_partition = partition;
|
||||
|
@ -83,10 +83,10 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
|
|||
//filesystems to choose from
|
||||
table_create.attach( * mk_label( (Glib::ustring) _("Filesystem:") + "\t" ), 0,1,1,2,Gtk::FILL);
|
||||
|
||||
Build_Filesystems_Menu() ;
|
||||
Build_Filesystems_Menu( only_unformatted ) ;
|
||||
|
||||
optionmenu_filesystem.set_menu( menu_filesystem );
|
||||
optionmenu_filesystem.signal_changed().connect( sigc::bind<bool>(sigc::mem_fun(*this, &Dialog_Partition_New::optionmenu_changed), false) );
|
||||
optionmenu_filesystem .set_menu( menu_filesystem );
|
||||
optionmenu_filesystem .signal_changed().connect( sigc::bind<bool>(sigc::mem_fun(*this, &Dialog_Partition_New::optionmenu_changed), false) );
|
||||
table_create.attach( optionmenu_filesystem, 1,2,1,2,Gtk::FILL);
|
||||
|
||||
//set some widely used values...
|
||||
|
@ -95,24 +95,25 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
|
|||
TOTAL_MB = this ->selected_partition .Get_Length_MB() ;
|
||||
MB_PER_PIXEL = (double) TOTAL_MB / 500 ;
|
||||
|
||||
//set spinbuttons
|
||||
//set spinbuttons initial values( seems a bit redundant )
|
||||
GRIP = true ; //prevents on spinbutton_changed from getting activated prematurely
|
||||
|
||||
spinbutton_before .set_range( 0, TOTAL_MB -1 ) ;//mind the -1 !!
|
||||
spinbutton_before .set_range( 0, TOTAL_MB -1 ) ;
|
||||
spinbutton_before .set_value( 0 ) ;
|
||||
|
||||
spinbutton_size .set_range( 1, TOTAL_MB ) ;
|
||||
spinbutton_size .set_value( TOTAL_MB ) ;
|
||||
|
||||
spinbutton_after .set_range( 0, TOTAL_MB -1 ) ;//mind the -1 !!
|
||||
spinbutton_after .set_range( 0, TOTAL_MB -1 ) ;
|
||||
spinbutton_after .set_value( 0 ) ;
|
||||
|
||||
GRIP = false ;
|
||||
|
||||
//set contents of label_minmax
|
||||
Set_MinMax_Text( 1, TOTAL_MB ) ;
|
||||
|
||||
this ->show_all_children() ;
|
||||
//set first enabled filesystem
|
||||
optionmenu_filesystem .set_history( first_creatable_fs ) ;
|
||||
optionmenu_changed( false ) ;
|
||||
|
||||
this ->show_all_children( ) ;
|
||||
}
|
||||
|
||||
Partition Dialog_Partition_New::Get_New_Partition()
|
||||
|
@ -161,8 +162,6 @@ Partition Dialog_Partition_New::Get_New_Partition()
|
|||
return part_temp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Dialog_Partition_New::optionmenu_changed( bool type )
|
||||
{
|
||||
//optionmenu_type
|
||||
|
@ -178,7 +177,7 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
|||
{
|
||||
menu_filesystem .items( ) .remove( menu_filesystem .items( ) .back( ) ) ;
|
||||
optionmenu_filesystem .set_sensitive( true ) ;
|
||||
optionmenu_filesystem .set_history( 0 ) ;
|
||||
optionmenu_filesystem .set_history( first_creatable_fs ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,10 +210,8 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
|||
|
||||
//set contents of label_minmax
|
||||
Set_MinMax_Text( MIN, MAX ) ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//set fitting resizer colors
|
||||
//backgroundcolor..
|
||||
optionmenu_type.get_history() == 2 ? color_temp .set( "darkgrey" ) : color_temp .set( "white" ) ;
|
||||
|
@ -224,19 +221,30 @@ void Dialog_Partition_New::optionmenu_changed( bool type )
|
|||
color_temp .set( Get_Color( FILESYSTEMS[ optionmenu_filesystem.get_history() ] .filesystem ) ) ;
|
||||
frame_resizer_base ->set_rgb_partition_color( color_temp ) ;
|
||||
|
||||
frame_resizer_base ->Draw_Partition() ;
|
||||
if ( this ->is_realized( ) )
|
||||
frame_resizer_base ->Draw_Partition( ) ;
|
||||
}
|
||||
|
||||
void Dialog_Partition_New::Build_Filesystems_Menu()
|
||||
void Dialog_Partition_New::Build_Filesystems_Menu( bool only_unformatted )
|
||||
{
|
||||
//fill the filesystem menu with the filesystems (except for extended)
|
||||
for ( unsigned int t=0 ; t < FILESYSTEMS .size() -1 ; t++ )
|
||||
for ( unsigned int t = 0 ; t < FILESYSTEMS .size( ) -1 ; t++ )
|
||||
{
|
||||
menu_filesystem .items() .push_back( Gtk::Menu_Helpers::MenuElem( FILESYSTEMS[ t ] .filesystem ) ) ;
|
||||
menu_filesystem .items()[ t ] .set_sensitive( FILESYSTEMS[ t ] .create ) ;
|
||||
menu_filesystem .items( ) .push_back( Gtk::Menu_Helpers::MenuElem( FILESYSTEMS[ t ] .filesystem ) ) ;
|
||||
menu_filesystem .items( )[ t ] .set_sensitive( FILESYSTEMS[ t ] .create && ! only_unformatted ) ;
|
||||
}
|
||||
|
||||
//unformatted is always available
|
||||
menu_filesystem .items( ) .back( ) .set_sensitive( true ) ;
|
||||
|
||||
//find and set first enabled filesystem
|
||||
for ( unsigned int t = 0 ; t < menu_filesystem .items( ) .size( ) ; t++ )
|
||||
if ( menu_filesystem .items( )[ t ] .sensitive( ) )
|
||||
{
|
||||
first_creatable_fs = t ;
|
||||
break ;
|
||||
}
|
||||
|
||||
//check if selected unallocated is big enough for fs'es with min. size
|
||||
//fat16
|
||||
if ( this ->selected_partition .Get_Length_MB() < 32 )
|
||||
|
|
|
@ -94,9 +94,9 @@ void GParted_Core::get_devices( std::vector<Device> & devices, bool deep_scan )
|
|||
{
|
||||
temp_device .disktype = disk ->type ->name ;
|
||||
temp_device .max_prims = ped_disk_get_max_primary_partition_count( disk ) ;
|
||||
temp_device .readonly = ! ped_disk_commit_to_os( disk ) ;
|
||||
|
||||
set_device_partitions( temp_device, deep_scan ) ;
|
||||
|
||||
}
|
||||
//harddisk without disklabel
|
||||
else
|
||||
|
@ -225,7 +225,6 @@ void GParted_Core::set_device_partitions( Device & device, bool deep_scan )
|
|||
//next partition (if any)
|
||||
c_partition = ped_disk_next_partition ( disk, c_partition ) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int GParted_Core::get_estimated_time( const Operation & operation )
|
||||
|
|
|
@ -586,7 +586,7 @@ void Win_GParted::Set_Valid_Operations()
|
|||
allow_new( true );
|
||||
|
||||
//find out if there is a copied partition and if it fits inside this unallocated space
|
||||
if ( copied_partition .partition != "NONE" )
|
||||
if ( copied_partition .partition != "NONE" && ! devices[ current_device ] .readonly )
|
||||
{
|
||||
//calculate cylindersize
|
||||
long cylinder_size = Sector_To_MB( devices[ current_device ] .heads * devices[ current_device ] .sectors ) ;
|
||||
|
@ -615,7 +615,7 @@ void Win_GParted::Set_Valid_Operations()
|
|||
allow_convert( true ) ;
|
||||
|
||||
//find out if resizing/moving and copying is possible
|
||||
if ( Get_FS( selected_partition .filesystem, gparted_core .get_fs( ) ) .resize )
|
||||
if ( Get_FS( selected_partition .filesystem, gparted_core .get_fs( ) ) .resize && ! devices[ current_device ] .readonly )
|
||||
{
|
||||
allow_resize( true ) ;
|
||||
|
||||
|
@ -636,7 +636,8 @@ void Win_GParted::Set_Valid_Operations()
|
|||
if ( ! any_logic ) //deletion is only allowed when there are nog logical partitions inside.
|
||||
allow_delete( true ) ;
|
||||
|
||||
allow_resize( true );
|
||||
if ( ! devices[ current_device ] .readonly )
|
||||
allow_resize( true );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -722,6 +723,29 @@ void Win_GParted::menu_gparted_refresh_devices()
|
|||
|
||||
//and refresh the device info...
|
||||
Fill_Label_Device_Info( ) ;
|
||||
|
||||
//show read-only warning if necessary
|
||||
Glib::ustring readonly_paths ;
|
||||
|
||||
for ( unsigned int t = 0 ; t < devices .size( ) ; t++ )
|
||||
if ( devices[ t ] .readonly )
|
||||
readonly_paths += "\n- " + devices[ t ] .path ;
|
||||
|
||||
if ( ! readonly_paths .empty( ) )
|
||||
{
|
||||
str_temp = "<span weight=\"bold\" size=\"larger\">" ;
|
||||
str_temp += _("The kernel is unable to re-read the partitiontables on the following devices:") ;
|
||||
str_temp += readonly_paths ;
|
||||
str_temp += "</span>\n\n" ;
|
||||
|
||||
str_temp += _("Because of this you will only have limited access to these decices.") ;
|
||||
str_temp += "\n" ;
|
||||
str_temp += _("Unmount all mounted partitions on a device to get full access.") ;
|
||||
|
||||
|
||||
Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true ) ;
|
||||
dialog.run( ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void Win_GParted::menu_gparted_quit()
|
||||
|
@ -941,7 +965,7 @@ void Win_GParted::activate_new()
|
|||
else if ( ! max_amount_prim_reached( ) )
|
||||
{
|
||||
Dialog_Partition_New dialog;
|
||||
dialog .Set_Data( selected_partition, any_extended, new_count, gparted_core .get_fs( ) ) ;
|
||||
dialog .Set_Data( selected_partition, any_extended, new_count, gparted_core .get_fs( ), devices [ current_device ] .readonly ) ;
|
||||
dialog .set_transient_for( *this );
|
||||
|
||||
if ( dialog .run( ) == Gtk::RESPONSE_OK )
|
||||
|
|
Loading…
Reference in New Issue