small fix with sequence of mount,remount,unmount resizing now contains

2006-01-20 Bart Hakvoort <hakvoort@cvs.gnome.org>

* src/jfs.cc: small fix with sequence of mount,remount,unmount
* src/xfs.cc: resizing now contains detailed feedback
* src/FileSystem.cc: show exceptiondescription in operationdetails
This commit is contained in:
Bart Hakvoort 2006-01-19 23:30:17 +00:00 committed by Bart Hakvoort
parent 4ad5ef49a4
commit 050ddc6a9d
4 changed files with 103 additions and 25 deletions

View File

@ -1,3 +1,9 @@
2006-01-20 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/jfs.cc: small fix with sequence of mount,remount,unmount
* src/xfs.cc: resizing now contains detailed feedback
* src/FileSystem.cc: show exceptiondescription in operationdetails
2006-01-19 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/jfs.cc: resizing now contains detailed feedback

View File

@ -72,7 +72,9 @@ int FileSystem::execute_command( std::vector<std::string> argv, std::vector<Oper
}
catch ( Glib::Exception & e )
{
std::cout << e .what() << std::endl ;
if ( ! e .what() .empty() )
operation_details .back() .sub_details .push_back( OperationDetails( e .what(), OperationDetails::NONE ) ) ;
return -1 ;
}

View File

@ -148,21 +148,7 @@ bool jfs::Resize( const Partition & partition_new,
if ( Utils::mount( partition_new .partition, TEMP_MP, "jfs", error, MS_REMOUNT, "resize" ) )
{
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
//and unmount it...
operation_details .back() .sub_details .push_back(
OperationDetails( String::ucompose( _("umount %1"), partition_new .partition ) ) ) ;
if ( Utils::unmount( partition_new .partition, TEMP_MP, error ) )
{
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
return_value = true ;
}
else
{
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
operation_details .back() .sub_details .back() .sub_details .push_back(
OperationDetails( error, OperationDetails::NONE ) ) ;
}
return_value = true ;
}
else
{
@ -170,6 +156,22 @@ bool jfs::Resize( const Partition & partition_new,
operation_details .back() .sub_details .back() .sub_details .push_back(
OperationDetails( error, OperationDetails::NONE ) ) ;
}
//and unmount it...
operation_details .back() .sub_details .push_back(
OperationDetails( String::ucompose( _("umount %1"), partition_new .partition ) ) ) ;
if ( Utils::unmount( partition_new .partition, TEMP_MP, error ) )
{
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
}
else
{
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
operation_details .back() .sub_details .back() .sub_details .push_back(
OperationDetails( error, OperationDetails::NONE ) ) ;
return_value = false ;
}
}
else
{
@ -177,7 +179,7 @@ bool jfs::Resize( const Partition & partition_new,
operation_details .back() .sub_details .back() .sub_details .push_back(
OperationDetails( error, OperationDetails::NONE ) ) ;
}
//remove the mountpoint..
operation_details .back() .sub_details .push_back(
OperationDetails( String::ucompose( _("remove temporary mountpoint (%1)"), TEMP_MP ) ) ) ;

View File

@ -18,6 +18,8 @@
#include "../include/xfs.h"
#include <cerrno>
namespace GParted
{
@ -118,7 +120,7 @@ bool xfs::Create( const Partition & new_partition, std::vector<OperationDetails>
bool xfs::Resize( const Partition & partition_new,
std::vector<OperationDetails> & operation_details,
bool fill_partition )
{//FIXME
{
if ( fill_partition )
operation_details .push_back( OperationDetails( _("grow filesystem to fill the partition") ) ) ;
else
@ -127,15 +129,81 @@ bool xfs::Resize( const Partition & partition_new,
bool return_value = false ;
Glib::ustring error ;
Glib::ustring TEMP_MP = "/tmp/gparted_tmp_xfs_mountpoint" ;
//xfs kan only grow if the partition is mounted..
mkdir( TEMP_MP .c_str(), 0 ) ;
if ( Utils::mount( partition_new .partition, TEMP_MP, "xfs", error ) )
//create mountpoint...
operation_details .back() .sub_details .push_back(
OperationDetails( String::ucompose( _("create temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
if ( ! mkdir( TEMP_MP .c_str(), 0 ) )
{
return_value = ! Execute_Command( "xfs_growfs " + TEMP_MP ) ;
Utils::unmount( partition_new .partition, TEMP_MP, error ) ;
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
//mount partition
operation_details .back() .sub_details .push_back(
OperationDetails( String::ucompose( _("mount %1 on %2"), partition_new .partition, TEMP_MP ) ) ) ;
if ( Utils::mount( partition_new .partition, TEMP_MP, "xfs", error ) )
{
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
//grow the mounted filesystem..
operation_details .back() .sub_details .push_back( OperationDetails( _("grow mounted filesystem") ) ) ;
argv .clear() ;
argv .push_back( "xfs_growfs" ) ;
argv .push_back( TEMP_MP ) ;
if ( ! execute_command( argv, operation_details .back() .sub_details .back() .sub_details ) )
{
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
return_value = true ;
}
else
{
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
}
//and unmount it...
operation_details .back() .sub_details .push_back(
OperationDetails( String::ucompose( _("umount %1"), partition_new .partition ) ) ) ;
if ( Utils::unmount( partition_new .partition, TEMP_MP, error ) )
{
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
}
else
{
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
operation_details .back() .sub_details .back() .sub_details .push_back(
OperationDetails( error, OperationDetails::NONE ) ) ;
return_value = false ;
}
}
else
{
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
operation_details .back() .sub_details .back() .sub_details .push_back(
OperationDetails( error, OperationDetails::NONE ) ) ;
}
//remove the mountpoint..
operation_details .back() .sub_details .push_back(
OperationDetails( String::ucompose( _("remove temporary mountpoint (%1)"), TEMP_MP ) ) ) ;
if ( ! rmdir( TEMP_MP .c_str() ) )
{
operation_details .back() .sub_details .back() .status = OperationDetails::SUCCES ;
}
else
{
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
operation_details .back() .sub_details .back() .sub_details .push_back(
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
return_value = false ;
}
}
else
{
operation_details .back() .sub_details .back() .status = OperationDetails::ERROR ;
operation_details .back() .sub_details .back() .sub_details .push_back(
OperationDetails( Glib::strerror( errno ), OperationDetails::NONE ) ) ;
}
rmdir( TEMP_MP .c_str() ) ;
operation_details .back() .status = return_value ? OperationDetails::SUCCES : OperationDetails::ERROR ;
return return_value ;