From ac82ee04531e4f24654fc7a56ee82d740bec0aae Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Sun, 1 Oct 2006 13:08:57 +0000 Subject: [PATCH] Replaced std::abs with llabs (see #357691) added support for reading of * src/GParted_Core: Replaced std::abs with llabs (see #357691) * src/hfs.cc, src/xfs.cc: added support for reading of volumelabel * src/reiserfs.cc: added Fixme --- ChangeLog | 7 +++++++ po/ChangeLog | 4 ++++ po/POTFILES.in | 1 + src/GParted_Core.cc | 24 +++++++++++------------- src/hfs.cc | 34 +++++++++++++++++++++++++++++++++- src/reiserfs.cc | 1 + src/xfs.cc | 27 +++++++++++++++++++++++++++ 7 files changed, 84 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index e982a139..9687bf4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-10-01 Bart Hakvoort + + * src/GParted_Core: Replaced std::abs with llabs (see #357691) + * src/hfs.cc, + src/xfs.cc: added support for reading of volumelabel + * src/reiserfs.cc: added Fixme + 2006-09-26 Bart Hakvoort * configure.in: Fix libparted detection in case --as-needed flag is diff --git a/po/ChangeLog b/po/ChangeLog index ac2bd71a..52869ae9 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2006-10-01 Bart Hakvoort + + * POTFILES.in: added src/HBoxOperations.cc + 2006-09-25 Daniel Nylander * sv.po: Updated Swedish translation. diff --git a/po/POTFILES.in b/po/POTFILES.in index 259faf3a..a8a5e26d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -11,6 +11,7 @@ src/Dialog_Progress.cc src/DialogFeatures.cc src/DialogManageFlags.cc src/GParted_Core.cc +src/HBoxOperations.cc src/OperationCopy.cc src/OperationCreate.cc src/OperationDelete.cc diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 175e3aa8..c9faa82f 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -513,7 +513,7 @@ void GParted_Core::read_mountpoints_from_file( const Glib::ustring & filename, index = line .find( "\\040" ) ; if ( index < line .length() ) line .replace( index, 4, " " ) ; - + map[ node ] .push_back( line ) ; } @@ -1620,7 +1620,7 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device, while ( succes && timer .elapsed() <= smallest_time && - std::abs( done ) + N <= length && + std::llabs( done ) + N <= length && optimal_blocksize * 2 < N ) { if ( done != 0 ) @@ -1664,7 +1664,7 @@ bool GParted_Core::copy_filesystem( const Glib::ustring & src_device, dst_device, src_start + ( dst_start > src_start ? 0 : done ), dst_start + ( dst_start > src_start ? 0 : done ), - length - std::abs( done ), + length - std::llabs( done ), optimal_blocksize, operationdetail, readonly, @@ -1838,7 +1838,7 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device, if ( lp_device_src && lp_device_dst && ped_device_open( lp_device_src ) && ped_device_open( lp_device_dst ) ) { Glib::ustring error_message ; - buf = static_cast( malloc( std::abs( blocksize ) * 512 ) ) ; + buf = static_cast( malloc( std::llabs( blocksize ) * 512 ) ) ; if ( buf ) { ped_device_sync( lp_device_dst ) ; @@ -1859,7 +1859,7 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device, operationdetail .get_last_child() .add_child( OperationDetail( "", STATUS_NONE ) ) ; Glib::Timer timer_progress_timeout, timer_total ; - while( succes && std::abs( done ) < length ) + while( succes && std::llabs( done ) < length ) { succes = copy_block( lp_device_src, lp_device_dst, @@ -1874,7 +1874,7 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device, if ( timer_progress_timeout .elapsed() >= 0.5 ) { set_progress_info( length, - std::abs( done + blocksize ), + std::llabs( done + blocksize ), timer_total, operationdetail .get_last_child() .get_last_child(), readonly ) ; @@ -1893,13 +1893,13 @@ bool GParted_Core::copy_blocks( const Glib::ustring & src_device, //final description operationdetail .get_last_child() .get_last_child() .set_description( - String::ucompose( readonly ? _("%1 of %2 read") : _("%1 of %2 copied"), std::abs( done ), length ), FONT_ITALIC ) ; + String::ucompose( readonly ? _("%1 of %2 read") : _("%1 of %2 copied"), std::llabs( done ), length ), FONT_ITALIC ) ; if ( ! succes && ! error_message .empty() ) operationdetail .get_last_child() .add_child( OperationDetail( error_message, STATUS_NONE, FONT_ITALIC ) ) ; - total_done += std::abs( done ) ; + total_done += std::llabs( done ) ; //close and destroy the devices.. ped_device_close( lp_device_src ) ; @@ -1924,11 +1924,9 @@ bool GParted_Core::copy_block( PedDevice * lp_device_src, Glib::ustring & error_message, bool readonly ) { - bool succes = false ; - if ( blocksize < 0 ) { - blocksize = std::abs( blocksize ) ; + blocksize = std::llabs( blocksize ) ; offset_src -= ( blocksize -1 ) ; offset_dst -= ( blocksize -1 ) ; } @@ -1938,7 +1936,7 @@ bool GParted_Core::copy_block( PedDevice * lp_device_src, if ( ped_device_read( lp_device_src, buf, offset_src, blocksize ) ) { if ( readonly || ped_device_write( lp_device_dst, buf, offset_dst, blocksize ) ) - succes = true ; + return true ; else error_message = String::ucompose( _("Error while writing block at sector %1"), offset_dst ) ; } @@ -1946,7 +1944,7 @@ bool GParted_Core::copy_block( PedDevice * lp_device_src, error_message = String::ucompose( _("Error while reading block at sector %1"), offset_src ) ; } - return succes ; + return false ; } bool GParted_Core::calibrate_partition( Partition & partition, OperationDetail & operationdetail ) diff --git a/src/hfs.cc b/src/hfs.cc index 0458909c..d5266e06 100644 --- a/src/hfs.cc +++ b/src/hfs.cc @@ -33,6 +33,12 @@ FS hfs::get_filesystem_support() if ( ! Glib::find_program_in_path( "hformat" ) .empty() ) fs .create = GParted::FS::EXTERNAL ; + if ( ! Glib::find_program_in_path( "hfsck" ) .empty() ) + { + fs .get_label = FS::EXTERNAL ; + fs .check = FS::EXTERNAL ; + } + fs .copy = GParted::FS::GPARTED ; fs .move = GParted::FS::GPARTED ; @@ -47,6 +53,31 @@ void hfs::set_used_sectors( Partition & partition ) void hfs::get_label( Partition & partition ) { + if ( ! Utils::execute_command( "hfsck -v " + partition .get_path(), output, error, true ) ) + { + char buf[512] ; + index = output .find( "drVN" ) ; + + if ( index < output .length() && sscanf( output .substr( index ) .c_str(), "drVN = %512s", buf ) == 1 ) + { + partition .label = buf ; + + //remove "" from the label.. + if ( partition .label .size() > 0 && partition .label[0] == '\"' ) + partition .label = partition .label .substr( 1 ) ; + + if ( partition .label .size() > 0 && partition .label[ partition .label .size() -1 ] == '\"' ) + partition .label = partition .label .substr( 0, partition .label .size() -1 ) ; + } + } + else + { + if ( ! output .empty() ) + partition .messages .push_back( output ) ; + + if ( ! error .empty() ) + partition .messages .push_back( error ) ; + } } bool hfs::create( const Partition & new_partition, OperationDetail & operationdetail ) @@ -68,7 +99,8 @@ bool hfs::copy( const Glib::ustring & src_part_path, bool hfs::check_repair( const Partition & partition, OperationDetail & operationdetail ) { - return true ; + //FIXME: find out what the returnvalue is in case of modified.. also check what the -a flag does.. (there is no manpage) + return ! execute_command( "hfsck -v " + partition .get_path(), operationdetail ) ; } } //GParted diff --git a/src/reiserfs.cc b/src/reiserfs.cc index 3ea07463..7d4fe4c6 100644 --- a/src/reiserfs.cc +++ b/src/reiserfs.cc @@ -87,6 +87,7 @@ void reiserfs::set_used_sectors( Partition & partition ) void reiserfs::get_label( Partition & partition ) { + //FIXME: i think running debugreiserfs takes a long time on filled filesystems, test for this... if ( ! Utils::execute_command( "debugreiserfs " + partition .get_path(), output, error, true ) ) { char buf[512] ; diff --git a/src/xfs.cc b/src/xfs.cc index a86603ad..f6b6afc3 100644 --- a/src/xfs.cc +++ b/src/xfs.cc @@ -29,7 +29,10 @@ FS xfs::get_filesystem_support() fs .filesystem = GParted::FS_XFS ; if ( ! Glib::find_program_in_path( "xfs_db" ) .empty() ) + { fs .read = GParted::FS::EXTERNAL ; + fs .get_label = FS::EXTERNAL ; + } if ( ! Glib::find_program_in_path( "mkfs.xfs" ) .empty() ) fs .create = GParted::FS::EXTERNAL ; @@ -103,6 +106,30 @@ void xfs::set_used_sectors( Partition & partition ) void xfs::get_label( Partition & partition ) { + if ( ! Utils::execute_command( "xfs_db -c 'label' " + partition .get_path(), output, error, true ) ) + { + char buf[512] ; + if ( sscanf( output .c_str(), "label = %512s", buf ) == 1 ) + { + partition .label = buf ; + + //remove "" from the label.. + if ( partition .label .size() > 0 && partition .label[0] == '\"' ) + partition .label = partition .label .substr( 1 ) ; + + if ( partition .label .size() > 0 && partition .label[ partition .label .size() -1 ] == '\"' ) + partition .label = partition .label .substr( 0, partition .label .size() -1 ) ; + } + } + else + { + if ( ! output .empty() ) + partition .messages .push_back( output ) ; + + if ( ! error .empty() ) + partition .messages .push_back( error ) ; + } + } bool xfs::create( const Partition & new_partition, OperationDetail & operationdetail )