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
This commit is contained in:
Bart Hakvoort 2006-10-01 13:08:57 +00:00
parent ecd3caee17
commit ac82ee0453
7 changed files with 84 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2006-10-01 Bart Hakvoort <hakvoort@cvs.gnome.org>
* 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 <hakvoort@cvs.gnome.org>
* configure.in: Fix libparted detection in case --as-needed flag is

View File

@ -1,3 +1,7 @@
2006-10-01 Bart Hakvoort <hakvoort@cvs.gnome.org>
* POTFILES.in: added src/HBoxOperations.cc
2006-09-25 Daniel Nylander <po@danielnylander.se>
* sv.po: Updated Swedish translation.

View File

@ -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

View File

@ -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<char *>( malloc( std::abs( blocksize ) * 512 ) ) ;
buf = static_cast<char *>( 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 )

View File

@ -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

View File

@ -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] ;

View File

@ -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 )