cleanups in the core and the fs'es (resize)
* cleanups in the core and the fs'es (resize)
This commit is contained in:
parent
8b4136b84d
commit
08245cd08c
|
@ -1,3 +1,7 @@
|
||||||
|
2006-06-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
|
* cleanups in the core and the fs'es (resize)
|
||||||
|
|
||||||
2006-06-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
2006-06-17 Bart Hakvoort <hakvoort@cvs.gnome.org>
|
||||||
|
|
||||||
* cleanups in the core and the fs'es (check/repair)
|
* cleanups in the core and the fs'es (check/repair)
|
||||||
|
|
|
@ -65,6 +65,12 @@ private:
|
||||||
const Partition & partition_old,
|
const Partition & partition_old,
|
||||||
Partition & partition_new,
|
Partition & partition_new,
|
||||||
std::vector<OperationDetails> & operation_detail ) ;
|
std::vector<OperationDetails> & operation_detail ) ;
|
||||||
|
bool resize_filesystem( const Partition & partition_old,
|
||||||
|
const Partition & partition_new,
|
||||||
|
std::vector<OperationDetails> & operation_details,
|
||||||
|
Sector cylinder_size = 0,
|
||||||
|
bool fill_partition = false ) ;
|
||||||
|
|
||||||
bool copy( const Partition & partition_src,
|
bool copy( const Partition & partition_src,
|
||||||
Partition & partition_dest,
|
Partition & partition_dest,
|
||||||
Sector min_size,
|
Sector min_size,
|
||||||
|
@ -105,7 +111,7 @@ private:
|
||||||
std::vector<OperationDetails> & operation_details,
|
std::vector<OperationDetails> & operation_details,
|
||||||
Sector block_size ) ;
|
Sector block_size ) ;
|
||||||
bool check_repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
|
bool check_repair( const Partition & partition, std::vector<OperationDetails> & operation_details ) ;
|
||||||
void set_proper_filesystem( const FILESYSTEM & filesystem ) ;
|
void set_proper_filesystem( const FILESYSTEM & filesystem, Sector cylinder_size = 0 ) ;
|
||||||
bool set_partition_type( const Partition & partition,
|
bool set_partition_type( const Partition & partition,
|
||||||
std::vector<OperationDetails> & operation_details ) ;
|
std::vector<OperationDetails> & operation_details ) ;
|
||||||
bool wait_for_node( const Glib::ustring & node ) ;
|
bool wait_for_node( const Glib::ustring & node ) ;
|
||||||
|
|
|
@ -892,13 +892,9 @@ bool GParted_Core::resize( const Device & device,
|
||||||
if ( check_repair( partition_new, operation_details ) )
|
if ( check_repair( partition_new, operation_details ) )
|
||||||
{
|
{
|
||||||
succes = true ;
|
succes = true ;
|
||||||
set_proper_filesystem( partition_new .filesystem ) ;
|
//FIXME, find another way to resolve this cylsize problem...
|
||||||
|
|
||||||
if ( partition_new .get_length() < partition_old .get_length() )
|
if ( partition_new .get_length() < partition_old .get_length() )
|
||||||
{
|
succes = resize_filesystem( partition_old, partition_new, operation_details, device .cylsize ) ;
|
||||||
p_filesystem ->cylinder_size = device .cylsize ;
|
|
||||||
succes = p_filesystem ->Resize( partition_new, operation_details ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( succes )
|
if ( succes )
|
||||||
succes = resize_partition(
|
succes = resize_partition(
|
||||||
|
@ -912,7 +908,7 @@ bool GParted_Core::resize( const Device & device,
|
||||||
succes = false ;
|
succes = false ;
|
||||||
|
|
||||||
//expand filesystem to fit exactly in partition
|
//expand filesystem to fit exactly in partition
|
||||||
if ( ! p_filesystem ->Resize( partition_new, operation_details, true ) )
|
if ( ! resize_filesystem( partition_old, partition_new, operation_details, device .cylsize, true ) )
|
||||||
succes = false ;
|
succes = false ;
|
||||||
|
|
||||||
if ( ! check_repair( partition_new, operation_details ) )
|
if ( ! check_repair( partition_new, operation_details ) )
|
||||||
|
@ -924,6 +920,35 @@ bool GParted_Core::resize( const Device & device,
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GParted_Core::resize_filesystem( const Partition & partition_old,
|
||||||
|
const Partition & partition_new,
|
||||||
|
std::vector<OperationDetails> & operation_details,
|
||||||
|
Sector cylinder_size,
|
||||||
|
bool fill_partition )
|
||||||
|
{
|
||||||
|
if ( fill_partition )
|
||||||
|
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
|
||||||
|
else if ( partition_new .get_length() < partition_old .get_length() )
|
||||||
|
operation_details .push_back( OperationDetails( _("shrink filesystem") ) ) ;
|
||||||
|
else if ( partition_new .get_length() > partition_old .get_length() )
|
||||||
|
operation_details .push_back( OperationDetails( _("grow filesystem") ) ) ;
|
||||||
|
else
|
||||||
|
operation_details .push_back(
|
||||||
|
OperationDetails( _("new and old partition have the same size. continuing anyway") ) ) ;
|
||||||
|
|
||||||
|
set_proper_filesystem( partition_new .filesystem, cylinder_size ) ;
|
||||||
|
if ( p_filesystem && p_filesystem ->Resize( partition_new, operation_details .back() .sub_details, fill_partition ) )
|
||||||
|
{
|
||||||
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool GParted_Core::copy( const Partition & partition_src,
|
bool GParted_Core::copy( const Partition & partition_src,
|
||||||
Partition & partition_dest,
|
Partition & partition_dest,
|
||||||
Sector min_size,
|
Sector min_size,
|
||||||
|
@ -1272,7 +1297,13 @@ bool GParted_Core::resize_partition( const Partition & partition_old,
|
||||||
std::vector<OperationDetails> & operation_details,
|
std::vector<OperationDetails> & operation_details,
|
||||||
Sector min_size )
|
Sector min_size )
|
||||||
{
|
{
|
||||||
operation_details .push_back( OperationDetails( _("resize partition") ) ) ;
|
if ( partition_new .get_length() < partition_old .get_length() )
|
||||||
|
operation_details .push_back( OperationDetails( _("shrink partition") ) ) ;
|
||||||
|
else if ( partition_new .get_length() > partition_old .get_length() )
|
||||||
|
operation_details .push_back( OperationDetails( _("grow partition") ) ) ;
|
||||||
|
else
|
||||||
|
operation_details .push_back(
|
||||||
|
OperationDetails( _("new and old partition have the same size. continuing anyway") ) ) ;
|
||||||
|
|
||||||
operation_details .back() .sub_details .push_back(
|
operation_details .back() .sub_details .push_back(
|
||||||
OperationDetails(
|
OperationDetails(
|
||||||
|
@ -1585,7 +1616,7 @@ void GParted_Core::set_flags( Partition & partition )
|
||||||
partition .flags .push_back( ped_partition_flag_get_name( flags[ t ] ) ) ;
|
partition .flags .push_back( ped_partition_flag_get_name( flags[ t ] ) ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem )
|
void GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem, Sector cylinder_size )
|
||||||
{
|
{
|
||||||
if ( p_filesystem )
|
if ( p_filesystem )
|
||||||
delete p_filesystem ;
|
delete p_filesystem ;
|
||||||
|
@ -1608,6 +1639,9 @@ void GParted_Core::set_proper_filesystem( const FILESYSTEM & filesystem )
|
||||||
|
|
||||||
default : p_filesystem = NULL ;
|
default : p_filesystem = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( p_filesystem )
|
||||||
|
p_filesystem ->cylinder_size = cylinder_size ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GParted_Core::set_partition_type( const Partition & partition,
|
bool GParted_Core::set_partition_type( const Partition & partition,
|
||||||
|
|
|
@ -91,18 +91,13 @@ bool ext2::Resize( const Partition & partition_new,
|
||||||
std::vector<OperationDetails> & operation_details,
|
std::vector<OperationDetails> & operation_details,
|
||||||
bool fill_partition )
|
bool fill_partition )
|
||||||
{
|
{
|
||||||
if ( fill_partition )
|
|
||||||
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
|
|
||||||
else
|
|
||||||
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
|
|
||||||
|
|
||||||
Glib::ustring str_temp = "resize2fs " + partition_new .get_path() ;
|
Glib::ustring str_temp = "resize2fs " + partition_new .get_path() ;
|
||||||
|
|
||||||
if ( ! fill_partition )
|
if ( ! fill_partition )
|
||||||
str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit(
|
str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit(
|
||||||
partition_new .get_length() - cylinder_size, GParted::UNIT_MIB ) ), true ) + "M" ;
|
partition_new .get_length() - cylinder_size, GParted::UNIT_MIB ) ), true ) + "M" ;
|
||||||
|
|
||||||
if ( ! execute_command( str_temp, operation_details .back() .sub_details ) )
|
if ( ! execute_command( str_temp, operation_details ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
return true ;
|
return true ;
|
||||||
|
|
|
@ -86,18 +86,13 @@ bool ext3::Resize( const Partition & partition_new,
|
||||||
std::vector<OperationDetails> & operation_details,
|
std::vector<OperationDetails> & operation_details,
|
||||||
bool fill_partition )
|
bool fill_partition )
|
||||||
{
|
{
|
||||||
if ( fill_partition )
|
|
||||||
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
|
|
||||||
else
|
|
||||||
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
|
|
||||||
|
|
||||||
Glib::ustring str_temp = "resize2fs " + partition_new .get_path() ;
|
Glib::ustring str_temp = "resize2fs " + partition_new .get_path() ;
|
||||||
|
|
||||||
if ( ! fill_partition )
|
if ( ! fill_partition )
|
||||||
str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit(
|
str_temp += " " + Utils::num_to_str( Utils::round( Utils::sector_to_unit(
|
||||||
partition_new .get_length() - cylinder_size, GParted::UNIT_MIB ) ), true ) + "M" ;
|
partition_new .get_length() - cylinder_size, GParted::UNIT_MIB ) ), true ) + "M" ;
|
||||||
|
|
||||||
if ( ! execute_command( str_temp, operation_details .back() .sub_details ) )
|
if ( ! execute_command( str_temp, operation_details ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
return true ;
|
return true ;
|
||||||
|
|
49
src/jfs.cc
49
src/jfs.cc
|
@ -107,78 +107,74 @@ bool jfs::Resize( const Partition & partition_new,
|
||||||
std::vector<OperationDetails> & operation_details,
|
std::vector<OperationDetails> & operation_details,
|
||||||
bool fill_partition )
|
bool fill_partition )
|
||||||
{
|
{
|
||||||
if ( fill_partition )
|
|
||||||
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
|
|
||||||
else
|
|
||||||
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
|
|
||||||
|
|
||||||
bool return_value = false ;
|
bool return_value = false ;
|
||||||
Glib::ustring error ;
|
Glib::ustring error ;
|
||||||
Glib::ustring TEMP_MP = Glib::get_tmp_dir() + "/gparted_tmp_jfs_mountpoint" ;
|
Glib::ustring TEMP_MP = Glib::get_tmp_dir() + "/gparted_tmp_jfs_mountpoint" ;
|
||||||
|
|
||||||
//create mountpoint...
|
//create mountpoint...
|
||||||
operation_details .back() .sub_details .push_back(
|
operation_details .push_back(
|
||||||
OperationDetails( String::ucompose( _("create temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
|
OperationDetails( String::ucompose( _("create temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
|
||||||
if ( ! mkdir( TEMP_MP .c_str(), 0 ) )
|
if ( ! mkdir( TEMP_MP .c_str(), 0 ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
|
|
||||||
//mount partition
|
//mount partition
|
||||||
operation_details .back() .sub_details .push_back(
|
operation_details .push_back(
|
||||||
OperationDetails( String::ucompose( _("mount %1 on %2"), partition_new .get_path(), TEMP_MP ) ) ) ;
|
OperationDetails( String::ucompose( _("mount %1 on %2"), partition_new .get_path(), TEMP_MP ) ) ) ;
|
||||||
|
|
||||||
if ( ! execute_command( "mount -v -t jfs " + partition_new .get_path() + " " + TEMP_MP,
|
if ( ! execute_command( "mount -v -t jfs " + partition_new .get_path() + " " + TEMP_MP,
|
||||||
operation_details .back() .sub_details .back() .sub_details ) )
|
operation_details .back() .sub_details ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
|
|
||||||
//remount the partition to resize the filesystem
|
//remount the partition to resize the filesystem
|
||||||
operation_details .back() .sub_details .push_back(
|
operation_details .push_back(
|
||||||
OperationDetails( String::ucompose( _("remount %1 on %2 with the 'resize' flag enabled"),
|
OperationDetails( String::ucompose( _("remount %1 on %2 with the 'resize' flag enabled"),
|
||||||
partition_new .get_path(), TEMP_MP ) ) ) ;
|
partition_new .get_path(), TEMP_MP ) ) ) ;
|
||||||
|
|
||||||
if ( ! execute_command( "mount -v -t jfs -o remount,resize " + partition_new .get_path() + " " + TEMP_MP,
|
if ( ! execute_command(
|
||||||
operation_details .back() .sub_details .back() .sub_details ) )
|
"mount -v -t jfs -o remount,resize " + partition_new .get_path() + " " + TEMP_MP,
|
||||||
|
operation_details .back() .sub_details ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
return_value = true ;
|
return_value = true ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//and unmount it...
|
//and unmount it...
|
||||||
operation_details .back() .sub_details .push_back(
|
operation_details .push_back(
|
||||||
OperationDetails( String::ucompose( _("unmount %1"), partition_new .get_path() ) ) ) ;
|
OperationDetails( String::ucompose( _("unmount %1"), partition_new .get_path() ) ) ) ;
|
||||||
|
|
||||||
if ( ! execute_command( "umount -v " + partition_new .get_path(),
|
if ( ! execute_command( "umount -v " + partition_new .get_path(),
|
||||||
operation_details .back() .sub_details .back() .sub_details ) )
|
operation_details .back() .sub_details ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
return_value = false ;
|
return_value = false ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove the mountpoint..
|
//remove the mountpoint..
|
||||||
operation_details .back() .sub_details .push_back(
|
operation_details .push_back(
|
||||||
OperationDetails( String::ucompose( _("remove temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
|
OperationDetails( String::ucompose( _("remove temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
|
||||||
if ( ! rmdir( TEMP_MP .c_str() ) )
|
if ( ! rmdir( TEMP_MP .c_str() ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
operation_details .back() .sub_details .back() .sub_details .push_back(
|
operation_details .back() .sub_details .push_back(
|
||||||
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
|
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
|
||||||
|
|
||||||
return_value = false ;
|
return_value = false ;
|
||||||
|
@ -186,12 +182,11 @@ bool jfs::Resize( const Partition & partition_new,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
operation_details .back() .sub_details .back() .sub_details .push_back(
|
operation_details .back() .sub_details .push_back(
|
||||||
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
|
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
|
|
||||||
return return_value ;
|
return return_value ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
src/ntfs.cc
25
src/ntfs.cc
|
@ -85,11 +85,6 @@ bool ntfs::Resize( const Partition & partition_new,
|
||||||
std::vector<OperationDetails> & operation_details,
|
std::vector<OperationDetails> & operation_details,
|
||||||
bool fill_partition )
|
bool fill_partition )
|
||||||
{
|
{
|
||||||
if ( fill_partition )
|
|
||||||
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
|
|
||||||
else
|
|
||||||
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
|
|
||||||
|
|
||||||
bool return_value = false ;
|
bool return_value = false ;
|
||||||
Glib::ustring str_temp = "ntfsresize -P --force --force " + partition_new .get_path() ;
|
Glib::ustring str_temp = "ntfsresize -P --force --force " + partition_new .get_path() ;
|
||||||
|
|
||||||
|
@ -101,32 +96,30 @@ bool ntfs::Resize( const Partition & partition_new,
|
||||||
}
|
}
|
||||||
|
|
||||||
//simulation..
|
//simulation..
|
||||||
operation_details .back() .sub_details .push_back( OperationDetails( _("run simulation") ) ) ;
|
operation_details .push_back( OperationDetails( _("run simulation") ) ) ;
|
||||||
|
|
||||||
if ( ! execute_command( str_temp + " --no-action", operation_details .back() .sub_details .back() .sub_details ) )
|
if ( ! execute_command( str_temp + " --no-action", operation_details .back() .sub_details ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
|
|
||||||
//real resize (use description from 'main' operation)
|
//real resize
|
||||||
operation_details .back() .sub_details .push_back(
|
operation_details .push_back( OperationDetails( _("real resize") ) ) ;
|
||||||
OperationDetails( operation_details .back() .description ) ) ;
|
|
||||||
|
|
||||||
if ( ! execute_command( str_temp, operation_details .back() .sub_details .back() .sub_details ) )
|
if ( ! execute_command( str_temp, operation_details .back() .sub_details ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
return_value = true ;
|
return_value = true ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
}
|
}
|
||||||
|
|
||||||
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
|
|
||||||
return return_value ;
|
return return_value ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,11 +89,6 @@ bool reiserfs::Resize( const Partition & partition_new,
|
||||||
std::vector<OperationDetails> & operation_details,
|
std::vector<OperationDetails> & operation_details,
|
||||||
bool fill_partition )
|
bool fill_partition )
|
||||||
{
|
{
|
||||||
if ( fill_partition )
|
|
||||||
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
|
|
||||||
else
|
|
||||||
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
|
|
||||||
|
|
||||||
Glib::ustring str_temp = "echo y | resize_reiserfs " + partition_new .get_path() ;
|
Glib::ustring str_temp = "echo y | resize_reiserfs " + partition_new .get_path() ;
|
||||||
|
|
||||||
if ( ! fill_partition )
|
if ( ! fill_partition )
|
||||||
|
@ -103,7 +98,7 @@ bool reiserfs::Resize( const Partition & partition_new,
|
||||||
partition_new .get_length() - cylinder_size, GParted::UNIT_BYTE ) ), true ) ;
|
partition_new .get_length() - cylinder_size, GParted::UNIT_BYTE ) ), true ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit_status = execute_command( str_temp, operation_details .back() .sub_details ) ;
|
exit_status = execute_command( str_temp, operation_details ) ;
|
||||||
if ( exit_status == 0 || exit_status == 256 )
|
if ( exit_status == 0 || exit_status == 256 )
|
||||||
{
|
{
|
||||||
operation_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
|
|
46
src/xfs.cc
46
src/xfs.cc
|
@ -109,76 +109,71 @@ bool xfs::Resize( const Partition & partition_new,
|
||||||
std::vector<OperationDetails> & operation_details,
|
std::vector<OperationDetails> & operation_details,
|
||||||
bool fill_partition )
|
bool fill_partition )
|
||||||
{
|
{
|
||||||
if ( fill_partition )
|
|
||||||
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
|
|
||||||
else
|
|
||||||
operation_details .push_back( OperationDetails( _("resize the filesystem") ) ) ;
|
|
||||||
|
|
||||||
bool return_value = false ;
|
bool return_value = false ;
|
||||||
Glib::ustring error ;
|
Glib::ustring error ;
|
||||||
Glib::ustring TEMP_MP = Glib::get_tmp_dir() + "/gparted_tmp_xfs_mountpoint" ;
|
Glib::ustring TEMP_MP = Glib::get_tmp_dir() + "/gparted_tmp_xfs_mountpoint" ;
|
||||||
|
|
||||||
//create mountpoint...
|
//create mountpoint...
|
||||||
operation_details .back() .sub_details .push_back(
|
operation_details .push_back(
|
||||||
OperationDetails( String::ucompose( _("create temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
|
OperationDetails( String::ucompose( _("create temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
|
||||||
if ( ! mkdir( TEMP_MP .c_str(), 0 ) )
|
if ( ! mkdir( TEMP_MP .c_str(), 0 ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
|
|
||||||
//mount partition
|
//mount partition
|
||||||
operation_details .back() .sub_details .push_back(
|
operation_details .push_back(
|
||||||
OperationDetails( String::ucompose( _("mount %1 on %2"), partition_new .get_path(), TEMP_MP ) ) ) ;
|
OperationDetails( String::ucompose( _("mount %1 on %2"), partition_new .get_path(), TEMP_MP ) ) ) ;
|
||||||
|
|
||||||
if ( ! execute_command( "mount -v -t xfs " + partition_new .get_path() + " " + TEMP_MP,
|
if ( ! execute_command( "mount -v -t xfs " + partition_new .get_path() + " " + TEMP_MP,
|
||||||
operation_details .back() .sub_details .back() .sub_details ) )
|
operation_details .back() .sub_details ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
|
|
||||||
//grow the mounted filesystem..
|
//grow the mounted filesystem..
|
||||||
operation_details .back() .sub_details .push_back( OperationDetails( _("grow mounted filesystem") ) ) ;
|
operation_details .push_back( OperationDetails( _("grow mounted filesystem") ) ) ;
|
||||||
|
|
||||||
if ( ! execute_command ( "xfs_growfs " + TEMP_MP,
|
if ( ! execute_command ( "xfs_growfs " + TEMP_MP,
|
||||||
operation_details .back() .sub_details .back() .sub_details ) )
|
operation_details .back() .sub_details ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
return_value = true ;
|
return_value = true ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//and unmount it...
|
//and unmount it...
|
||||||
operation_details .back() .sub_details .push_back(
|
operation_details .push_back(
|
||||||
OperationDetails( String::ucompose( _("unmount %1"), partition_new .get_path() ) ) ) ;
|
OperationDetails( String::ucompose( _("unmount %1"), partition_new .get_path() ) ) ) ;
|
||||||
|
|
||||||
if ( ! execute_command( "umount -v " + partition_new .get_path(),
|
if ( ! execute_command( "umount -v " + partition_new .get_path(),
|
||||||
operation_details .back() .sub_details .back() .sub_details ) )
|
operation_details .back() .sub_details ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
return_value = false ;
|
return_value = false ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove the mountpoint..
|
//remove the mountpoint..
|
||||||
operation_details .back() .sub_details .push_back(
|
operation_details .push_back(
|
||||||
OperationDetails( String::ucompose( _("remove temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
|
OperationDetails( String::ucompose( _("remove temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
|
||||||
if ( ! rmdir( TEMP_MP .c_str() ) )
|
if ( ! rmdir( TEMP_MP .c_str() ) )
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
|
operation_details .back() .status = OperationDetails::SUCCES ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
operation_details .back() .sub_details .back() .sub_details .push_back(
|
operation_details .back() .sub_details .push_back(
|
||||||
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
|
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
|
||||||
|
|
||||||
return_value = false ;
|
return_value = false ;
|
||||||
|
@ -186,12 +181,11 @@ bool xfs::Resize( const Partition & partition_new,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
|
operation_details .back() .status = OperationDetails::ERROR ;
|
||||||
operation_details .back() .sub_details .back() .sub_details .push_back(
|
operation_details .back() .sub_details .push_back(
|
||||||
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
|
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
|
|
||||||
return return_value ;
|
return return_value ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue