diff -Nur gparted-0.1/include/FileSystem.h gparted-0.1.new/include/FileSystem.h --- gparted-0.1/include/FileSystem.h 2005-12-28 16:43:05.000000000 +0000 +++ gparted-0.1.new/include/FileSystem.h 2006-05-23 11:04:00.412308587 +0100 @@ -46,7 +46,7 @@ Glib::RefPtr textbuffer ; - long cylinder_size ; //see GParted_Core::Resize() + Sector cylinder_size ; //see GParted_Core::resize() protected: int Execute_Command( Glib::ustring command ) ; diff -Nur gparted-0.1/include/Utils.h gparted-0.1.new/include/Utils.h --- gparted-0.1/include/Utils.h 2006-01-04 18:59:09.000000000 +0000 +++ gparted-0.1.new/include/Utils.h 2006-05-23 10:45:22.214308587 +0100 @@ -37,7 +37,11 @@ typedef long long Sector; -#define MEGABYTE 2048 //try it: 2048 * 512 / 1024 /1024 == 1 :P +//sizeunits defined in sectors of 512 bytes.. +#define KIBIBYTE 2 +#define MEBIBYTE 2048 +#define GIBIBYTE 2097152 +#define TEBIBYTE 2147483648U enum FILESYSTEM { @@ -64,6 +68,17 @@ FS_UNUSED = 18 }; +enum SIZE_UNIT +{ + UNIT_SECTOR = 0, + UNIT_BYTE = 1, + + UNIT_KIB = 2, + UNIT_MIB = 3, + UNIT_GIB = 4, + UNIT_TIB = 5, +}; + //struct to store filesysteminformation struct FS { @@ -96,8 +111,7 @@ class Utils { public: - static long Round( double double_value ) ; - static long Sector_To_MB( Sector sectors ) ; + static Sector Round( double double_value ) ; static Gtk::Label * mk_label( const Glib::ustring & text, bool use_markup = true, bool align_left = true, @@ -115,6 +129,7 @@ const Glib::ustring & data = "" ) ; static bool unmount( const Glib::ustring & node, const Glib::ustring & mountpoint, Glib::ustring & error ) ; static Glib::ustring format_size( Sector size ) ; + static double sector_to_unit( Sector sectors, SIZE_UNIT size_unit ) ; }; diff -Nur gparted-0.1/src/Dialog_Base_Partition.cc gparted-0.1.new/src/Dialog_Base_Partition.cc --- gparted-0.1/src/Dialog_Base_Partition.cc 2006-01-06 23:47:34.000000000 +0000 +++ gparted-0.1.new/src/Dialog_Base_Partition.cc 2006-05-23 10:45:22.215308587 +0100 @@ -112,21 +112,21 @@ Partition Dialog_Base_Partition::Get_New_Partition( ) { if ( ORIG_BEFORE != spinbutton_before .get_value_as_int( ) ) - selected_partition .sector_start = START + spinbutton_before .get_value_as_int( ) * MEGABYTE ; + selected_partition .sector_start = START + spinbutton_before .get_value_as_int( ) * MEBIBYTE ; if ( ORIG_AFTER != spinbutton_after .get_value_as_int( ) ) - selected_partition .sector_end = selected_partition .sector_start + spinbutton_size .get_value_as_int( ) * MEGABYTE ; + selected_partition .sector_end = selected_partition .sector_start + spinbutton_size .get_value_as_int( ) * MEBIBYTE ; - //due to loss of precision during calcs from Sector -> MB and back, it is possible the new partition thinks it's bigger then it can be. Here we solve this. + //due to loss of precision during calcs from Sector -> MiB and back, it is possible the new partition thinks it's bigger then it can be. Here we solve this. if ( selected_partition .sector_start < START ) selected_partition .sector_start = START ; if ( selected_partition .sector_end > (START + total_length) ) selected_partition .sector_end = START + total_length ; //grow a bit into small freespace ( < 1MB ) - if ( (selected_partition .sector_start - START) < MEGABYTE ) + if ( (selected_partition .sector_start - START) < MEBIBYTE ) selected_partition .sector_start = START ; - if ( ( START + total_length - selected_partition .sector_end ) < MEGABYTE ) + if ( ( START + total_length - selected_partition .sector_end ) < MEBIBYTE ) selected_partition .sector_end = START + total_length ; //set new value of unused.. diff -Nur gparted-0.1/src/Dialog_Partition_New.cc gparted-0.1.new/src/Dialog_Partition_New.cc --- gparted-0.1/src/Dialog_Partition_New.cc 2006-01-07 13:34:09.000000000 +0000 +++ gparted-0.1.new/src/Dialog_Partition_New.cc 2006-05-23 10:45:22.216308587 +0100 @@ -130,10 +130,10 @@ default : part_type = GParted::TYPE_UNALLOCATED ; } - new_start = START + (Sector) (spinbutton_before .get_value( ) * MEGABYTE) ; - new_end = new_start + (Sector) (spinbutton_size .get_value( ) * MEGABYTE) ; + new_start = START + (Sector) (spinbutton_before .get_value( ) * MEBIBYTE) ; + new_end = new_start + (Sector) (spinbutton_size .get_value( ) * MEBIBYTE) ; - /* due to loss of precision during calcs from Sector -> MB and back, it is possible the new + /* due to loss of precision during calcs from Sector -> MiB and back, it is possible the new * partition thinks it's bigger then it can be. Here we try to solve this.*/ if ( new_start < selected_partition.sector_start ) new_start = selected_partition.sector_start ; @@ -148,10 +148,10 @@ new_start, new_end, selected_partition .inside_extended, false) ; - //grow new partition a bit if freespaces are < 1 MB - if ( (part_temp.sector_start - selected_partition.sector_start) < MEGABYTE ) + //grow new partition a bit if freespaces are < 1 MiB + if ( (part_temp.sector_start - selected_partition.sector_start) < MEBIBYTE ) part_temp.sector_start = selected_partition.sector_start ; - if ( (selected_partition.sector_end - part_temp.sector_end) < MEGABYTE ) + if ( (selected_partition.sector_end - part_temp.sector_end) < MEBIBYTE ) part_temp.sector_end = selected_partition.sector_end ; //if new is extended... diff -Nur gparted-0.1/src/Dialog_Partition_Resize_Move.cc gparted-0.1.new/src/Dialog_Partition_Resize_Move.cc --- gparted-0.1/src/Dialog_Partition_Resize_Move.cc 2005-12-13 21:30:13.000000000 +0000 +++ gparted-0.1.new/src/Dialog_Partition_Resize_Move.cc 2006-05-23 10:45:22.217308587 +0100 @@ -77,7 +77,7 @@ spinbutton_before .set_sensitive( false ) ; } - //calculate total size in MB's of previous, current and next partition + //calculate total size in MiB's of previous, current and next partition //first find index of partition unsigned int t; for ( t = 0 ; t < partitions .size( ) ; t++ ) @@ -99,7 +99,7 @@ next = partitions[t +1].sector_end - partitions[t +1].sector_start ; total_length = previous + (selected_partition.sector_end - selected_partition.sector_start) + next; - TOTAL_MB = Utils::Sector_To_MB( total_length ) ; + TOTAL_MB = Utils::Round( Utils::sector_to_unit( total_length, GParted::UNIT_MIB ) ) ; MB_PER_PIXEL = TOTAL_MB / 500.00 ; @@ -130,7 +130,7 @@ if ( ! fixed_start ) { spinbutton_before .set_range( 0, TOTAL_MB - fs .MIN ) ; - spinbutton_before .set_value( Utils::Sector_To_MB( previous ) ) ; + spinbutton_before .set_value( Utils::Round( Utils::sector_to_unit( previous, GParted::UNIT_MIB ) ) ) ; } //set values of spinbutton_size @@ -139,7 +139,7 @@ //set values of spinbutton_after spinbutton_after .set_range( 0, TOTAL_MB - fs .MIN ) ; - spinbutton_after .set_value( Utils::Sector_To_MB( next ) ) ; + spinbutton_after .set_value( Utils::Round( Utils::sector_to_unit( next, GParted::UNIT_MIB ) ) ) ; frame_resizer_base ->set_size_limits( Utils::Round( fs .MIN / MB_PER_PIXEL ), Utils::Round( fs .MAX / MB_PER_PIXEL ) +1 ) ; @@ -149,7 +149,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const std::vector & partitions ) { - //calculate total size in MB's of previous, current and next partition + //calculate total size in MiB's of previous, current and next partition //first find index of partition unsigned int t = 0; while ( t < partitions .size( ) && partitions[ t ] .type != GParted::TYPE_EXTENDED ) t++ ; @@ -171,7 +171,7 @@ //now we have enough data to calculate some important values.. total_length = previous + (selected_partition.sector_end - selected_partition.sector_start) + next; - TOTAL_MB = Utils::Sector_To_MB( total_length ) ; + TOTAL_MB = Utils::Round( Utils::sector_to_unit( total_length, UNIT_MIB ) ) ; MB_PER_PIXEL = TOTAL_MB / 500.00 ; //calculate proportional length of partition ( in pixels ) @@ -198,15 +198,15 @@ if ( first == 0 ) //no logicals spinbutton_before .set_range( 0, TOTAL_MB - BUF/2 ) ; else - spinbutton_before .set_range( 0, Utils::Sector_To_MB (first - START) ) ; + spinbutton_before .set_range( 0, Utils::Round( Utils::sector_to_unit( first - START, GParted::UNIT_MIB ) ) ) ; - spinbutton_before .set_value( Utils::Sector_To_MB ( previous ) ) ; + spinbutton_before .set_value( Utils::Round( Utils::sector_to_unit( previous, GParted::UNIT_MIB ) ) ) ; //set values of spinbutton_size if ( first == 0 ) //no logicals spinbutton_size .set_range( BUF/2, TOTAL_MB ) ; else - spinbutton_size .set_range( Utils::Sector_To_MB( used ), TOTAL_MB ) ; + spinbutton_size .set_range( Utils::Round( Utils::sector_to_unit( used, GParted::UNIT_MIB ) ), TOTAL_MB ) ; spinbutton_size .set_value( selected_partition .Get_Length_MB( ) ) ; @@ -214,12 +214,13 @@ if ( first == 0 ) //no logicals spinbutton_after .set_range( 0, TOTAL_MB - BUF/2 ) ; else - spinbutton_after .set_range( 0, Utils::Sector_To_MB( total_length + START - first - used) ) ; + spinbutton_after .set_range( 0, Utils::Round( Utils::sector_to_unit( total_length + START - first - used, GParted::UNIT_MIB ) ) ) ; - spinbutton_after .set_value( Utils::Sector_To_MB( next ) ) ; + spinbutton_after .set_value( Utils::Round( Utils::sector_to_unit( next, GParted::UNIT_MIB ) ) ) ; //set contents of label_minmax - Set_MinMax_Text( first == 0 ? BUF/2 : Utils::Sector_To_MB( used ), Utils::Sector_To_MB( total_length ) ) ; + Set_MinMax_Text( first == 0 ? BUF/2 : Utils::Round( Utils::sector_to_unit( used, GParted::UNIT_MIB ) ), + Utils::Round( Utils::sector_to_unit( total_length, GParted::UNIT_MIB ) ) ) ; } } //GParted diff -Nur gparted-0.1/src/GParted_Core.cc gparted-0.1.new/src/GParted_Core.cc --- gparted-0.1/src/GParted_Core.cc 2006-05-23 10:05:56.754308587 +0100 +++ gparted-0.1.new/src/GParted_Core.cc 2006-05-23 11:03:53.942308587 +0100 @@ -123,9 +123,10 @@ temp_device .sectors = lp_device ->bios_geom .sectors ; temp_device .cylinders = lp_device ->bios_geom .cylinders ; temp_device .length = temp_device .heads * temp_device .sectors * temp_device .cylinders ; - temp_device .cylsize = Utils::Sector_To_MB( temp_device .heads * temp_device .sectors ) ; + temp_device .cylsize = Utils::Round( Utils::sector_to_unit( + temp_device .heads * temp_device .sectors, GParted::UNIT_MIB ) ) ; - //make sure cylsize is at least 1 MB + //make sure cylsize is at least 1 MiB if ( temp_device .cylsize < 1 ) temp_device .cylsize = 1 ; @@ -449,7 +450,7 @@ } //start <---> first partition start - if ( (partitions .front( ) .sector_start - start) >= MEGABYTE ) + if ( (partitions .front( ) .sector_start - start) >= MEBIBYTE ) { partition_temp .sector_start = start ; partition_temp .sector_end = partitions .front( ) .sector_start -1 ; @@ -459,7 +460,7 @@ //look for gaps in between for ( unsigned int t =0 ; t < partitions .size( ) -1 ; t++ ) - if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= MEGABYTE ) + if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= MEBIBYTE ) { partition_temp .sector_start = partitions[ t ] .sector_end +1 ; partition_temp .sector_end = partitions[ t +1 ] .sector_start -1 ; @@ -468,7 +469,7 @@ } //last partition end <---> end - if ( (end - partitions .back( ) .sector_end ) >= MEGABYTE ) + if ( (end - partitions .back( ) .sector_end ) >= MEBIBYTE ) { partition_temp .sector_start = partitions .back( ) .sector_end +1 ; partition_temp .sector_end = end ; @@ -600,40 +601,44 @@ bool GParted_Core::Resize( const Device & device, const Partition & partition_old, const Partition & partition_new ) { + //extended partition if ( partition_old .type == GParted::TYPE_EXTENDED ) return Resize_Container_Partition( partition_old, partition_new, false ) ; - //lazy check (only grow). it's possbile one day this should be separated in checks for grow,shrink,move .. + //resize using libparted.. if ( get_fs( partition_old .filesystem ) .grow == GParted::FS::LIBPARTED ) return Resize_Normal_Using_Libparted( partition_old, partition_new ) ; - else //use custom resize tools.. + + //use custom resize tools.. + bool succes = false ; + set_proper_filesystem( partition_new .filesystem ) ; + + if ( p_filesystem && p_filesystem ->Check_Repair( partition_new ) ) { - set_proper_filesystem( partition_new .filesystem ) ; - - if ( p_filesystem ->Check_Repair( partition_new ) ) - { - //shrinking - if ( partition_new .Get_Length_MB( ) < partition_old .Get_Length_MB( ) ) - { - p_filesystem ->cylinder_size = device .cylsize ; - - if ( p_filesystem ->Resize( partition_new ) ) - Resize_Container_Partition( partition_old, partition_new, ! get_fs( partition_new .filesystem ) .move ) ; - } - //growing/moving - else - Resize_Container_Partition( partition_old, partition_new, ! get_fs( partition_new .filesystem ) .move ) ; - + succes = true ; - p_filesystem ->Check_Repair( partition_new ) ; + if ( partition_new .get_length() < partition_old .get_length() ) + { + p_filesystem ->cylinder_size = MEBIBYTE * device .cylsize ; + succes = p_filesystem ->Resize( partition_new ) ; + } + + if ( succes ) + succes = Resize_Container_Partition( partition_old, partition_new, ! get_fs( partition_new .filesystem ) .move ) ; - p_filesystem ->Resize( partition_new, true ) ; //expand filesystem to fit exactly in partition + //these 3 are always executed, however, if 1 of them fails the whole operation fails + if ( ! p_filesystem ->Check_Repair( partition_new ) ) + succes = false ; + + //expand filesystem to fit exactly in partition + if ( ! p_filesystem ->Resize( partition_new, true ) ) + succes = false ; - return p_filesystem ->Check_Repair( partition_new ) ; - } + if ( ! p_filesystem ->Check_Repair( partition_new ) ) + succes = false ; } - - return false ; + + return succes ; } bool GParted_Core::Copy( const Glib::ustring & src_part_path, Partition & partition_dest ) @@ -778,7 +783,7 @@ if ( constraint ) { if ( copy ) - constraint ->min_size = new_partition .sector_end - new_partition .sector_start ; + constraint ->min_size = new_partition .get_length() ; if ( ped_disk_add_partition( lp_disk, c_part, constraint ) && commit( ) ) { diff -Nur gparted-0.1/src/Operation.cc gparted-0.1.new/src/Operation.cc --- gparted-0.1/src/Operation.cc 2006-01-04 18:59:09.000000000 +0000 +++ gparted-0.1.new/src/Operation.cc 2006-05-23 10:45:22.220308587 +0100 @@ -80,20 +80,24 @@ device .path ) ; case RESIZE_MOVE: - //if startsector has changed >= 1 MB we consider it a move + //if startsector has changed >= 1 MiB we consider it a move diff = std::abs( partition_new .sector_start - partition_original .sector_start ) ; - if ( diff >= MEGABYTE ) + if ( diff >= MEBIBYTE ) { if ( partition_new .sector_start > partition_original .sector_start ) - temp = String::ucompose( _("Move %1 forward by %2 MB"), partition_new.partition, Utils::Sector_To_MB( diff ) ) ; + temp = String::ucompose( _("Move %1 forward by %2 MB"), + partition_new.partition, + Utils::Round( Utils::sector_to_unit( diff, GParted::UNIT_MIB ) ) ) ; else - temp = String::ucompose( _("Move %1 backward by %2 MB"), partition_new.partition, Utils::Sector_To_MB( diff ) ) ; + temp = String::ucompose( _("Move %1 backward by %2 MB"), + partition_new.partition, + Utils::Round( Utils::sector_to_unit( diff, GParted::UNIT_MIB ) ) ) ; } - //check if size has changed ( we only consider changes >= 1 MB ) + //check if size has changed ( we only consider changes >= 1 MiB ) diff = std::abs( (partition_original .sector_end - partition_original .sector_start) - (partition_new .sector_end - partition_new .sector_start) ) ; - if ( diff >= MEGABYTE ) + if ( diff >= MEBIBYTE ) { if ( temp .empty( ) ) temp = String::ucompose( _("Resize %1 from %2 MB to %3 MB"), @@ -123,7 +127,7 @@ return String::ucompose( _("Copy %1 to %2 (start at %3 MB)"), partition_new .partition, device .path, - Utils::Sector_To_MB( partition_new .sector_start ) ) ; + Utils::Round( Utils::sector_to_unit( partition_new .sector_start, GParted::UNIT_MIB ) ) ) ; default : return ""; @@ -163,7 +167,7 @@ } //start <---> first partition start - if ( (partitions .front( ) .sector_start - start) >= MEGABYTE ) + if ( (partitions .front( ) .sector_start - start) >= MEBIBYTE ) { UNALLOCATED .sector_start = start ; UNALLOCATED .sector_end = partitions .front( ) .sector_start -1 ; @@ -173,7 +177,7 @@ //look for gaps in between for ( unsigned int t =0 ; t < partitions .size( ) -1 ; t++ ) - if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= MEGABYTE ) + if ( ( partitions[ t +1 ] .sector_start - partitions[ t ] .sector_end ) >= MEBIBYTE ) { UNALLOCATED .sector_start = partitions[ t ] .sector_end +1 ; UNALLOCATED .sector_end = partitions[ t +1 ] .sector_start -1 ; @@ -182,7 +186,7 @@ } //last partition end <---> end - if ( (end - partitions .back( ) .sector_end ) >= MEGABYTE ) + if ( (end - partitions .back( ) .sector_end ) >= MEBIBYTE ) { UNALLOCATED .sector_start = partitions .back( ) .sector_end +1 ; UNALLOCATED .sector_end = end ; diff -Nur gparted-0.1/src/Partition.cc gparted-0.1.new/src/Partition.cc --- gparted-0.1/src/Partition.cc 2006-01-07 13:33:31.000000000 +0000 +++ gparted-0.1.new/src/Partition.cc 2006-05-23 10:45:22.220308587 +0100 @@ -93,12 +93,12 @@ long Partition::Get_Length_MB() const { - return Utils::Sector_To_MB( sector_end - sector_start ) ; + return Utils::Round( Utils::sector_to_unit( get_length(), GParted::UNIT_MIB ) ) ; } long Partition::Get_Used_MB() const { - return Utils::Sector_To_MB( this ->sectors_used ) ; + return Utils::Round( Utils::sector_to_unit( sectors_used, GParted::UNIT_MIB ) ) ; } long Partition::Get_Unused_MB() const diff -Nur gparted-0.1/src/Utils.cc gparted-0.1.new/src/Utils.cc --- gparted-0.1/src/Utils.cc 2006-01-07 00:01:31.000000000 +0000 +++ gparted-0.1.new/src/Utils.cc 2006-05-23 10:45:22.221308587 +0100 @@ -26,14 +26,9 @@ namespace GParted { -long Utils::Round( double double_value ) +Sector Utils::Round( double double_value ) { - return static_cast( double_value + 0.5 ) ; -} - -long Utils::Sector_To_MB( Sector sectors ) -{ - return Round( sectors * 0.000488281250 ) ; // that's what 512/1024/1024 gives you :) + return static_cast( double_value + 0.5 ) ; } Gtk::Label * Utils::mk_label( const Glib::ustring & text, bool use_markup, bool align_left, bool wrap, const Glib::ustring & text_color ) @@ -241,21 +235,59 @@ Glib::ustring Utils::format_size( Sector size ) { - size *= 512 ; std::stringstream ss ; //ss .imbue( std::locale( "" ) ) ; see #157871 ss << std::setiosflags( std::ios::fixed ) << std::setprecision( 2 ) ; - if ( size < 1073741824 ) + if ( size < KIBIBYTE ) { - ss << static_cast( size / 1048567.0 ) ; + ss << sector_to_unit( size, UNIT_BYTE ) ; + return String::ucompose( _("%1 B"), ss .str() ) ; + } + else if ( size < MEBIBYTE ) + { + ss << sector_to_unit( size, UNIT_KIB ) ; + return String::ucompose( _("%1 KB"), ss .str() ) ; + } + else if ( size < GIBIBYTE ) + { + ss << sector_to_unit( size, UNIT_MIB ) ; return String::ucompose( _("%1 MB"), ss .str() ) ; } - else + else if ( size < TEBIBYTE ) { - ss << static_cast( size / 1073741824.0 ) ; + ss << sector_to_unit( size, UNIT_GIB ) ; return String::ucompose( _("%1 GB"), ss .str() ) ; } + else + { + ss << sector_to_unit( size, UNIT_TIB ) ; + return String::ucompose( _("%1 TB"), ss .str() ) ; + } +} + +double Utils::sector_to_unit( Sector sectors, SIZE_UNIT size_unit ) +{ + /* NOTE: this could have been done more efficient by using static numbers. + * However, the performancegain would be unnoticable and this way its easier to read/debug + */ + switch ( size_unit ) + { + case UNIT_BYTE : + return sectors * 512 ; + + case UNIT_KIB : + return sector_to_unit( sectors, UNIT_BYTE ) / 1024 ; + case UNIT_MIB : + return sector_to_unit( sectors, UNIT_KIB ) / 1024 ; + case UNIT_GIB : + return sector_to_unit( sectors, UNIT_MIB ) / 1024 ; + case UNIT_TIB : + return sector_to_unit( sectors, UNIT_GIB ) / 1024 ; + + default: + return sectors ; + } } } //GParted.. diff -Nur gparted-0.1/src/ext2.cc gparted-0.1.new/src/ext2.cc --- gparted-0.1/src/ext2.cc 2005-12-28 16:43:06.000000000 +0000 +++ gparted-0.1.new/src/ext2.cc 2006-05-23 10:51:46.506308587 +0100 @@ -90,7 +90,8 @@ Glib::ustring str_temp = "resize2fs " + partition_new .partition ; if ( ! fill_partition ) - str_temp += " " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ; + str_temp += " " + Utils::num_to_str( Utils::Round( Utils::sector_to_unit( + partition_new .get_length() - cylinder_size, GParted::UNIT_MIB ) ), true ) + "M" ; return ! Execute_Command( str_temp ) ; } diff -Nur gparted-0.1/src/ext3.cc gparted-0.1.new/src/ext3.cc --- gparted-0.1/src/ext3.cc 2005-12-28 16:43:06.000000000 +0000 +++ gparted-0.1.new/src/ext3.cc 2006-05-23 10:52:22.244308587 +0100 @@ -90,7 +90,8 @@ Glib::ustring str_temp = "resize2fs " + partition_new .partition ; if ( ! fill_partition ) - str_temp += " " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ; + str_temp += " " + Utils::num_to_str( Utils::Round( Utils::sector_to_unit( + partition_new .get_length() - cylinder_size, GParted::UNIT_MIB ) ), true ) + "M" ; return ! Execute_Command( str_temp ) ; } diff -Nur gparted-0.1/src/ntfs.cc gparted-0.1.new/src/ntfs.cc --- gparted-0.1/src/ntfs.cc 2005-12-28 16:43:06.000000000 +0000 +++ gparted-0.1.new/src/ntfs.cc 2006-05-23 11:27:57.594308587 +0100 @@ -84,12 +84,19 @@ bool ntfs::Resize( const Partition & partition_new, bool fill_partition ) { - Glib::ustring str_temp = "echo y | ntfsresize -f " + partition_new .partition ; + Glib::ustring str_temp = "ntfsresize -P --force --force " + partition_new .partition ; if ( ! fill_partition ) - str_temp += " -s " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ; + { + str_temp += " -s " ; + str_temp += Utils::num_to_str( Utils::Round( Utils::sector_to_unit( + partition_new .get_length() - cylinder_size, GParted::UNIT_BYTE ) ), true ) ; + } - return ! Execute_Command( str_temp ) ; + if ( ! Execute_Command( str_temp + " --no-action" ) ) + return ! Execute_Command( str_temp ); + else + return false; } bool ntfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) @@ -106,9 +114,7 @@ bool ntfs::Check_Repair( const Partition & partition ) { - //according to Szaka it's best to use ntfsresize to check the partition for errors - //since --info is read-only i'll leave it out. just calling ntfsresize --force has also a tendency of fixing stuff :) - return Resize( partition, true ) ; + return ! Execute_Command( "ntfsresize -P -i -f -v " + partition .partition ); } int ntfs::get_estimated_time( long MB_to_Consider ) diff -Nur gparted-0.1/src/reiserfs.cc gparted-0.1.new/src/reiserfs.cc --- gparted-0.1/src/reiserfs.cc 2005-12-28 16:43:06.000000000 +0000 +++ gparted-0.1.new/src/reiserfs.cc 2006-05-23 10:56:14.720308587 +0100 @@ -93,7 +93,11 @@ Glib::ustring str_temp = "echo y | resize_reiserfs " + partition_new .partition ; if ( ! fill_partition ) - str_temp += " -s " + Utils::num_to_str( partition_new .Get_Length_MB( ) - cylinder_size, true ) + "M" ; + { + str_temp += " -s " ; + str_temp += Utils::num_to_str( Utils::Round( Utils::sector_to_unit( + partition_new .get_length() - cylinder_size, GParted::UNIT_BYTE ) ), true ) ; + } return ! Execute_Command( str_temp ) ; }