diff --git a/AUTHORS b/AUTHORS index 019302ef..4d539cd3 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,6 +12,7 @@ not an invitation to misrepresent who contributed to GNU GParted. We need to keep track of copyright (see the Maintainer HOWTO on www.gnu.org). Curtis Gedak + * Rewrote get_label functionality for hfs * Wrote create, get_label, and check_repair functionality for hfs+ * Wrote get_label functionality for fat16 and fat32 filesystems * Wrote Utils::regexp_label() function diff --git a/ChangeLog b/ChangeLog index 41340753..caa1402b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2008-07-25 Curtis Gedak + * src/hfs.cc: Rewrote get_label to use vol_id for hfs file system + - Reason: not all hfsutils packages include hfsck (e.g. Ubuntu 7.10) + * src/hfsplus.cc: Enhanced support for hfsplus file system - Added create, get_label, and check_repair functionality - Additional feature support is provided by the hfsprogs package diff --git a/README b/README index 02b881c7..c35504b1 100644 --- a/README +++ b/README @@ -98,10 +98,11 @@ Optional packages include: dosfstools mtools hfsutils + hfsprogs jfsutils ntfsprogs reiser4progs reiserfsprogs xfsprogs NOTE: If the vol_id command is in the search PATH, it will be - used to read linux-swap volume labels. + used to read linux-swap, hfs, and hfs+ file system volume labels. diff --git a/src/hfs.cc b/src/hfs.cc index 10323dbb..e80b4bd3 100644 --- a/src/hfs.cc +++ b/src/hfs.cc @@ -32,12 +32,12 @@ FS hfs::get_filesystem_support() if ( ! Glib::find_program_in_path( "hformat" ) .empty() ) fs .create = GParted::FS::EXTERNAL ; - + if ( ! Glib::find_program_in_path( "hfsck" ) .empty() ) - { - fs .get_label = FS::EXTERNAL ; fs .check = FS::EXTERNAL ; - } + + if ( ! Glib::find_program_in_path( "vol_id" ) .empty() ) + fs .get_label = FS::EXTERNAL ; fs .copy = GParted::FS::GPARTED ; fs .move = GParted::FS::GPARTED ; @@ -53,22 +53,12 @@ void hfs::set_used_sectors( Partition & partition ) void hfs::get_label( Partition & partition ) { - if ( ! Utils::execute_command( "hfsck -v " + partition .get_path(), output, error, true ) ) + if ( ! Utils::execute_command( "vol_id " + partition .get_path(), output, error, true ) ) { - char buf[512] ; - index = output .find( "drVN" ) ; - - if ( index < output .length() && sscanf( output .substr( index ) .c_str(), "drVN = %512s", buf ) == 1 ) - { - partition .label = buf ; - - //remove "" from the label.. - if ( partition .label .size() > 0 && partition .label[0] == '\"' ) - partition .label = partition .label .substr( 1 ) ; - - if ( partition .label .size() > 0 && partition .label[ partition .label .size() -1 ] == '\"' ) - partition .label = partition .label .substr( 0, partition .label .size() -1 ) ; - } + Glib::ustring label = Utils::regexp_label( output, "ID_FS_LABEL=([^\n]*)" ) ; + //FIXME: find a better way to see if label is empty.. imagine someone uses 'untitled' as label.... ;) + if( label != "untitled" ) + partition .label = label ; } else { @@ -114,5 +104,3 @@ bool hfs::check_repair( const Partition & partition, OperationDetail & operation } } //GParted - -