diff --git a/ChangeLog b/ChangeLog index 3fe50140..4e6b0adc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-12-15 Bart Hakvoort + + * (all filesystem classes): fixed bug with thousand separator (#161362). + * ext2.cc, + ext3.cc: fixed bug with incorrect used/unused space after copying. + 2004-12-15 Bart Hakvoort * Added dialog (accessable from 'gparted' menu) which shows supported operations for the various filesystems. diff --git a/src/ext2.cc b/src/ext2.cc index aa55d1d6..aece96a1 100644 --- a/src/ext2.cc +++ b/src/ext2.cc @@ -59,7 +59,7 @@ void ext2::Set_Used_Sectors( Partition & partition ) Sector free_blocks = -1, blocksize = -1 ; //get free blocks.. - f = popen( ( "LANG=C dumpe2fs -h " + partition .partition ) .c_str( ), "r" ) ; + f = popen( ( "LC_ALL=C dumpe2fs -h " + partition .partition ) .c_str( ), "r" ) ; while ( fgets( c_buf, 512, f ) ) { output = Glib::locale_to_utf8( c_buf ) ; @@ -86,7 +86,7 @@ bool ext2::Create( const Glib::ustring device_path, const Partition & new_partit bool ext2::Resize( const Partition & partition_new, bool fill_partition ) { - Glib::ustring str_temp = "resize2fs " + partition_new .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" ; @@ -96,7 +96,14 @@ bool ext2::Resize( const Partition & partition_new, bool fill_partition ) bool ext2::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) { - return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; + if ( ! Execute_Command( "LC_NUMERIC=C dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) + { + Partition partition ; + partition .partition = dest_part_path ; + return Resize( partition, true ) ; + } + + return false ; } bool ext2::Check_Repair( const Partition & partition ) diff --git a/src/ext3.cc b/src/ext3.cc index 65287916..67e61d3d 100644 --- a/src/ext3.cc +++ b/src/ext3.cc @@ -59,7 +59,7 @@ void ext3::Set_Used_Sectors( Partition & partition ) Sector free_blocks = -1, blocksize = -1 ; //get free blocks.. - f = popen( ( "LANG=C dumpe2fs -h " + partition .partition ) .c_str( ), "r" ) ; + f = popen( ( "LC_ALL=C dumpe2fs -h " + partition .partition ) .c_str( ), "r" ) ; while ( fgets( c_buf, 512, f ) ) { output = Glib::locale_to_utf8( c_buf ) ; @@ -86,7 +86,7 @@ bool ext3::Create( const Glib::ustring device_path, const Partition & new_partit bool ext3::Resize( const Partition & partition_new, bool fill_partition ) { - Glib::ustring str_temp = "resize2fs " + partition_new .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" ; @@ -96,7 +96,14 @@ bool ext3::Resize( const Partition & partition_new, bool fill_partition ) bool ext3::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) { - return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; + if ( ! Execute_Command( "LC_NUMERIC=C dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) + { + Partition partition ; + partition .partition = dest_part_path ; + return Resize( partition, true ) ; + } + + return false ; } bool ext3::Check_Repair( const Partition & partition ) diff --git a/src/fat16.cc b/src/fat16.cc index c3e66818..18192f0a 100644 --- a/src/fat16.cc +++ b/src/fat16.cc @@ -43,7 +43,6 @@ FS fat16::get_filesystem_support( ) if ( ! system( "which dd 1>/dev/null 2>/dev/null" ) ) fs .copy = true ; - fs .MIN = 32 ; fs .MAX = 4096 ; @@ -92,7 +91,7 @@ bool fat16::Resize( const Partition & partition_new, bool fill_partition ) bool fat16::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) { - return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; + return ! Execute_Command( "LC_NUMERIC=C dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; } bool fat16::Check_Repair( const Partition & partition ) diff --git a/src/fat32.cc b/src/fat32.cc index 4bfdd65b..d19fc654 100644 --- a/src/fat32.cc +++ b/src/fat32.cc @@ -90,7 +90,7 @@ bool fat32::Resize( const Partition & partition_new, bool fill_partition ) bool fat32::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) { - return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; + return ! Execute_Command( "LC_NUMERIC=C dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; } bool fat32::Check_Repair( const Partition & partition ) diff --git a/src/hfs.cc b/src/hfs.cc index c34c8fcf..ccc5f21e 100644 --- a/src/hfs.cc +++ b/src/hfs.cc @@ -48,7 +48,7 @@ void hfs::Set_Used_Sectors( Partition & partition ) Glib::ustring output ; //get free bytes.. - f = popen( ( "LANG=C echo 'quit' | hfs " + partition .partition ) .c_str( ), "r" ) ; + f = popen( ( "LC_ALL=C echo 'quit' | hfs " + partition .partition ) .c_str( ), "r" ) ; while ( fgets( c_buf, 512, f ) ) { output = Glib::locale_to_utf8( c_buf ) ; @@ -76,7 +76,7 @@ bool hfs::Resize( const Partition & partition_new, bool fill_partition ) bool hfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) { - return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; + return ! Execute_Command( "LC_NUMERIC=C dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; } bool hfs::Check_Repair( const Partition & partition ) diff --git a/src/jfs.cc b/src/jfs.cc index e8db23f9..ab351225 100644 --- a/src/jfs.cc +++ b/src/jfs.cc @@ -86,12 +86,14 @@ bool jfs::Resize( const Partition & partition_new, bool fill_partition ) bool jfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) { - if ( ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) + if ( ! Execute_Command( "LC_NUMERIC=C dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) { Partition partition ; partition .partition = dest_part_path ; return Resize( partition, true ) ; } + + return false ; } bool jfs::Check_Repair( const Partition & partition ) diff --git a/src/linux_swap.cc b/src/linux_swap.cc index d45cef3b..d4aa23f9 100644 --- a/src/linux_swap.cc +++ b/src/linux_swap.cc @@ -83,7 +83,7 @@ bool linux_swap::Resize( const Partition & partition_new, bool fill_partition ) bool linux_swap::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) { - return ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; + return ! Execute_Command( "LC_NUMERIC=C dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; } bool linux_swap::Check_Repair( const Partition & partition ) diff --git a/src/ntfs.cc b/src/ntfs.cc index 15ef3a4b..a816dee5 100644 --- a/src/ntfs.cc +++ b/src/ntfs.cc @@ -59,7 +59,7 @@ void ntfs::Set_Used_Sectors( Partition & partition ) Glib::ustring output ; //get free sectors.. - f = popen( ( "LANG=C ntfscluster --force " + partition .partition ) .c_str( ), "r" ) ; + f = popen( ( "LC_ALL=C ntfscluster --force " + partition .partition ) .c_str( ), "r" ) ; while ( fgets( c_buf, 512, f ) ) { output = Glib::locale_to_utf8( c_buf ) ; @@ -81,7 +81,7 @@ bool ntfs::Create( const Glib::ustring device_path, const Partition & new_partit 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 = "LC_NUMERIC=C echo y | ntfsresize -f " + partition_new .partition ; if ( ! fill_partition ) str_temp += " -s " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ; @@ -91,19 +91,21 @@ bool ntfs::Resize( const Partition & partition_new, bool fill_partition ) bool ntfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) { - bool ret_val = ! Execute_Command( "ntfsclone -f --overwrite " + dest_part_path + " " + src_part_path ) ; + if ( ! Execute_Command( "ntfsclone -f --overwrite " + dest_part_path + " " + src_part_path ) ) + { + Partition partition ; + partition .partition = dest_part_path ; + return Resize( partition, true ) ; + } - //resize to full to set correct used/unused - Execute_Command( "echo y | ntfsresize -f " + dest_part_path ) ; - - return ret_val ; + return false ; } 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 ! Execute_Command( "echo y | ntfsresize -f " + partition .partition ) ; + return Resize( partition, true ) ; } int ntfs::get_estimated_time( long MB_to_Consider ) diff --git a/src/reiserfs.cc b/src/reiserfs.cc index e9d1f191..f789cab2 100644 --- a/src/reiserfs.cc +++ b/src/reiserfs.cc @@ -63,7 +63,7 @@ void reiserfs::Set_Used_Sectors( Partition & partition ) Sector free_blocks = -1, blocksize = -1 ; //get free blocks.. - f = popen( ( "LANG=C debugreiserfs " + partition .partition ) .c_str( ), "r" ) ; + f = popen( ( "LC_ALL=C debugreiserfs " + partition .partition ) .c_str( ), "r" ) ; while ( fgets( c_buf, 512, f ) ) { output = Glib::locale_to_utf8( c_buf ) ; @@ -89,7 +89,7 @@ bool reiserfs::Create( const Glib::ustring device_path, const Partition & new_pa bool reiserfs::Resize( const Partition & partition_new, bool fill_partition ) { - Glib::ustring str_temp = "echo y | resize_reiserfs " + partition_new .partition ; + Glib::ustring str_temp = "LC_NUMERIC=C echo y | resize_reiserfs " + partition_new .partition ; if ( ! fill_partition ) str_temp += " -s " + num_to_str( partition_new .Get_Length_MB( ) - cylinder_size ) + "M" ; @@ -99,22 +99,23 @@ bool reiserfs::Resize( const Partition & partition_new, bool fill_partition ) bool reiserfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) { - //copy partition - bool ret_val = ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ; + if ( ! Execute_Command( "LC_NUMERIC=C dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) + { + Partition partition ; + partition .partition = dest_part_path ; + return Resize( partition, true ) ; + } - //and set proper used/unused - Execute_Command( "resize_reiserfs " + dest_part_path ) ; - - return ret_val ; + return false ; } bool reiserfs::Check_Repair( const Partition & partition ) { //according to the manpage it should return 0 or 1 on succes, instead it returns 256 on succes.. - //blah, don't have time for this. Just check for both options, we'll fix this in 0.0.8 with our much improved errorhandling + //blah, don't have time for this. Just check for both options, we'll fix this later with our much improved errorhandling int t = Execute_Command( "reiserfsck -y --fix-fixable " + partition .partition ) ; - return ( t <=1 || t == 256 ) ; + return ( t <= 1 || t == 256 ) ; } int reiserfs::get_estimated_time( long MB_to_Consider ) diff --git a/src/xfs.cc b/src/xfs.cc index f33abc33..5877b87a 100644 --- a/src/xfs.cc +++ b/src/xfs.cc @@ -68,7 +68,7 @@ void xfs::Set_Used_Sectors( Partition & partition ) Sector free_blocks = -1, blocksize = -1 ; //get free blocks.. - f = popen( ( "LANG=C xfs_db -c 'sb 0' -c print -r " + partition .partition ) .c_str( ), "r" ) ; + f = popen( ( "LC_ALL=C xfs_db -c 'sb 0' -c print -r " + partition .partition ) .c_str( ), "r" ) ; while ( fgets( c_buf, 512, f ) ) { output = Glib::locale_to_utf8( c_buf ) ; @@ -111,7 +111,7 @@ bool xfs::Resize( const Partition & partition_new, bool fill_partition ) bool xfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest_part_path ) { - if ( ! Execute_Command( "dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) + if ( ! Execute_Command( "LC_NUMERIC=C dd bs=8192 if=" + src_part_path + " of=" + dest_part_path ) ) { Partition partition ; partition .partition = dest_part_path ;