P ). Resizing of ext2/3 works perfect now. I've even tested it on the

* Again way too many chances to create a detailed entry (i'm glad i'm the only dev atm :P ).
  Resizing of ext2/3 works perfect now. I've even tested it on the partition holding my SG seasons =)
  Implemented checking of filesystems (only internally used atm).
  Done some overall tweaking, finetuning etc.. release 0.0.7 is getting shape.
This commit is contained in:
Bart Hakvoort 2004-11-21 21:49:38 +00:00
parent 53321675f7
commit bd02bca613
32 changed files with 613 additions and 539 deletions

View File

@ -1,3 +1,10 @@
2004-11-21 Bart Hakvoort <gparted@users.sf.net>
* Again way too many chances to create a detailed entry (i'm glad i'm the only dev atm :P ).
Resizing of ext2/3 works perfect now. I've even tested it on the partition holding my SG seasons =)
Implemented checking of filesystems (only internally used atm).
Done some overall tweaking, finetuning etc.. release 0.0.7 is getting shape.
2004-11-19 Bart Hakvoort <gparted@users.sf.net>
* include/Device.h,

View File

@ -27,7 +27,7 @@ class Dialog_Partition_Copy : public Dialog_Base_Partition
{
public:
Dialog_Partition_Copy( ) ;
void Set_Data( Partition & selected_partition, Partition & copied_partition );
void Set_Data( const Partition & selected_partition, const Partition & copied_partition );
Partition Get_New_Partition( ) ;
private:

View File

@ -26,7 +26,7 @@ namespace GParted
class Dialog_Partition_Resize_Move : public Dialog_Base_Partition
{
public:
Dialog_Partition_Resize_Move( std::vector<FS> FILESYSTEMS ) ;
Dialog_Partition_Resize_Move( std::vector<FS> FILESYSTEMS, Sector cylinder_size ) ;
void Set_Data( const Partition & selected_partition, const std::vector <Partition> & partitions ) ;
private:

View File

@ -78,21 +78,26 @@ namespace GParted
class FileSystem
{
public:
FileSystem( ) ;
virtual ~FileSystem( ) { }
virtual FS get_filesystem_support( ) = 0 ;
virtual void Set_Used_Sectors( Partition & partition ) = 0 ;
virtual bool Create( const Glib::ustring device_path, const Partition & new_partition ) = 0 ;
virtual bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) = 0 ;
virtual bool Resize( const Partition & partition_new, bool fill_partition = false ) = 0 ;
virtual bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) = 0 ;
virtual bool Check_Repair( const Partition & partition ) = 0 ;
virtual int get_estimated_time( long MB_to_Consider ) = 0 ;
Glib::RefPtr<Gtk::TextBuffer> textbuffer ;
PedDisk *disk ; //see GParted_Core::Set_Used_Sectors() ...
long cylinder_size ; //see GParted_Core::Resize()
protected:
bool Execute_Command( Glib::ustring command ) ;
PedDevice *device ;
PedDisk *disk ;
private:
void Update_Textview( ) ;

View File

@ -41,7 +41,7 @@ public:
void find_supported_filesystems( ) ;
void get_devices( std::vector<Device> & devices, bool deep_scan ) ;
int get_estimated_time( Operation & operation ) ;
int get_estimated_time( const Operation & operation ) ;
void Apply_Operation_To_Disk( Operation & operation );
@ -57,13 +57,15 @@ public:
private:
void set_device_partitions( Device & device, bool deep_scan = true ) ;
Glib::ustring get_sym_path( const Glib::ustring & real_path ) ;
Sector Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring & sym_path );
void Set_Used_Sectors( Partition & partition );
Glib::ustring Get_Flags( PedPartition *c_partition ) ;
int Create_Empty_Partition( const Glib::ustring & device_path, Partition & new_partition, bool copy = false ) ;
bool Resize_Extended( const Glib::ustring & device_path, const Partition & extended ) ;
bool Resize_Container_Partition( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new ) ;
bool Resize_Normal_Using_Libparted( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new ) ;
void Show_Error( Glib::ustring message ) ;
void set_proper_filesystem( const Glib::ustring & filesystem ) ;
long Get_Cylinder_Size( const Glib::ustring & device_path ) ;
Glib::RefPtr<Gtk::TextBuffer> textbuffer;

View File

@ -54,8 +54,6 @@ public:
Glib::ustring str_operation ;
Glib::ustring copied_partition_path ; //for copy operation..
private:
void Insert_Unallocated( std::vector<Partition> & partitions, Sector start, Sector end );
int Get_Index_Original( std::vector<Partition> & partitions ) ;

View File

@ -66,16 +66,16 @@ public:
const bool inside_extended,
const bool busy ) ;
void Set_Used( Sector used ) ;
void Set_Unused( Sector sectors_unused ) ;
void Set_Unallocated( Sector sector_start, Sector sector_end, bool inside_extended );
//update partition number (used when a logical partition is deleted)
void Update_Number( int new_number );
long Get_Length_MB( );
long Get_Used_MB( );
long Get_Unused_MB( );
const long Get_Length_MB( ) const ;
const long Get_Used_MB( ) const ;
const long Get_Unused_MB( ) const ;
//some public members
Glib::ustring partition;//the symbolic path (e.g. /dev/hda1 )

View File

@ -36,14 +36,14 @@ class TreeView_Detail : public Gtk::TreeView
{
public:
TreeView_Detail( );
void Load_Partitions( std::vector<Partition> & partitions ) ;
void Load_Partitions( const std::vector<Partition> & partitions ) ;
void Set_Selected( const Partition & partition );
//signals for interclass communication
sigc::signal<void, GdkEventButton *, const Partition & > signal_mouse_click;
private:
void Create_Row( const Gtk::TreeRow &, Partition &);
void Create_Row( const Gtk::TreeRow & treerow, const Partition & partition );
//overridden signal
virtual bool on_button_press_event(GdkEventButton *);

View File

@ -43,12 +43,14 @@ typedef long long Sector;
struct FS
{
Glib::ustring filesystem ;
bool read ; //can we get the amount of used sectors?
bool create ;
bool resize ; //only endpoint
bool move ; //startpoint and endpoint
bool check ;
bool check ; //some checktool available?
bool copy ;
FS( ) {create = resize = move = check = false ;}
FS( ) {read = create = resize = move = check = copy = false ;}
};

View File

@ -64,7 +64,7 @@ public:
private:
void Build_Visual_Disk( ) ; //i still dream of some fully resizeable visualdisk....
void Create_Visual_Partition( Partition & partition ) ;
void Create_Visual_Partition( const Partition & partition ) ;
void Prepare_Legend( std::vector<Glib::ustring> & legend, const std::vector<Partition> & partitions ) ;
void Build_Legend( ) ;

View File

@ -28,9 +28,11 @@ class ext2 : public FileSystem
{
public:
FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
bool Check_Repair( const Partition & partition ) ;
int get_estimated_time( long MB_to_Consider ) ;
};

View File

@ -28,9 +28,11 @@ class ext3 : public FileSystem
{
public:
FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
bool Check_Repair( const Partition & partition ) ;
int get_estimated_time( long MB_to_Consider ) ;
};

View File

@ -28,9 +28,11 @@ class fat16 : public FileSystem
{
public:
FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
bool Check_Repair( const Partition & partition ) ;
int get_estimated_time( long MB_to_Consider ) ;
};

View File

@ -28,9 +28,11 @@ class fat32 : public FileSystem
{
public:
FS get_filesystem_support( );
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
bool Check_Repair( const Partition & partition ) ;
int get_estimated_time( long MB_to_Consider ) ;
};

View File

@ -28,9 +28,11 @@ class linux_swap : public FileSystem
{
public:
FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
bool Check_Repair( const Partition & partition ) ;
int get_estimated_time( long MB_to_Consider ) ;
};

View File

@ -30,9 +30,11 @@ class reiserfs : public FileSystem
{
public:
FS get_filesystem_support( ) ;
void Set_Used_Sectors( Partition & partition ) ;
bool Create( const Glib::ustring device_path, const Partition & new_partition ) ;
bool Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new ) ;
bool Resize( const Partition & partition_new, bool fill_partition = false ) ;
bool Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) ;
bool Check_Repair( const Partition & partition ) ;
int get_estimated_time( long MB_to_Consider ) ;
};

View File

@ -26,7 +26,7 @@ Dialog_Partition_Copy::Dialog_Partition_Copy()
Set_Confirm_Button( PASTE ) ;
}
void Dialog_Partition_Copy::Set_Data( Partition & selected_partition, Partition & copied_partition )
void Dialog_Partition_Copy::Set_Data( const Partition & selected_partition, const Partition & copied_partition )
{
GRIP = true ; //prevents on spinbutton_changed from getting activated prematurely

View File

@ -44,7 +44,7 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition )
hbox = manage( new Gtk::HBox( ) );
hbox ->pack_start( *image, Gtk::PACK_SHRINK ) ;
hbox ->pack_start( * mk_label( "<b> " + (Glib::ustring) _( "Libparted message:" ) + " </b>" ), Gtk::PACK_SHRINK ) ;
hbox ->pack_start( * mk_label( "<b> " + (Glib::ustring) _( "Warning:" ) + " </b>" ), Gtk::PACK_SHRINK ) ;
frame ->set_label_widget( *hbox ) ;
frame ->add( * mk_label( "<i>" + partition.error + "</i>", true, true, true ) ) ;

View File

@ -42,6 +42,7 @@ void Dialog_Partition_New::Set_Data( const Partition & partition, bool any_exten
this ->new_count = new_count;
this ->selected_partition = partition;
this ->FILESYSTEMS = FILESYSTEMS ;
this ->FILESYSTEMS .erase( this ->FILESYSTEMS .end( ) ) ;//remove dummy "unknown"
FS fs ; fs.filesystem = "extended" ;
this ->FILESYSTEMS .push_back( fs ) ;

View File

@ -20,10 +20,10 @@
namespace GParted
{
Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move( std::vector<FS> FILESYSTEMS )
Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move( std::vector<FS> FILESYSTEMS, Sector cylinder_size )
{
this ->FILESYSTEMS = FILESYSTEMS ;
BUF = 5 ;
BUF = Sector_To_MB( cylinder_size ) *2 ;
}
void Dialog_Partition_Resize_Move::Set_Data( const Partition & selected_partition, const std::vector <Partition> & partitions )

View File

@ -21,14 +21,20 @@
namespace GParted
{
FileSystem::FileSystem( )
{
disk = NULL;
cylinder_size = 0 ;
}
bool FileSystem::Execute_Command( Glib::ustring command )
{
Glib::Dispatcher dispatcher;
sigc::connection conn = dispatcher .connect( sigc::mem_fun(*this, &FileSystem::Update_Textview) );
//stderr to stdout
command += " 2>&1" ;
//command += " 2>&1" ;
std::cout << command << std::endl ;
output = command + "\n\n" ;
dispatcher ( ) ;
@ -47,6 +53,7 @@ bool FileSystem::Execute_Command( Glib::ustring command )
output = "" ;
dispatcher ( ) ;
return true ;
}

View File

@ -3,25 +3,11 @@
namespace GParted
{
//AFAIK it's not possible to use a C++ memberfunction as a callback for a C libary function (if you know otherwise, PLEASE contact me)
Glib::ustring error_message;
PedExceptionOption PedException_Handler (PedException* ex)
{
error_message = Glib::locale_to_utf8( ex ->message ) ;
std::cout << "\nLIBPARTED MESSAGE ----------------------\n" << error_message << "\n---------------------------\n";
return PED_EXCEPTION_UNHANDLED ;
}
GParted_Core::GParted_Core( )
{
device = NULL ;
disk = NULL ;
c_partition = NULL ;
ped_exception_set_handler( PedException_Handler ) ;
p_filesystem = NULL ;
textbuffer = Gtk::TextBuffer::create( ) ;
@ -52,6 +38,10 @@ void GParted_Core::find_supported_filesystems( )
reiserfs fs_reiserfs;
FILESYSTEMS .push_back( fs_reiserfs .get_filesystem_support( ) ) ;
//unknown filesystem (default when no match is found)
FS fs ; fs .filesystem = "unknown" ;
FILESYSTEMS .push_back( fs ) ;
}
void GParted_Core::get_devices( std::vector<Device> & devices, bool deep_scan )
@ -110,7 +100,7 @@ void GParted_Core::get_devices( std::vector<Device> & devices, bool deep_scan )
void GParted_Core::set_device_partitions( Device & device, bool deep_scan )
{
Partition partition_temp ;
Glib::ustring part_path, error ;
Glib::ustring part_path ;
int EXT_INDEX = -1 ;
//clear partitions
@ -131,13 +121,13 @@ void GParted_Core::set_device_partitions( Device & device, bool deep_scan )
else
{
temp = "unknown" ;
error = _( "Unable to detect filesystem! Possible reasons are:" ) ;
error += "\n-";
error += _( "The filesystem is damaged" ) ;
error += "\n-" ;
error += _( "The filesystem is unknown to libparted" ) ;
error += "\n-";
error += _( "There is no filesystem available (unformatted)" ) ;
partition_temp .error = _( "Unable to detect filesystem! Possible reasons are:" ) ;
partition_temp .error += "\n-";
partition_temp .error += _( "The filesystem is damaged" ) ;
partition_temp .error += "\n-" ;
partition_temp .error += _( "The filesystem is unknown to libparted" ) ;
partition_temp .error += "\n-";
partition_temp .error += _( "There is no filesystem available (unformatted)" ) ;
}
partition_temp .Set( part_path,
@ -148,11 +138,21 @@ void GParted_Core::set_device_partitions( Device & device, bool deep_scan )
c_partition ->type,
ped_partition_is_busy( c_partition ) );
if ( deep_scan )
partition_temp .Set_Used( Get_Used_Sectors( c_partition, part_path ) ) ;
if ( deep_scan && partition_temp .filesystem != "linux-swap" )
{
Set_Used_Sectors( partition_temp ) ;
//the 'Unknow' filesystem warning overrules this one
if ( partition_temp .sectors_used == -1 && partition_temp .error .empty( ) )
{
partition_temp .error = _("Unable to read the contents of this filesystem!") ;
partition_temp .error += "\n" ;
partition_temp .error += ("As a result you won't be able to resize this partition.") ;
}
}
partition_temp .flags = Get_Flags( c_partition ) ;
partition_temp .error = error .empty( ) ? error_message : error ;
if ( partition_temp .busy )
device .busy = true ;
@ -203,16 +203,13 @@ void GParted_Core::set_device_partitions( Device & device, bool deep_scan )
device .device_partitions[ EXT_INDEX ] .logicals .push_back( partition_temp ) ;
}
//reset stuff..
error = error_message = "" ;
//next partition (if any)
c_partition = ped_disk_next_partition ( disk, c_partition ) ;
}
}
int GParted_Core::get_estimated_time( Operation & operation )
int GParted_Core::get_estimated_time( const Operation & operation )
{
switch ( operation .operationtype )
{
@ -269,13 +266,9 @@ void GParted_Core::Apply_Operation_To_Disk( Operation & operation )
case COPY:
if ( ! Copy( operation .device_path, operation .copied_partition_path, operation .partition_new ) )
Show_Error( String::ucompose( _("Error while copying %1"), operation .partition_new .partition ) ) ;
}
}
bool GParted_Core::Create( const Glib::ustring & device_path, Partition & new_partition )
{
if ( new_partition .type == GParted::EXTENDED )
@ -319,13 +312,42 @@ bool GParted_Core::Delete( const Glib::ustring & device_path, const Partition &
bool GParted_Core::Resize( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new )
{
if ( partition_old .type == GParted::EXTENDED )
return Resize_Extended( device_path, partition_new ) ;
return Resize_Container_Partition( device_path, partition_old, partition_new ) ;
//these 3 still use libparted's resizer.
else if ( partition_old .filesystem == "linux-swap" ||
partition_old .filesystem == "fat16" ||
partition_old .filesystem == "fat32"
)
return Resize_Normal_Using_Libparted( device_path, partition_old, partition_new ) ;
//use custom resize tools..(afaik only resize, no moves)
else
{
set_proper_filesystem( partition_new .filesystem ) ;
return p_filesystem ->Resize( device_path, partition_old, partition_new ) ;
if ( p_filesystem ->Check_Repair( partition_new ) )
{
//shrinking
if ( partition_new .sector_end < partition_old .sector_end )
{
p_filesystem ->cylinder_size = Get_Cylinder_Size( device_path ) ;
if ( p_filesystem ->Resize( partition_new ) )
Resize_Container_Partition( device_path, partition_old, partition_new ) ;
}
//growing
if ( partition_new .sector_end > partition_old .sector_end )
Resize_Container_Partition( device_path, partition_old, partition_new ) ;
p_filesystem ->Check_Repair( partition_new ) ;
p_filesystem ->Resize( partition_new, true ) ; //expand filesystem to fit exactly in partition
return p_filesystem ->Check_Repair( partition_new ) ;
}
}
return false ;
@ -383,64 +405,32 @@ Glib::ustring GParted_Core::get_sym_path( const Glib::ustring & real_path )
}
Sector GParted_Core::Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring & sym_path)
void GParted_Core::Set_Used_Sectors( Partition & partition )
{
/* This is quite an unreliable process, atm i try two different methods, but since both are far from perfect the results are
* questionable.
* - first i try geometry.get_used() in libpartedpp, i implemented this function to check the minimal size when resizing a partition. Disadvantage
* of this method is the fact it won't work on mounted filesystems. Besides that, its SLOW
* - if the former method fails ( result is -1 ) i'll try to read the output from the df command ( df -k --sync <partition path> )
* - if this fails the filesystem on the partition is ( more or less ) unknown to the operating system and therefore the unused sectors cannot be calcualted
* - as soon as i have my internetconnection back i should ask people with more experience on this stuff for advice !
*/
if ( partition .filesystem == "unknown" || partition .filesystem == "linux-swap" )
partition .Set_Unused( -1 ) ;
//check if there is a (known) filesystem
if ( ! c_partition ->fs_type )
return -1;
//used sectors are not relevant for swapspace
if ( (Glib::ustring) c_partition ->fs_type ->name == "linux-swap" )
return -1;
//METHOD #1
//the getused method doesn't work on mounted partitions and for some filesystems ( i *guess* this is called check by andrew )
if ( ! ped_partition_is_busy( c_partition ) && Get_FS( c_partition ->fs_type ->name, FILESYSTEMS ) .create )
else if ( partition .busy )
{
PedFileSystem *fs = NULL;
PedConstraint *constraint = NULL;
fs = ped_file_system_open( & c_partition ->geom );
if ( fs )
{
constraint = ped_file_system_get_resize_constraint (fs);
ped_file_system_close (fs);
if ( constraint && constraint->min_size != -1 )
return constraint->min_size ;
}
}
//METHOD #2
//this ony works for mounted ( and therefore known to the OS ) filesystems. My method is quite crude, keep in mind it's only temporary ;-)
if ( ped_partition_is_busy( c_partition ) )
{
Glib::ustring buf;
system( ("df -k --sync " + sym_path + " | grep " + sym_path + " > /tmp/.tmp_gparted") .c_str( ) );
system( ("df -k --sync " + partition .partition + " | grep " + partition .partition + " > /tmp/.tmp_gparted") .c_str( ) );
std::ifstream file_input( "/tmp/.tmp_gparted" );
file_input >> buf; //skip first value
file_input >> buf;
if ( buf != "0" && ! buf .empty( ) )
//we need the 4th value
file_input >> temp; file_input >> temp; file_input >> temp;file_input >> temp;
if ( ! temp .empty( ) )
partition .Set_Unused( atoi( temp .c_str( ) ) * 1024/512 ) ;
file_input .close( );
system( "rm -f /tmp/.tmp_gparted" );
}
else if ( Get_FS( partition .filesystem, FILESYSTEMS ) .read )
{
file_input >> buf;
file_input .close( ); system( "rm -f /tmp/.tmp_gparted" );
return atoi( buf .c_str( ) ) * 1024/512 ;
}
file_input .close( ); system( "rm -f /tmp/.tmp_gparted" );
}
set_proper_filesystem( partition .filesystem ) ;
return -1 ; //all methods were unsuccesfull
p_filesystem ->disk = disk ;
p_filesystem ->Set_Used_Sectors( partition ) ;
}
}
int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Partition & new_partition, bool copy )
@ -491,29 +481,71 @@ int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Par
return new_partition .partition_number ;
}
bool GParted_Core::Resize_Extended( const Glib::ustring & device_path, const Partition & extended )
bool GParted_Core::Resize_Container_Partition( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new )
{
bool return_value = false ;
PedConstraint *constraint = NULL ;
c_partition = NULL ;
if ( open_device_and_disk( device_path, device, disk ) )
{
PedPartition *c_part = NULL ;
PedConstraint *constraint = NULL ;
if ( partition_old .type == GParted::EXTENDED )
c_partition = ped_disk_extended_partition( disk ) ;
else
c_partition = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
c_part = ped_disk_extended_partition( disk ) ;
if ( c_part )
if ( c_partition )
{
constraint = ped_constraint_any( device );
if ( constraint )
{
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, extended .sector_start, extended .sector_end ) )
{
ped_partition_set_system ( c_part, NULL );
if ( ped_disk_set_partition_geom ( disk, c_partition, constraint, partition_new .sector_start, partition_new .sector_end ) )
return_value = Commit( disk ) ;
}
ped_constraint_destroy ( constraint );
}
}
close_device_and_disk( device, disk ) ;
}
sleep( 1 ) ; //the OS needs time to re-add the devicenode..
return return_value ;
}
bool GParted_Core::Resize_Normal_Using_Libparted( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new )
{
bool return_value = false ;
PedFileSystem *fs = NULL ;
PedConstraint *constraint = NULL ;
c_partition = NULL ;
if ( open_device_and_disk( device_path, device, disk ) )
{
c_partition = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
if ( c_partition )
{
fs = ped_file_system_open ( & c_partition ->geom );
if ( fs )
{
constraint = ped_file_system_get_resize_constraint ( fs );
if ( constraint )
{
if ( ped_disk_set_partition_geom ( disk, c_partition, constraint, partition_new .sector_start, partition_new .sector_end ) &&
ped_file_system_resize ( fs, & c_partition ->geom, NULL )
)
return_value = Commit( disk ) ;
ped_constraint_destroy ( constraint );
}
ped_file_system_close ( fs );
}
}
close_device_and_disk( device, disk ) ;
@ -570,4 +602,18 @@ void GParted_Core::set_proper_filesystem( const Glib::ustring & filesystem )
p_filesystem ->textbuffer = textbuffer ;
}
long GParted_Core::Get_Cylinder_Size( const Glib::ustring & device_path )
{
long cylinder_size = 0 ;
if ( open_device( device_path, device ) )
{
cylinder_size = Sector_To_MB( device ->bios_geom .heads * device ->bios_geom .sectors ) ;
close_device_and_disk( device, disk ) ;
}
return cylinder_size ;
}
} //GParted

View File

@ -56,10 +56,10 @@ void Partition::Set( const Glib::ustring & partition,
this ->busy = busy;
}
void Partition::Set_Used( Sector used )
void Partition::Set_Unused( Sector sectors_unused )
{
this ->sectors_used = used;
this ->sectors_unused = ( used == -1 ) ? -1 : ( sector_end - sector_start) - used ;
this ->sectors_unused = sectors_unused ;
this ->sectors_used = ( sectors_unused == -1 ) ? -1 : ( sector_end - sector_start) - sectors_unused ;
}
void Partition::Set_Unallocated( Sector sector_start, Sector sector_end, bool inside_extended )
@ -71,23 +71,22 @@ void Partition::Set_Unallocated( Sector sector_start, Sector sector_end, bool in
void Partition::Update_Number( int new_number )
{ //of course this fails when we have devicenames with numbers over 99
partition_number >= 10 ? partition = partition.substr( 0, partition.length() -2 ) : partition = partition.substr( 0, partition.length() -1 ) ;
partition = partition .substr( 0, partition .length( ) - ( partition_number >= 10 ? 2 : 1 ) ) ;
this ->partition_number = new_number;
this ->partition += num_to_str( partition_number ) ;
}
long Partition::Get_Length_MB( )
const long Partition::Get_Length_MB( ) const
{
return Sector_To_MB( this ->sector_end - this ->sector_start) ;
return Sector_To_MB( sector_end - sector_start ) ;
}
long Partition::Get_Used_MB( )
const long Partition::Get_Used_MB( ) const
{
return Sector_To_MB( this ->sectors_used ) ;
}
long Partition::Get_Unused_MB( )
const long Partition::Get_Unused_MB( ) const
{
return Get_Length_MB( ) - Get_Used_MB( ) ;
}

View File

@ -70,7 +70,7 @@ TreeView_Detail::TreeView_Detail( )
}
void TreeView_Detail::Load_Partitions( std::vector<Partition> & partitions )
void TreeView_Detail::Load_Partitions( const std::vector<Partition> & partitions )
{
treestore_detail ->clear( ) ;
@ -102,8 +102,13 @@ void TreeView_Detail::Set_Selected( const Partition & partition )
row = *iter;
partition_temp = row[ treeview_detail_columns.partition_struct ] ;
//primary's
if ( partition .sector_start >= partition_temp .sector_start && partition .sector_end <=partition_temp .sector_end && partition.inside_extended == partition_temp.inside_extended )
{ this->set_cursor( (Gtk::TreePath) row); return; }
if ( partition .sector_start >= partition_temp .sector_start &&
partition .sector_end <=partition_temp .sector_end &&
partition.inside_extended == partition_temp.inside_extended )
{
this ->set_cursor( (Gtk::TreePath) row );
return;
}
//logicals
if ( row .children( ) .size( ) > 0 ) //this is the row with the extended partition, search it's childrows...
@ -127,7 +132,7 @@ void TreeView_Detail::Set_Selected( const Partition & partition )
}
void TreeView_Detail::Create_Row( const Gtk::TreeRow & treerow, Partition & partition )
void TreeView_Detail::Create_Row( const Gtk::TreeRow & treerow, const Partition & partition )
{
//hereby i assume these 2 are mutual exclusive. is this wise?? Time (and bugreports) will tell :)
if ( partition .busy )
@ -138,7 +143,7 @@ void TreeView_Detail::Create_Row( const Gtk::TreeRow & treerow, Partition & part
treerow[ treeview_detail_columns .partition ] = partition .partition;
treerow[ treeview_detail_columns .color ] = Get_Color( partition .filesystem ) ;
partition .type == GParted::UNALLOCATED ? treerow[treeview_detail_columns.text_color] = "darkgrey" : treerow[treeview_detail_columns.text_color] = "black" ;
treerow[ treeview_detail_columns .text_color ] = ( partition .type == GParted::UNALLOCATED ) ? "darkgrey" : "black" ;
treerow[ treeview_detail_columns .type ] = partition .filesystem ;
treerow[ treeview_detail_columns .type_square ] = "██" ;

View File

@ -92,7 +92,7 @@ void VBox_VisualDisk::Build_Visual_Disk( )
this ->show_all_children( ) ;
}
void VBox_VisualDisk::Create_Visual_Partition( Partition & partition )
void VBox_VisualDisk::Create_Visual_Partition( const Partition & partition )
{
int x,y;//for pango_layout check
@ -128,12 +128,18 @@ void VBox_VisualDisk::Create_Visual_Partition( Partition & partition )
visual_partitions .back( ) ->length = (int) (SCREEN_WIDTH / (double) ( device_length / (double) ( partition .sector_end - partition .sector_start) ) );
if ( visual_partitions .back( ) ->length < 20 )//we need a min. size. Otherwise some small partitions wouldn't be visible
partition .type == GParted::UNALLOCATED ? visual_partitions.back() ->length = 15 : visual_partitions.back() ->length = 20 ;
visual_partitions .back( ) ->length = ( partition .type == GParted::UNALLOCATED ) ? 15 : 20 ;
if ( partition .inside_extended )
{ visual_partitions.back() ->height = 34 ; visual_partitions.back() ->text_y = 9 ; }
{
visual_partitions .back( ) ->height = 34 ;
visual_partitions .back( ) ->text_y = 9 ;
}
else
{ visual_partitions.back() ->height = 44 ;visual_partitions.back() ->text_y = 15 ; }
{
visual_partitions .back( ) ->height = 44 ;
visual_partitions .back( ) ->text_y = 15 ;
}
if ( partition .type == GParted::UNALLOCATED )
visual_partitions .back( ) ->used = -1;

View File

@ -611,7 +611,9 @@ void Win_GParted::Set_Valid_Operations()
allow_resize( true ) ;
//only allow copying of real partitions
if ( selected_partition .status != GParted::STAT_NEW && selected_partition .status != GParted::STAT_COPY )
if ( selected_partition .status != GParted::STAT_NEW &&
selected_partition .status != GParted::STAT_COPY &&
Get_FS( selected_partition .filesystem, gparted_core .get_fs( ) ) .copy )
allow_copy( true ) ;
}
@ -839,7 +841,7 @@ void Win_GParted::activate_resize()
operations[ t ] .Apply_Operation_To_Visual( partitions ) ;
Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( ) ) ;
Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( ), devices[ current_device ] .length / devices[ current_device ] .cylinders ) ;
if ( selected_partition .type == GParted::LOGICAL )
{

View File

@ -26,79 +26,67 @@ FS ext2::get_filesystem_support( )
FS fs ;
fs .filesystem = "ext2" ;
if ( ! system( "which dumpe2fs 1>/dev/null 2>/dev/null" ) )
fs .read = true ;
if ( ! system( "which mkfs.ext2 1>/dev/null 2>/dev/null" ) )
fs .create = true ;
if ( ! system( "which e2fsck 1>/dev/null 2>/dev/null" ) )
fs .check = true ;
//resizing is a delicate process which requires 3 commands..
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
fs .resize = true ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
fs .copy = true ;
return fs ;
}
void ext2::Set_Used_Sectors( Partition & partition )
{
char c_buf[ 512 ] ;
FILE *f ;
Glib::ustring output ;
Sector free_blocks = -1, blocksize = -1 ;
//get free blocks..
f = popen( ( "dumpe2fs -h " + partition .partition ) .c_str( ), "r" ) ;
while ( fgets( c_buf, 512, f ) )
{
output = Glib::locale_to_utf8( c_buf ) ;
//free blocks
if ( output .find( "Free blocks" ) < output .length( ) )
free_blocks = atoi( (output .substr( output .find( ":" ) +1, output .length( ) ) ) .c_str( ) ) ;
//blocksize
if ( output .find( "Block size:" ) < output .length( ) )
blocksize = atoi( (output .substr( output .find( ":" ) +1, output .length( ) ) ) .c_str( ) ) ;
}
pclose( f ) ;
if ( free_blocks > -1 && blocksize > -1 )
partition .Set_Unused( free_blocks * blocksize / 512 ) ;
}
bool ext2::Create( const Glib::ustring device_path, const Partition & new_partition )
{
bool return_value = false ;
if ( open_device_and_disk( device_path, device, disk ) )
{
PedPartition *c_part = NULL ;
PedFileSystemType *fs_type = NULL ;
PedFileSystem *fs = NULL ;
c_part = ped_disk_get_partition_by_sector( disk, (new_partition .sector_end + new_partition .sector_start) / 2 ) ;
if ( c_part )
{
fs_type = ped_file_system_type_get( "ext2" ) ;
if ( fs_type )
{
fs = ped_file_system_create( & c_part ->geom, fs_type, NULL );
if ( fs )
{
if ( ped_partition_set_system( c_part, fs_type ) )
return_value = Commit( disk ) ;
ped_file_system_close( fs );
}
}
return Execute_Command( "mkfs.ext2 " + new_partition .partition ) ;
}
close_device_and_disk( device, disk ) ;
}
return return_value ;
}
bool ext2::Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new )
bool ext2::Resize( const Partition & partition_new, bool fill_partition )
{
bool return_value = false ;
Glib::ustring str_temp = "resize2fs " + partition_new .partition ;
PedPartition *c_part = NULL ;
PedFileSystem *fs = NULL ;
PedConstraint *constraint = NULL ;
if ( ! fill_partition )
str_temp += " " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ;
if ( open_device_and_disk( device_path, device, disk ) )
{
c_part = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
if ( c_part )
{
fs = ped_file_system_open ( & c_part->geom );
if ( fs )
{
constraint = ped_file_system_get_resize_constraint ( fs );
if ( constraint )
{
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, partition_new .sector_start, partition_new .sector_end ) &&
ped_file_system_resize ( fs, & c_part->geom, NULL ) )
return_value = Commit( disk ) ;
ped_constraint_destroy ( constraint );
}
ped_file_system_close ( fs );
}
}
close_device_and_disk( device, disk ) ;
}
return return_value ;
return Execute_Command( str_temp ) ;
}
bool ext2::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
@ -106,9 +94,14 @@ bool ext2::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
}
bool ext2::Check_Repair( const Partition & partition )
{
return Execute_Command( "e2fsck -fy " + partition .partition ) ;
}
int ext2::get_estimated_time( long MB_to_Consider )
{
return 1 + MB_to_Consider / 500 ;
return -1 ;
}

View File

@ -26,89 +26,67 @@ FS ext3::get_filesystem_support( )
FS fs ;
fs .filesystem = "ext3" ;
if ( ! system( "which dumpe2fs 1>/dev/null 2>/dev/null" ) )
fs .read = true ;
if ( ! system( "which tune2fs 1>/dev/null 2>/dev/null" ) )
if ( ! system( "which mkfs.ext3 1>/dev/null 2>/dev/null" ) )
fs .create = true ;
if ( ! system( "which e2fsck 1>/dev/null 2>/dev/null" ) )
fs .check = true ;
//resizing is a delicate process which requires 3 commands..
if ( ! system( "which resize2fs 1>/dev/null 2>/dev/null" ) && fs .read && fs .check )
fs .resize = true ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
fs .copy = true ;
return fs ;
}
void ext3::Set_Used_Sectors( Partition & partition )
{
char c_buf[ 512 ] ;
FILE *f ;
Glib::ustring output ;
Sector free_blocks = -1, blocksize = -1 ;
//get free blocks..
f = popen( ( "dumpe2fs -h " + partition .partition ) .c_str( ), "r" ) ;
while ( fgets( c_buf, 512, f ) )
{
output = Glib::locale_to_utf8( c_buf ) ;
//free blocks
if ( output .find( "Free blocks" ) < output .length( ) )
free_blocks = atoi( (output .substr( output .find( ":" ) +1, output .length( ) ) ) .c_str( ) ) ;
//blocksize
if ( output .find( "Block size:" ) < output .length( ) )
blocksize = atoi( (output .substr( output .find( ":" ) +1, output .length( ) ) ) .c_str( ) ) ;
}
pclose( f ) ;
if ( free_blocks > -1 && blocksize > -1 )
partition .Set_Unused( free_blocks * blocksize / 512 ) ;
}
bool ext3::Create( const Glib::ustring device_path, const Partition & new_partition )
{
bool return_value = false ;
if ( open_device_and_disk( device_path, device, disk ) )
{
PedPartition *c_part = NULL ;
PedFileSystemType *fs_type = NULL ;
PedFileSystem *fs = NULL ;
c_part = ped_disk_get_partition_by_sector( disk, (new_partition .sector_end + new_partition .sector_start) / 2 ) ;
if ( c_part )
{
fs_type = ped_file_system_type_get( "ext2" ) ;
if ( fs_type )
{
fs = ped_file_system_create( & c_part ->geom, fs_type, NULL );
if ( fs )
{
if ( ped_partition_set_system(c_part, fs_type ) )
{
return_value = Commit( disk ) ;
sleep( 1 ) ;
//system( ("tune2fs -j " + new_partition .partition) .c_str( ) ) ;
Execute_Command( "tune2fs -j " + new_partition .partition ) ;
return Execute_Command( "mkfs.ext3 " + new_partition .partition ) ;
}
ped_file_system_close( fs );
}
}
}
close_device_and_disk( device, disk) ;
}
return return_value ;
}
bool ext3::Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new )
bool ext3::Resize( const Partition & partition_new, bool fill_partition )
{
bool return_value = false ;
Glib::ustring str_temp = "resize2fs " + partition_new .partition ;
PedPartition *c_part = NULL ;
PedFileSystem *fs = NULL ;
PedConstraint *constraint = NULL ;
if ( ! fill_partition )
str_temp += " " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ;
if ( open_device_and_disk( device_path, device, disk ) )
{
c_part = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
if ( c_part )
{
fs = ped_file_system_open ( & c_part->geom );
if ( fs )
{
constraint = ped_file_system_get_resize_constraint ( fs );
if ( constraint )
{
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, partition_new .sector_start, partition_new .sector_end ) &&
ped_file_system_resize ( fs, & c_part->geom, NULL ) )
return_value = Commit( disk ) ;
ped_constraint_destroy ( constraint );
}
ped_file_system_close ( fs );
}
}
close_device_and_disk( device, disk ) ;
}
return return_value ;
return Execute_Command( str_temp ) ;
}
bool ext3::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
@ -116,9 +94,14 @@ bool ext3::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
}
bool ext3::Check_Repair( const Partition & partition )
{
return Execute_Command( "e2fsck -fy " + partition .partition ) ;
}
int ext3::get_estimated_time( long MB_to_Consider )
{
return 1 + MB_to_Consider / 400 ;
return -1 ;
}
} //GParted

View File

@ -26,13 +26,46 @@ FS fat16::get_filesystem_support( )
FS fs ;
fs .filesystem = "fat16" ;
fs .read = true ; //provided by libparted
fs .create = true ;
fs .resize = true ;
fs .move = true ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
fs .copy = true ;
return fs ;
}
void fat16::Set_Used_Sectors( Partition & partition )
{
PedFileSystem *fs = NULL;
PedConstraint *constraint = NULL;
PedPartition *c_part = NULL ;
if ( disk )
{
c_part = ped_disk_get_partition_by_sector( disk, (partition .sector_end + partition .sector_start) / 2 ) ;
if ( c_part )
{
fs = ped_file_system_open( & c_part ->geom );
if ( fs )
{
constraint = ped_file_system_get_resize_constraint ( fs ) ;
if ( constraint )
{
partition .Set_Unused( (partition .sector_end - partition .sector_start) - constraint ->min_size ) ;
ped_constraint_destroy ( constraint );
}
ped_file_system_close( fs ) ;
}
}
}
}
bool fat16::Create( const Glib::ustring device_path, const Partition & new_partition )
{
bool return_value = false ;
@ -66,40 +99,10 @@ bool fat16::Create( const Glib::ustring device_path, const Partition & new_parti
return return_value ;
}
bool fat16::Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new )
bool fat16::Resize( const Partition & partition_new, bool fill_partition )
{
bool return_value = false ;
PedPartition *c_part = NULL ;
PedFileSystem *fs = NULL ;
PedConstraint *constraint = NULL ;
if ( open_device_and_disk( device_path, device, disk ) )
{
c_part = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
if ( c_part )
{
fs = ped_file_system_open ( & c_part->geom );
if ( fs )
{
constraint = ped_file_system_get_resize_constraint ( fs );
if ( constraint )
{
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, partition_new .sector_start, partition_new .sector_end ) &&
ped_file_system_resize ( fs, & c_part->geom, NULL ) )
return_value = Commit( disk ) ;
ped_constraint_destroy ( constraint );
}
ped_file_system_close ( fs );
}
}
close_device_and_disk( device, disk) ;
}
return return_value ;
//handled in GParted_Core::Resize_Normal_Using_Libparted
return false ;
}
bool fat16::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
@ -107,9 +110,14 @@ bool fat16::Copy( const Glib::ustring & src_part_path, const Glib::ustring & des
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
}
bool fat16::Check_Repair( const Partition & partition )
{
return false ;
}
int fat16::get_estimated_time( long MB_to_Consider )
{
return 1 ;
return -1 ;
}
} //GParted

View File

@ -26,6 +26,7 @@ FS fat32::get_filesystem_support( )
FS fs ;
fs .filesystem = "fat32" ;
fs .read = true ; //provided by libparted
//find out if we can create fat32 filesystems
if ( ! system( "which mkdosfs 1>/dev/null 2>/dev/null" ) )
@ -35,36 +36,31 @@ FS fat32::get_filesystem_support( )
fs .resize = true ;
fs .move = true ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
fs .copy = true ;
return fs ;
}
bool fat32::Create( const Glib::ustring device_path, const Partition & new_partition )
void fat32::Set_Used_Sectors( Partition & partition )
{
return Execute_Command( "mkdosfs -F32 " + new_partition .partition ) ;
}
bool fat32::Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new )
{
bool return_value = false ;
PedPartition *c_part = NULL ;
PedFileSystem *fs = NULL;
PedConstraint *constraint = NULL;
PedPartition *c_part = NULL ;
if ( open_device_and_disk( device_path, device, disk ) )
if ( disk )
{
c_part = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
c_part = ped_disk_get_partition_by_sector( disk, (partition .sector_end + partition .sector_start) / 2 ) ;
if ( c_part )
{
fs = ped_file_system_open( & c_part ->geom );
if ( fs )
{
constraint = ped_file_system_get_resize_constraint ( fs ) ;
if ( constraint )
{
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, partition_new .sector_start, partition_new .sector_end ) &&
ped_file_system_resize ( fs, & c_part->geom, NULL ) )
return_value = Commit( disk ) ;
partition .Set_Unused( (partition .sector_end - partition .sector_start) - constraint ->min_size ) ;
ped_constraint_destroy ( constraint );
}
@ -72,11 +68,18 @@ bool fat32::Resize( const Glib::ustring device_path, const Partition & partition
ped_file_system_close( fs ) ;
}
}
close_device_and_disk( device, disk) ;
}
}
return return_value ;
bool fat32::Create( const Glib::ustring device_path, const Partition & new_partition )
{
return Execute_Command( "mkdosfs -F32 " + new_partition .partition ) ;
}
bool fat32::Resize( const Partition & partition_new, bool fill_partition )
{
//handled in GParted_Core::Resize_Normal_Using_Libparted
return false ;
}
bool fat32::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
@ -84,9 +87,14 @@ bool fat32::Copy( const Glib::ustring & src_part_path, const Glib::ustring & des
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
}
bool fat32::Check_Repair( const Partition & partition )
{
return false ;
}
int fat32::get_estimated_time( long MB_to_Consider )
{
return 1 + MB_to_Consider / 5000 ;
return -1 ;
}

View File

@ -26,13 +26,21 @@ FS linux_swap::get_filesystem_support( )
FS fs ;
fs .filesystem = "linux-swap" ;
fs .read = false ; //used/unused isn't relevant for swapspace
fs .create = true ;
fs .resize = true ;
fs .move = true ;
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
fs .copy = true ;
return fs ;
}
void linux_swap::Set_Used_Sectors( Partition & partition )
{
}
bool linux_swap::Create( const Glib::ustring device_path, const Partition & new_partition )
{
bool return_value = false ;
@ -66,40 +74,10 @@ bool linux_swap::Create( const Glib::ustring device_path, const Partition & new_
return return_value ;
}
bool linux_swap::Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new )
bool linux_swap::Resize( const Partition & partition_new, bool fill_partition )
{
bool return_value = false ;
PedPartition *c_part = NULL ;
PedFileSystem *fs = NULL ;
PedConstraint *constraint = NULL ;
if ( open_device_and_disk( device_path, device, disk ) )
{
c_part = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
if ( c_part )
{
fs = ped_file_system_open ( & c_part->geom );
if ( fs )
{
constraint = ped_file_system_get_resize_constraint ( fs );
if ( constraint )
{
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, partition_new .sector_start, partition_new .sector_end ) &&
ped_file_system_resize ( fs, & c_part->geom, NULL ) )
return_value = Commit( disk ) ;
ped_constraint_destroy ( constraint );
}
ped_file_system_close ( fs );
}
}
close_device_and_disk( device, disk ) ;
}
return return_value ;
//handled in GParted_Core::Resize_Normal_Using_Libparted
return false ;
}
bool linux_swap::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
@ -107,6 +85,11 @@ bool linux_swap::Copy( const Glib::ustring & src_part_path, const Glib::ustring
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
}
bool linux_swap::Check_Repair( const Partition & partition )
{
return false ;
}
int linux_swap::get_estimated_time( long MB_to_Consider )
{
return 1 + MB_to_Consider / 5000 ;

View File

@ -30,6 +30,7 @@ FS reiserfs::get_filesystem_support( )
static void * test_handle = NULL ;
if ( (test_handle = dlopen("libreiserfs.so", RTLD_NOW)) )
{
fs .read = true ;
fs .create = true ;
fs .resize = true ;
@ -37,9 +38,41 @@ FS reiserfs::get_filesystem_support( )
test_handle = NULL ;
}
if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) )
fs .copy = true ;
return fs ;
}
void reiserfs::Set_Used_Sectors( Partition & partition )
{
PedFileSystem *fs = NULL;
PedConstraint *constraint = NULL;
PedPartition *c_part = NULL ;
if ( disk )
{
c_part = ped_disk_get_partition_by_sector( disk, (partition .sector_end + partition .sector_start) / 2 ) ;
if ( c_part )
{
fs = ped_file_system_open( & c_part ->geom );
if ( fs )
{
constraint = ped_file_system_get_resize_constraint ( fs ) ;
if ( constraint )
{
partition .Set_Unused( (partition .sector_end - partition .sector_start) - constraint ->min_size ) ;
ped_constraint_destroy ( constraint );
}
ped_file_system_close( fs ) ;
}
}
}
}
bool reiserfs::Create( const Glib::ustring device_path, const Partition & new_partition )
{
bool return_value = false ;
@ -73,40 +106,9 @@ bool reiserfs::Create( const Glib::ustring device_path, const Partition & new_pa
return return_value ;
}
bool reiserfs::Resize( const Glib::ustring device_path, const Partition & partition_old, const Partition & partition_new )
bool reiserfs::Resize( const Partition & partition_new, bool fill_partition )
{
bool return_value = false ;
PedPartition *c_part = NULL ;
PedFileSystem *fs = NULL ;
PedConstraint *constraint = NULL ;
if ( open_device_and_disk( device_path, device, disk ) )
{
c_part = ped_disk_get_partition_by_sector( disk, (partition_old .sector_end + partition_old .sector_start) / 2 ) ;
if ( c_part )
{
fs = ped_file_system_open ( & c_part->geom );
if ( fs )
{
constraint = ped_file_system_get_resize_constraint ( fs );
if ( constraint )
{
if ( ped_disk_set_partition_geom ( disk, c_part, constraint, partition_new .sector_start, partition_new .sector_end ) &&
ped_file_system_resize ( fs, & c_part->geom, NULL ) )
return_value = Commit( disk ) ;
ped_constraint_destroy ( constraint );
}
ped_file_system_close ( fs );
}
}
close_device_and_disk( device, disk ) ;
}
return return_value ;
return false ;
}
bool reiserfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path )
@ -114,6 +116,11 @@ bool reiserfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring &
return Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ;
}
bool reiserfs::Check_Repair( const Partition & partition )
{
return false ;
}
int reiserfs::get_estimated_time( long MB_to_Consider )
{
return 1 + MB_to_Consider / 1000 ;