From 169f1e34f9bbdc24631a8131bbeb378acc7fc91f Mon Sep 17 00:00:00 2001 From: Bart Hakvoort Date: Wed, 29 Dec 2004 19:22:58 +0000 Subject: [PATCH] implemented read used/unused space on a jfs filesystem. * src/jfs.cc: implemented read used/unused space on a jfs filesystem. --- ChangeLog | 4 ++++ src/jfs.cc | 30 ++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c0cc4602..7ed09abb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-12-29 Bart Hakvoort + + * src/jfs.cc: implemented read used/unused space on a jfs filesystem. + 2004-12-29 Bart Hakvoort * include/GParted_Core.h, diff --git a/src/jfs.cc b/src/jfs.cc index 3c554a6d..9490f226 100644 --- a/src/jfs.cc +++ b/src/jfs.cc @@ -27,8 +27,8 @@ FS jfs::get_filesystem_support( ) fs .filesystem = "jfs" ; -// if ( ! system( "which xfs_db 1>/dev/null 2>/dev/null" ) ) -// fs .read = true ; + if ( ! system( "which jfs_debugfs 1>/dev/null 2>/dev/null" ) ) + fs .read = true ; if ( ! system( "which mkfs.jfs 1>/dev/null 2>/dev/null" ) ) fs .create = true ; @@ -61,6 +61,32 @@ FS jfs::get_filesystem_support( ) void jfs::Set_Used_Sectors( Partition & partition ) { + char c_buf[ 512 ] ; + FILE *f ; + + Glib::ustring output ; + + //get free sectors.. + f = popen( ( "LC_ALL=C echo dm | jfs_debugfs " + partition .partition ) .c_str( ), "r" ) ; + while ( fgets( c_buf, 512, f ) ) + { + output = Glib::locale_to_utf8( c_buf ) ; + + //free sectors + if ( output .find( "dn_nfree" ) < output .length( ) ) + { + output = output .substr( output .find( ":" ) +1, output .length( ) ) ; + + int dec_free_blocks ; + std::istringstream hex_free_blocks( output .substr( 0, output .find( "[" ) ) ); + hex_free_blocks >> std::hex >> dec_free_blocks ; + + partition .Set_Unused( dec_free_blocks * 8 ) ;//4096 / 512 (i've been told jfs blocksize is _always_ 4K) + + break ; + } + } + pclose( f ) ; } bool jfs::Create( const Partition & new_partition )