From d127dfa9838f8ce9f903ea0f5162ec1ec4d40f3b Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Sat, 16 Oct 2004 20:27:28 +0000 Subject: [PATCH] when the libary of an optional filesystem (atm only reiserfs) wasn't * src/Device.cc: when the libary of an optional filesystem (atm only reiserfs) wasn't installed, every scan printed an error in the console (df couldn't find the partition listed). Fixed by checking if partition is busy before using df. --- ChangeLog | 5 +++++ src/Device.cc | 25 ++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9cecbaed..c895b398 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-10-16 Bart Hakvoort + + * src/Device.cc: when the libary of an optional filesystem (atm only reiserfs) wasn't installed, every scan printed an error + in the console (df couldn't find the partition listed). Fixed by checking if partition is busy before using df. + 2004-10-16 Bart Hakvoort * src/Dialog_Progress.cc: changed dialogwidth from 500 to 600 pixels. (icw certain languages the operation didn't fit) diff --git a/src/Device.cc b/src/Device.cc index 62846094..6393c284 100644 --- a/src/Device.cc +++ b/src/Device.cc @@ -539,19 +539,22 @@ Sector Device::Get_Used_Sectors( PedPartition *c_partition, const Glib::ustring //METHOD #2 //this ony works for mounted ( and therefore known to the OS ) filesystems. My method is quite crude, keep in mind it's only temporary ;-) - Glib::ustring buf; - system( ("df -k --sync " + sym_path + " | grep " + sym_path + " > /tmp/.tmp_gparted").c_str() ); - std::ifstream file_input( "/tmp/.tmp_gparted" ); - - file_input >> buf; //skip first value - file_input >> buf; - if ( buf != "0" && ! buf.empty() ) - { + if ( ped_partition_is_busy( c_partition ) ) + { + Glib::ustring buf; + system( ("df -k --sync " + sym_path + " | grep " + sym_path + " > /tmp/.tmp_gparted").c_str() ); + std::ifstream file_input( "/tmp/.tmp_gparted" ); + + file_input >> buf; //skip first value file_input >> buf; - file_input.close(); system( "rm -f /tmp/.tmp_gparted" ); - return atoi( buf.c_str() ) * 1024/512 ; + if ( buf != "0" && ! buf.empty() ) + { + file_input >> buf; + file_input.close(); system( "rm -f /tmp/.tmp_gparted" ); + return atoi( buf.c_str() ) * 1024/512 ; + } + file_input.close(); system( "rm -f /tmp/.tmp_gparted" ); } - file_input.close(); system( "rm -f /tmp/.tmp_gparted" ); return -1 ; //all methods were unsuccesfull