fixed nasty error with resizing 'fixed-start filesystems'. added a check

* include/GParted_Core.h,
  src/GParted_Core.cc: fixed nasty error with resizing 'fixed-start filesystems'.
* src/Partition.cc: added a check to prevent unused space from being bigger then total space.
* src/ntfs.cc: removed -Q from mkntfs. -Q bypassed some safetychecks to gain performance and (so i heard later) also had a
  tendency of failing ;) (Adrighem)
This commit is contained in:
Bart Hakvoort 2004-11-24 10:32:56 +00:00
parent b189e385f1
commit e71d5c5887
5 changed files with 31 additions and 7 deletions

View File

@ -1,3 +1,11 @@
2004-11-24 Bart Hakvoort <gparted@users.sf.net>
* include/GParted_Core.h,
src/GParted_Core.cc: fixed nasty error with resizing 'fixed-start filesystems'.
* src/Partition.cc: added a check to prevent unused space from being bigger then total space.
* src/ntfs.cc: removed -Q from mkntfs. -Q bypassed some safetychecks to gain performance and (so i heard later) also had a
tendency of failing ;) (Adrighem)
2004-11-23 Bart Hakvoort <gparted@users.sf.net>
* src/Dialog_Partition_New.cc,

View File

@ -61,7 +61,7 @@ private:
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_Container_Partition( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new ) ;
bool Resize_Container_Partition( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new, bool fixed_start = true ) ;
bool Resize_Normal_Using_Libparted( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new ) ;
void Show_Error( Glib::ustring message ) ;

View File

@ -307,6 +307,8 @@ bool GParted_Core::Delete( const Glib::ustring & device_path, const Partition &
return_value = ( ped_disk_delete_partition( disk, c_partition ) && Commit( disk ) ) ;
close_device_and_disk( device, disk ) ;
sleep( 1 ) ;//paranoia give the OS some time to update nodes in /dev
}
return return_value ;
@ -315,7 +317,7 @@ 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_Container_Partition( device_path, partition_old, partition_new ) ;
return Resize_Container_Partition( device_path, partition_old, partition_new, false ) ;
//these 3 still use libparted's resizer.
else if ( partition_old .filesystem == "linux-swap" ||
@ -484,7 +486,7 @@ int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Par
return new_partition .partition_number ;
}
bool GParted_Core::Resize_Container_Partition( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new )
bool GParted_Core::Resize_Container_Partition( const Glib::ustring & device_path, const Partition & partition_old, const Partition & partition_new, bool fixed_start )
{
bool return_value = false ;
@ -501,6 +503,17 @@ bool GParted_Core::Resize_Container_Partition( const Glib::ustring & device_path
if ( c_partition )
{
constraint = ped_constraint_any( device );
if ( fixed_start && constraint ) //create a constraint which keeps de startpoint intact and rounds the end to a cylinderboundary
{
ped_disk_set_partition_geom ( disk, c_partition, constraint, partition_new .sector_start, partition_new .sector_end ) ;
ped_constraint_destroy ( constraint );
constraint = NULL ;
ped_geometry_set_start ( & c_partition ->geom, partition_new .sector_start ) ;
constraint = ped_constraint_exact ( & c_partition ->geom ) ;
}
if ( constraint )
{
if ( ped_disk_set_partition_geom ( disk, c_partition, constraint, partition_new .sector_start, partition_new .sector_end ) )

View File

@ -57,10 +57,13 @@ void Partition::Set( const Glib::ustring & partition,
}
void Partition::Set_Unused( Sector sectors_unused )
{
if ( sectors_unused < ( sector_end - sector_start ) )
{
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 )
{

View File

@ -72,7 +72,7 @@ void ntfs::Set_Used_Sectors( Partition & partition )
bool ntfs::Create( const Glib::ustring device_path, const Partition & new_partition )
{
return Execute_Command( "mkntfs -Q " + new_partition .partition ) ;
return Execute_Command( "mkntfs " + new_partition .partition ) ;
}
bool ntfs::Resize( const Partition & partition_new, bool fill_partition )