Rewrote get_label to use vol_id command for hfs file system

svn path=/trunk/; revision=872
This commit is contained in:
Curtis Gedak 2008-07-25 23:05:20 +00:00
parent b12fbfb1b2
commit 0a95638dc8
4 changed files with 15 additions and 22 deletions

View File

@ -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 <gedakc@users.sourceforge.net>
* 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

View File

@ -1,5 +1,8 @@
2008-07-25 Curtis Gedak <gedakc@gmail.com>
* 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

3
README
View File

@ -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.

View File

@ -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