mirror of
https://gitlab.gnome.org/GNOME/gparted
synced 2024-09-13 21:21:12 +00:00
Set sector size and add to operation and dialog methods
This change is in preparation for supporting sectors sizes > 512 bytes.
This commit is contained in:
parent
4bcd0a3704
commit
74ecd2ed3f
|
@ -1,5 +1,5 @@
|
|||
/* Copyright (C) 2004 Bart
|
||||
* Copyright (C) 2008 Curtis Gedak
|
||||
* Copyright (C) 2008, 2009, 2010 Curtis Gedak
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
~Dialog_Base_Partition( ) ;
|
||||
|
||||
void Set_Resizer( bool extended ) ;
|
||||
Partition Get_New_Partition( ) ;
|
||||
Partition Get_New_Partition( Byte_Value sector_size ) ;
|
||||
|
||||
protected:
|
||||
enum SPINBUTTON {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* Copyright (C) 2004 Bart
|
||||
/* Copyright (C) 2004 Bart
|
||||
* Copyright (C) 2010 Curtis Gedak
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -29,7 +30,7 @@ public:
|
|||
Dialog_Partition_Copy( const FS & fs, Sector cylinder_size ) ;
|
||||
void Set_Data( const Partition & selected_partition, const Partition & copied_partition );
|
||||
|
||||
Partition Get_New_Partition() ;
|
||||
Partition Get_New_Partition( Byte_Value sector_size ) ;
|
||||
|
||||
private:
|
||||
};
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
bool only_unformatted,
|
||||
Sector cylinder_size,
|
||||
Glib::ustring disktype );
|
||||
Partition Get_New_Partition() ;//overridden function
|
||||
Partition Get_New_Partition( Byte_Value sector_size ) ;//overridden function
|
||||
|
||||
private:
|
||||
void Build_Filesystems_Menu( bool only_unformatted ) ;
|
||||
|
|
|
@ -71,6 +71,7 @@ private:
|
|||
std::vector<Partition> & partitions,
|
||||
Sector start,
|
||||
Sector end,
|
||||
Byte_Value sector_size,
|
||||
bool inside_extended ) ;
|
||||
void set_mountpoints( std::vector<Partition> & partitions ) ;
|
||||
void set_used_sectors( std::vector<Partition> & partitions ) ;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Copyright (C) 2004 Bart
|
||||
* Copyright (C) 2008 Curtis Gedak
|
||||
* Copyright (C) 2008, 2009, 2010 Curtis Gedak
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -59,8 +59,8 @@ public:
|
|||
protected:
|
||||
int find_index_original( const std::vector<Partition> & partitions ) ;
|
||||
int find_index_extended( const std::vector<Partition> & partitions ) ;
|
||||
void insert_unallocated( std::vector<Partition> & partitions, Sector start, Sector end, bool inside_extended );
|
||||
|
||||
void insert_unallocated( std::vector<Partition> & partitions, Sector start, Sector end, Byte_Value sector_size, bool inside_extended );
|
||||
|
||||
int index ;
|
||||
int index_extended ;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Copyright (C) 2004 Bart
|
||||
* Copyright (C) 2008, 2009 Curtis Gedak
|
||||
* Copyright (C) 2008, 2009, 2010 Curtis Gedak
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -64,6 +64,7 @@ public:
|
|||
FILESYSTEM filesystem,
|
||||
Sector sector_start,
|
||||
Sector sector_end,
|
||||
Byte_Value sector_size,
|
||||
bool inside_extended,
|
||||
bool busy ) ;
|
||||
|
||||
|
@ -73,6 +74,7 @@ public:
|
|||
void Set_Unallocated( const Glib::ustring & device_path,
|
||||
Sector sector_start,
|
||||
Sector sector_end,
|
||||
Byte_Value sector_size,
|
||||
bool inside_extended );
|
||||
|
||||
//update partition number (used when a logical partition is deleted)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Copyright (C) 2004 Bart
|
||||
* Copyright (C) 2008, 2009 Curtis Gedak
|
||||
* Copyright (C) 2008, 2009, 2010 Curtis Gedak
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -122,7 +122,7 @@ void Dialog_Base_Partition::Set_Resizer( bool extended )
|
|||
this ->show_all_children() ;
|
||||
}
|
||||
|
||||
Partition Dialog_Base_Partition::Get_New_Partition()
|
||||
Partition Dialog_Base_Partition::Get_New_Partition( Byte_Value sector_size )
|
||||
{
|
||||
//FIXME: Partition size is limited to just less than 1024 TeraBytes due
|
||||
// to the maximum value of signed 4 byte integer.
|
||||
|
|
|
@ -143,14 +143,14 @@ void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, cons
|
|||
this ->show_all_children() ;
|
||||
}
|
||||
|
||||
Partition Dialog_Partition_Copy::Get_New_Partition()
|
||||
Partition Dialog_Partition_Copy::Get_New_Partition( Byte_Value sector_size )
|
||||
{
|
||||
//first call baseclass to get the correct new partition
|
||||
selected_partition = Dialog_Base_Partition::Get_New_Partition() ;
|
||||
|
||||
selected_partition = Dialog_Base_Partition::Get_New_Partition( sector_size ) ;
|
||||
|
||||
//set proper name and status for partition
|
||||
selected_partition .status = GParted::STAT_COPY ;
|
||||
|
||||
|
||||
return selected_partition ;
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
|
|||
this ->show_all_children() ;
|
||||
}
|
||||
|
||||
Partition Dialog_Partition_New::Get_New_Partition()
|
||||
Partition Dialog_Partition_New::Get_New_Partition( Byte_Value sector_size )
|
||||
{
|
||||
Partition part_temp ;
|
||||
PartitionType part_type ;
|
||||
|
@ -193,7 +193,8 @@ Partition Dialog_Partition_New::Get_New_Partition()
|
|||
String::ucompose( _("New Partition #%1"), new_count ),
|
||||
new_count, part_type,
|
||||
FILESYSTEMS[ optionmenu_filesystem .get_history() ] .filesystem,
|
||||
new_start, new_end,
|
||||
new_start, new_end,
|
||||
sector_size,
|
||||
selected_partition .inside_extended, false ) ;
|
||||
|
||||
//Retrieve Label info
|
||||
|
@ -212,6 +213,7 @@ Partition Dialog_Partition_New::Get_New_Partition()
|
|||
UNALLOCATED .Set_Unallocated( part_temp .device_path,
|
||||
part_temp .sector_start,
|
||||
part_temp .sector_end,
|
||||
sector_size,
|
||||
true ) ;
|
||||
part_temp .logicals .push_back( UNALLOCATED ) ;
|
||||
}
|
||||
|
|
|
@ -336,6 +336,7 @@ void GParted_Core::set_devices( std::vector<Device> & devices )
|
|||
partition_temp .Set_Unallocated( temp_device .get_path(),
|
||||
0,
|
||||
temp_device .length,
|
||||
temp_device .sector_size,
|
||||
false );
|
||||
//Place libparted messages in this unallocated partition
|
||||
partition_temp .messages .insert( partition_temp .messages .end(),
|
||||
|
@ -794,6 +795,7 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
get_filesystem(),
|
||||
lp_partition ->geom .start,
|
||||
lp_partition ->geom .end,
|
||||
device .sector_size,
|
||||
lp_partition ->type,
|
||||
partition_is_busy ) ;
|
||||
free( lp_path ) ;
|
||||
|
@ -836,6 +838,7 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
GParted::FS_EXTENDED,
|
||||
lp_partition ->geom .start,
|
||||
lp_partition ->geom .end,
|
||||
device .sector_size,
|
||||
false,
|
||||
partition_is_busy ) ;
|
||||
free( lp_path ) ;
|
||||
|
@ -883,9 +886,10 @@ void GParted_Core::set_device_partitions( Device & device )
|
|||
device .partitions[ EXT_INDEX ] .logicals,
|
||||
device .partitions[ EXT_INDEX ] .sector_start,
|
||||
device .partitions[ EXT_INDEX ] .sector_end,
|
||||
device .sector_size,
|
||||
true ) ;
|
||||
|
||||
insert_unallocated( device .get_path(), device .partitions, 0, device .length -1, false ) ;
|
||||
|
||||
insert_unallocated( device .get_path(), device .partitions, 0, device .length -1, device .sector_size, false ) ;
|
||||
}
|
||||
|
||||
GParted::FILESYSTEM GParted_Core::get_filesystem()
|
||||
|
@ -1079,10 +1083,11 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
|
|||
std::vector<Partition> & partitions,
|
||||
Sector start,
|
||||
Sector end,
|
||||
Byte_Value sector_size,
|
||||
bool inside_extended )
|
||||
{
|
||||
partition_temp .Reset() ;
|
||||
partition_temp .Set_Unallocated( device_path, 0, 0, inside_extended ) ;
|
||||
partition_temp .Set_Unallocated( device_path, 0, 0, sector_size, inside_extended ) ;
|
||||
|
||||
//if there are no partitions at all..
|
||||
if ( partitions .empty() )
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* Copyright (C) 2004 Bart
|
||||
* Copyright (C) 2010 Curtis Gedak
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -42,10 +43,10 @@ int Operation::find_index_extended( const std::vector<Partition> & partitions )
|
|||
return -1 ;
|
||||
}
|
||||
|
||||
void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector start, Sector end, bool inside_extended )
|
||||
void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector start, Sector end, Byte_Value sector_size, bool inside_extended )
|
||||
{
|
||||
Partition UNALLOCATED ;
|
||||
UNALLOCATED .Set_Unallocated( device .get_path(), 0, 0, inside_extended ) ;
|
||||
UNALLOCATED .Set_Unallocated( device .get_path(), 0, 0, sector_size, inside_extended ) ;
|
||||
|
||||
//if there are no partitions at all..
|
||||
if ( partitions .empty() )
|
||||
|
|
|
@ -55,7 +55,8 @@ void OperationCopy::apply_to_visual( std::vector<Partition> & partitions )
|
|||
insert_unallocated( partitions[ index_extended ] .logicals,
|
||||
partitions[ index_extended ] .sector_start,
|
||||
partitions[ index_extended ] .sector_end,
|
||||
true ) ;
|
||||
device .sector_size,
|
||||
true ) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -66,7 +67,7 @@ void OperationCopy::apply_to_visual( std::vector<Partition> & partitions )
|
|||
{
|
||||
partitions[ index ] = partition_new ;
|
||||
|
||||
insert_unallocated( partitions, 0, device .length -1, false ) ;
|
||||
insert_unallocated( partitions, 0, device .length -1, device .sector_size, false ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,8 @@ void OperationCreate::apply_to_visual( std::vector<Partition> & partitions )
|
|||
insert_unallocated( partitions[ index_extended ] .logicals,
|
||||
partitions[ index_extended ] .sector_start,
|
||||
partitions[ index_extended ] .sector_end,
|
||||
true ) ;
|
||||
device .sector_size,
|
||||
true ) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -61,7 +62,7 @@ void OperationCreate::apply_to_visual( std::vector<Partition> & partitions )
|
|||
{
|
||||
partitions[ index ] = partition_new ;
|
||||
|
||||
insert_unallocated( partitions, 0, device .length -1, false ) ;
|
||||
insert_unallocated( partitions, 0, device .length -1, device .sector_size, false ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ void OperationDelete::apply_to_visual( std::vector<Partition> & partitions )
|
|||
insert_unallocated( partitions[ index_extended ] .logicals,
|
||||
partitions[ index_extended ] .sector_start,
|
||||
partitions[ index_extended ] .sector_end,
|
||||
device .sector_size,
|
||||
true ) ;
|
||||
|
||||
//if deleted partition was logical we have to decrease the partitionnumbers of the logicals
|
||||
|
@ -65,7 +66,7 @@ void OperationDelete::apply_to_visual( std::vector<Partition> & partitions )
|
|||
{
|
||||
remove_original_and_adjacent_unallocated( partitions, index ) ;
|
||||
|
||||
insert_unallocated( partitions, 0, device .length -1, false ) ;
|
||||
insert_unallocated( partitions, 0, device .length -1, device .sector_size, false ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,8 +136,9 @@ void OperationResizeMove::apply_normal_to_visual( std::vector<Partition> & parti
|
|||
remove_adjacent_unallocated( partitions[ index_extended ] .logicals, index ) ;
|
||||
|
||||
insert_unallocated( partitions[ index_extended ] .logicals,
|
||||
partitions[ index_extended ] .sector_start,
|
||||
partitions[ index_extended ] .sector_end,
|
||||
partitions[ index_extended ] .sector_start,
|
||||
partitions[ index_extended ] .sector_end,
|
||||
device .sector_size,
|
||||
true ) ;
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +151,7 @@ void OperationResizeMove::apply_normal_to_visual( std::vector<Partition> & parti
|
|||
partitions[ index ] = partition_new ;
|
||||
remove_adjacent_unallocated( partitions, index ) ;
|
||||
|
||||
insert_unallocated( partitions, 0, device .length -1, false ) ;
|
||||
insert_unallocated( partitions, 0, device .length -1, device .sector_size, false ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +172,7 @@ void OperationResizeMove::apply_extended_to_visual( std::vector<Partition> & par
|
|||
partitions[ index_extended ] .sector_end = partition_new .sector_end ;
|
||||
}
|
||||
|
||||
insert_unallocated( partitions, 0, device .length -1, false ) ;
|
||||
insert_unallocated( partitions, 0, device .length -1, device .sector_size, false ) ;
|
||||
}
|
||||
|
||||
//stuff INSIDE extended partition
|
||||
|
@ -190,6 +191,7 @@ void OperationResizeMove::apply_extended_to_visual( std::vector<Partition> & par
|
|||
insert_unallocated( partitions[ index_extended ] .logicals,
|
||||
partitions[ index_extended ] .sector_start,
|
||||
partitions[ index_extended ] .sector_end,
|
||||
device .sector_size,
|
||||
true ) ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Copyright (C) 2004 Bart
|
||||
* Copyright (C) 2008, 2009 Curtis Gedak
|
||||
* Copyright (C) 2008, 2009, 2010 Curtis Gedak
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -58,6 +58,7 @@ void Partition::Set( const Glib::ustring & device_path,
|
|||
FILESYSTEM filesystem,
|
||||
Sector sector_start,
|
||||
Sector sector_end,
|
||||
Byte_Value sector_size,
|
||||
bool inside_extended,
|
||||
bool busy )
|
||||
{
|
||||
|
@ -70,6 +71,7 @@ void Partition::Set( const Glib::ustring & device_path,
|
|||
this ->filesystem = filesystem;
|
||||
this ->sector_start = sector_start;
|
||||
this ->sector_end = sector_end;
|
||||
this ->sector_size = sector_size;
|
||||
this ->inside_extended = inside_extended;
|
||||
this ->busy = busy;
|
||||
|
||||
|
@ -97,6 +99,7 @@ void Partition::set_used( Sector sectors_used )
|
|||
void Partition::Set_Unallocated( const Glib::ustring & device_path,
|
||||
Sector sector_start,
|
||||
Sector sector_end,
|
||||
Byte_Value sector_size,
|
||||
bool inside_extended )
|
||||
{
|
||||
Reset() ;
|
||||
|
@ -108,6 +111,7 @@ void Partition::Set_Unallocated( const Glib::ustring & device_path,
|
|||
GParted::FS_UNALLOCATED,
|
||||
sector_start,
|
||||
sector_end,
|
||||
sector_size,
|
||||
inside_extended,
|
||||
false );
|
||||
|
||||
|
|
|
@ -1404,11 +1404,12 @@ void Win_GParted::activate_resize()
|
|||
selected_partition .Set_Unallocated( devices[ current_device ] .get_path(),
|
||||
selected_partition .sector_start,
|
||||
selected_partition .sector_end,
|
||||
devices[current_device] .sector_size,
|
||||
selected_partition .inside_extended ) ;
|
||||
|
||||
Operation * operation = new OperationCreate( devices[ current_device ],
|
||||
selected_partition,
|
||||
dialog .Get_New_Partition() ) ;
|
||||
selected_partition,
|
||||
dialog .Get_New_Partition( devices[ current_device ] .sector_size ) ) ;
|
||||
operation ->icon = render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU );
|
||||
|
||||
Add_Operation( operation ) ;
|
||||
|
@ -1420,8 +1421,8 @@ void Win_GParted::activate_resize()
|
|||
else//normal move/resize on existing partition
|
||||
{
|
||||
Operation * operation = new OperationResizeMove( devices[ current_device ],
|
||||
selected_partition,
|
||||
dialog .Get_New_Partition() );
|
||||
selected_partition,
|
||||
dialog .Get_New_Partition( devices[ current_device ] .sector_size) );
|
||||
operation ->icon = render_icon( Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU );
|
||||
|
||||
Add_Operation( operation ) ;
|
||||
|
@ -1460,9 +1461,9 @@ void Win_GParted::activate_paste()
|
|||
dialog .hide() ;
|
||||
|
||||
Operation * operation = new OperationCopy( devices[ current_device ],
|
||||
selected_partition,
|
||||
dialog .Get_New_Partition(),
|
||||
copied_partition ) ;
|
||||
selected_partition,
|
||||
dialog .Get_New_Partition( devices[ current_device ] .sector_size ),
|
||||
copied_partition ) ;
|
||||
operation ->icon = render_icon( Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU );
|
||||
|
||||
Add_Operation( operation ) ;
|
||||
|
@ -1527,8 +1528,8 @@ void Win_GParted::activate_new()
|
|||
|
||||
new_count++ ;
|
||||
Operation *operation = new OperationCreate( devices[ current_device ],
|
||||
selected_partition,
|
||||
dialog .Get_New_Partition() ) ;
|
||||
selected_partition,
|
||||
dialog .Get_New_Partition( devices[ current_device ] .sector_size ) ) ;
|
||||
operation ->icon = render_icon( Gtk::Stock::NEW, Gtk::ICON_SIZE_MENU );
|
||||
|
||||
Add_Operation( operation );
|
||||
|
@ -1668,14 +1669,15 @@ void Win_GParted::activate_format( GParted::FILESYSTEM new_fs )
|
|||
|
||||
//ok we made it. lets create an fitting partition object
|
||||
Partition part_temp ;
|
||||
part_temp .Set( devices[ current_device ] .get_path(),
|
||||
selected_partition .get_path(),
|
||||
selected_partition .partition_number,
|
||||
part_temp .Set( devices[ current_device ] .get_path(),
|
||||
selected_partition .get_path(),
|
||||
selected_partition .partition_number,
|
||||
selected_partition .type,
|
||||
new_fs,
|
||||
new_fs,
|
||||
selected_partition .sector_start,
|
||||
selected_partition .sector_end,
|
||||
selected_partition .inside_extended,
|
||||
selected_partition .sector_end,
|
||||
devices[ current_device ] .sector_size,
|
||||
selected_partition .inside_extended,
|
||||
false ) ;
|
||||
|
||||
part_temp .status = GParted::STAT_FORMATTED ;
|
||||
|
@ -1969,14 +1971,15 @@ void Win_GParted::activate_label_partition()
|
|||
dialog .hide() ;
|
||||
//Make a duplicate of the selected partition (used in UNDO)
|
||||
Partition part_temp ;
|
||||
part_temp .Set( devices[ current_device ] .get_path(),
|
||||
selected_partition .get_path(),
|
||||
selected_partition .partition_number,
|
||||
part_temp .Set( devices[ current_device ] .get_path(),
|
||||
selected_partition .get_path(),
|
||||
selected_partition .partition_number,
|
||||
selected_partition .type,
|
||||
selected_partition .filesystem,
|
||||
selected_partition .filesystem,
|
||||
selected_partition .sector_start,
|
||||
selected_partition .sector_end,
|
||||
selected_partition .inside_extended,
|
||||
selected_partition .sector_end,
|
||||
devices[ current_device ] .sector_size,
|
||||
selected_partition .inside_extended,
|
||||
false ) ;
|
||||
|
||||
part_temp .label = dialog .get_new_label();
|
||||
|
|
Loading…
Reference in a new issue