Apollon, ☺
In den Resize- Methoden in ext3.cc, ntfs.cc usw. steht jeweils sowas:
bool ext3::Resize( const Partition & partition_new, bool fill_partition )
{
Glib::ustring str_temp = "LC_NUMERIC=C resize2fs " + partition_new .partition ;
if ( ! fill_partition )
str_temp += " " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ;
return ! Execute_Command( str_temp ) ;
}
num_to_str ist in Utils.h definiert:
inline Glib::ustring num_to_str( Sector number )
{
std::ostringstream os;
os .imbue( std::locale("") );
os << number ;
return os .str() ;
}
Dies wird sowohl in den resize-Funktionen (evtl. auch anderswo, mal schauen) als auch von der GUI verwendet. In letzterem Fall ist das ja ganz nett, in ersterem ist die Formatierung irgendwie idiotisch, oder? Das Ganze ist nur beim Verkleinern relevant, denn beim Vergrößern ist fill_partition wahr, so daß gar keine Größenangabe übergeben wird - siehe GParted_Core.cc:
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, false ) ;
//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 ) ;
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 ;
}
Saubere Lösung IMO: entweder die blöde Formatierung allgemein rausnehmen, oder für die GUI eine separate Funktion mit dieser Formatierung verwenden.
Stimmt das so? Bin kein Informatiker, und schon gar kein Programmierer, und dies ist der erste C++-Quelltext, den ich je gelesen habe, also habt bitte Nachsicht...