diff --git a/ChangeLog b/ChangeLog index 3c7d549e..97264375 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,13 @@ * src/GParted_Core.cc: simplified algorithm to get remaining time +2006-09-04 Bart Hakvoort + + * include/GParted_Core.h, + src/GParted_Core.cc: update ntfsbootsector after first sector has + changed. This is necessary to let windows boot correctly afterwards. + * src/ntfs.cc: added FIXME + 2006-09-03 Bart Hakvoort * include/GParted_Core.h, diff --git a/include/GParted_Core.h b/include/GParted_Core.h index 772b2c95..0495960b 100644 --- a/include/GParted_Core.h +++ b/include/GParted_Core.h @@ -140,6 +140,7 @@ private: bool set_proper_filesystem( const FILESYSTEM & filesystem ) ; bool wait_for_node( const Glib::ustring & node ) ; bool erase_filesystem_signatures( const Partition & partition ) ; + bool update_bootsector( const Partition & partition, OperationDetail & operationdetail ) ; //general.. bool open_device( const Glib::ustring & device_path ) ; diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index 8a5c09dc..b72e2dae 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -1099,6 +1099,7 @@ bool GParted_Core::move( const Device & device, return check_repair_filesystem( partition_old, operationdetail ) && move_filesystem( partition_old, partition_new, operationdetail ) && resize_move_partition( partition_old, partition_new, operationdetail ) && + update_bootsector( partition_new, operationdetail ) && check_repair_filesystem( partition_new, operationdetail ) && maximize_filesystem( partition_new, operationdetail ) ; } @@ -1491,6 +1492,7 @@ bool GParted_Core::copy( const Partition & partition_src, operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ; return ( succes && + update_bootsector( partition_dst, operationdetail ) && check_repair_filesystem( partition_dst, operationdetail ) && maximize_filesystem( partition_dst, operationdetail ) ) ; } @@ -1909,7 +1911,7 @@ bool GParted_Core::calculate_exact_geom( const Partition & partition_old, FONT_ITALIC ) ) ; } - operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ; + operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ; return succes ; } @@ -1986,6 +1988,48 @@ bool GParted_Core::erase_filesystem_signatures( const Partition & partition ) return return_value ; } +bool GParted_Core::update_bootsector( const Partition & partition, OperationDetail & operationdetail ) +{ + //only for ntfs atm... + //FIXME: 1) this should be done without relying on external commands + // 2) this should probably be done in the fsclasses... + if ( partition .filesystem == FS_NTFS ) + { + operationdetail .add_child( OperationDetail( + String::ucompose( _("updating bootsector of %1 filesystem on %2"), + Utils::get_filesystem_string( partition .filesystem ), + partition .get_path() ) ) ) ; + + std::stringstream ss ; + ss << std::hex << partition .sector_start ; + Glib::ustring hex = ss .str() ; + + //fill with zeros and reverse... + hex .insert( 0, 8 - hex .length(), '0' ) ; + Glib::ustring reversed_hex ; + for ( int t = 6 ; t >= 0 ; t -=2 ) + reversed_hex .append( hex .substr( t, 2 ) ) ; + + Glib::ustring output, error, command ; + command = + "echo " + reversed_hex + " | /usr/bin/xxd -r -p | /bin/dd conv=notrunc of=" + partition .get_path() + " bs=1 seek=28" ; + + operationdetail .get_last_child() .add_child( OperationDetail( command, STATUS_NONE, FONT_BOLD_ITALIC ) ) ; + bool succes = ! Utils::execute_command( command, output, error ) ; + + if ( ! output .empty() ) + operationdetail .get_last_child() .get_last_child() .add_child( OperationDetail( output, STATUS_NONE, FONT_ITALIC ) ) ; + + if ( ! error .empty() ) + operationdetail .get_last_child() .get_last_child() .add_child( OperationDetail( error, STATUS_NONE, FONT_ITALIC ) ) ; + + operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ; + return succes ; + } + + return true ; +} + bool GParted_Core::open_device( const Glib::ustring & device_path ) { lp_device = ped_device_get( device_path .c_str() ); diff --git a/src/ntfs.cc b/src/ntfs.cc index 662e7423..5c8bcdba 100644 --- a/src/ntfs.cc +++ b/src/ntfs.cc @@ -67,7 +67,7 @@ void ntfs::set_used_sectors( Partition & partition ) if ( N > -1 ) partition .set_used( Utils::round( N / 512.0 ) ) ; } - else + else//FIXME: i think it's a good idea to push the output here as well partition .messages .push_back( error ) ; }