From 32711970862944f38cc80daf2c60826f370bde44 Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Thu, 25 Nov 2004 19:21:42 +0000 Subject: [PATCH] fixed small bug with resizing and lower limits. use * src/Dialog_Partition_Resize_Move.cc: fixed small bug with resizing and lower limits. * src/GParted_Core.cc: use ped_file_system_clobber before creating a filesystem on a partition. * src/Win_GParted.cc: pasting is now only allowed if unallocated >= copied partition + cylindersize. Instead of dividing length device by amount of cylinders i use heads * sectors/track to get cylindersize. Changed device busy warning a bit to more decent english (adamw) * src/ntfs.cc: readded '-Q' to mkntfs. The error about an 'unknown filesystem' was related to detection problems and not to faulty creation of the filesystem. Should be solved anyway by implementing ped_file_system_clobber. Also removed ntfsfix since it didn't do anything relevant. Instead i use ntfsresize, because this contains relevant checks (szaka) --- ChangeLog | 13 ++++++++++++- src/Dialog_Partition_Resize_Move.cc | 21 ++++++++++++++------- src/GParted_Core.cc | 18 ++++++++++++++++-- src/Win_GParted.cc | 16 ++++++++++++---- src/ntfs.cc | 6 ++++-- 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 365bc3f3..8dae8fa4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2004-11-24 Bart Hakvoort + + * src/Dialog_Partition_Resize_Move.cc: fixed small bug with resizing and lower limits. + * src/GParted_Core.cc: use ped_file_system_clobber before creating a filesystem on a partition. + * src/Win_GParted.cc: pasting is now only allowed if unallocated >= copied partition + cylindersize. + Instead of dividing length device by amount of cylinders i use heads * sectors/track to get cylindersize. + Changed device busy warning a bit to more decent english (adamw) + * src/ntfs.cc: readded '-Q' to mkntfs. The error about an 'unknown filesystem' was related to detection problems and not to + faulty creation of the filesystem. Should be solved anyway by implementing ped_file_system_clobber. + Also removed ntfsfix since it didn't do anything relevant. Instead i use ntfsresize, because this contains relevant checks (szaka) + 2004-11-24 Bart Hakvoort * src/TreeView_Detail.cc: renamed columnheader from 'Type' to 'Filesystem'. Dunno why it was called 'Type' (maybe some PM legacy =) ) @@ -30,7 +41,7 @@ src/GParted_Core.cc, src/Makefile.am, include/ntfs.h, - src/ntfs.cc: added full ntfs support. (couldn't test it very will due to the absence of a win32 box :P ) + src/ntfs.cc: added full ntfs support. (couldn't test it very well due to the absence of a win32 box :P ) 2004-11-22 Bart Hakvoort diff --git a/src/Dialog_Partition_Resize_Move.cc b/src/Dialog_Partition_Resize_Move.cc index cf61f258..86846e1f 100644 --- a/src/Dialog_Partition_Resize_Move.cc +++ b/src/Dialog_Partition_Resize_Move.cc @@ -23,6 +23,11 @@ namespace GParted Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move( std::vector FILESYSTEMS, Sector cylinder_size ) { this ->FILESYSTEMS = FILESYSTEMS ; + + //some disk have a small cylindersize, for safetyreasons i keep this size at >=1 + if ( cylinder_size < 2048 ) + cylinder_size = 2048 ; + BUF = Sector_To_MB( cylinder_size ) *2 ; } @@ -111,14 +116,16 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector selected_partition .Get_Length_MB( ) ) @@ -139,7 +146,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const std::vector geom ) ; + + close_device_and_disk( device, disk ) ; + } + + set_proper_filesystem( partition .filesystem ) ; + return p_filesystem ->Create( device_path, partition ) ; } @@ -470,6 +481,9 @@ int GParted_Core::Create_Empty_Partition( const Glib::ustring & device_path, Par if ( ped_disk_add_partition ( disk, c_part, constraint ) && Commit( disk ) ) { + //remove all filesystem signatures... + ped_file_system_clobber ( & c_part ->geom ) ; + sleep( 1 ) ;//the OS needs some time to create the devicenode in /dev new_partition .partition = ped_partition_get_path( c_part ) ; diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc index 859e7e4c..418443d5 100644 --- a/src/Win_GParted.cc +++ b/src/Win_GParted.cc @@ -586,8 +586,16 @@ void Win_GParted::Set_Valid_Operations() allow_new( true ); //find out if there is a copied partition and if it fits inside this unallocated space - if ( copied_partition .partition != "NONE" && copied_partition .Get_Length_MB( ) < selected_partition .Get_Length_MB( ) ) - allow_paste( true ) ; + if ( copied_partition .partition != "NONE" ) + { + //calculate cylindersize + long cylinder_size = Sector_To_MB( devices[ current_device ] .heads * devices[ current_device ] .sectors ) ; + if ( cylinder_size < 1 ) + cylinder_size = 1 ; + + if ( (copied_partition .Get_Length_MB( ) + cylinder_size) < selected_partition .Get_Length_MB( ) ) + allow_paste( true ) ; + } return ; } @@ -846,7 +854,7 @@ void Win_GParted::activate_resize() operations[ t ] .Apply_Operation_To_Visual( partitions ) ; - Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( ), devices[ current_device ] .length / devices[ current_device ] .cylinders ) ; + Dialog_Partition_Resize_Move dialog( gparted_core .get_fs( ), devices[ current_device ] .heads * devices[ current_device ] .sectors ) ; if ( selected_partition .type == GParted::LOGICAL ) { @@ -1161,7 +1169,7 @@ void Win_GParted::activate_apply() str_temp += "\n\n" ; str_temp += _("A busy device is a device with at least one mounted partition.") ; str_temp += "\n"; - str_temp += _("Since making changes to a busy device may confuse the kernel it is advisable to reboot your computer.") ; + str_temp += _("Because making changes to a busy device may confuse the kernel, you are advised to reboot your computer.") ; Gtk::MessageDialog dialog( *this, str_temp, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true ); dialog .run( ) ; diff --git a/src/ntfs.cc b/src/ntfs.cc index 8428f6ca..7f377515 100644 --- a/src/ntfs.cc +++ b/src/ntfs.cc @@ -72,7 +72,7 @@ void ntfs::Set_Used_Sectors( Partition & partition ) bool ntfs::Create( const Glib::ustring device_path, const Partition & new_partition ) { - return Execute_Command( "mkntfs " + new_partition .partition ) ; + return Execute_Command( "mkntfs -Q " + new_partition .partition ) ; } bool ntfs::Resize( const Partition & partition_new, bool fill_partition ) @@ -95,7 +95,9 @@ bool ntfs::Copy( const Glib::ustring & src_part_path, const Glib::ustring & dest bool ntfs::Check_Repair( const Partition & partition ) { - return Execute_Command( "ntfsfix " + 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 ) ; } int ntfs::get_estimated_time( long MB_to_Consider )