Recognise new dosfstools program names (#704629)

Dosfstools >= 3.0.18, released June 2013, renamed the programs thus:

    dosfslabel becomes fatlabel,
    dosfsck becomes fsck.fat,
    and mkdosfs becomes mkfs.fat.

Dosfstools creates symbolic links for the old names for backward
compatibility, but unfortunately the Debian dosfstools-3.0.22-1
(experimental) package doesn't include those symbolic links.  This
causes create, check and read unmounted FAT16/32 file systems to not be
supported.

Make GParted look for the new names first and the old names second.

Closes Bug #704629 - Program name changes in dosfstools 3.0.18+ break
                     FAT16/32 support
This commit is contained in:
Mike Fleetwood 2013-07-25 23:18:57 +01:00 committed by Curtis Gedak
parent 3fb1fa22a1
commit 1ae03dee95
2 changed files with 22 additions and 6 deletions

View file

@ -28,8 +28,10 @@ namespace GParted
class fat16 : public FileSystem
{
const enum FILESYSTEM specific_type ;
Glib::ustring create_cmd ;
Glib::ustring check_cmd ;
public:
fat16( enum FILESYSTEM type ) : specific_type( type ) {} ;
fat16( enum FILESYSTEM type ) : specific_type( type ), create_cmd( "" ), check_cmd( "" ) {} ;
const Glib::ustring get_custom_text( CUSTOM_TEXT ttype, int index = 0 ) ;
FS get_filesystem_support() ;
void set_used_sectors( Partition & partition ) ;

View file

@ -67,16 +67,30 @@ FS fat16::get_filesystem_support()
setenv( "MTOOLS_SKIP_CHECK", "1", 0 );
//find out if we can create fat file systems
if ( ! Glib::find_program_in_path( "mkdosfs" ) .empty() )
if ( ! Glib::find_program_in_path( "mkfs.fat" ) .empty() )
{
fs .create = GParted::FS::EXTERNAL ;
fs .create_with_label = GParted::FS::EXTERNAL ;
create_cmd = "mkfs.fat" ;
}
else if ( ! Glib::find_program_in_path( "mkdosfs" ) .empty() )
{
fs .create = GParted::FS::EXTERNAL ;
fs .create_with_label = GParted::FS::EXTERNAL ;
create_cmd = "mkdosfs" ;
}
if ( ! Glib::find_program_in_path( "dosfsck" ) .empty() )
if ( ! Glib::find_program_in_path( "fsck.fat" ) .empty() )
{
fs .check = GParted::FS::EXTERNAL ;
fs .read = GParted::FS::EXTERNAL ;
check_cmd = "fsck.fat" ;
}
else if ( ! Glib::find_program_in_path( "dosfsck" ) .empty() )
{
fs .check = GParted::FS::EXTERNAL ;
fs .read = GParted::FS::EXTERNAL ;
check_cmd = "dosfsck" ;
}
if ( ! Glib::find_program_in_path( "mdir" ) .empty() )
@ -117,7 +131,7 @@ FS fat16::get_filesystem_support()
void fat16::set_used_sectors( Partition & partition )
{
exit_status = Utils::execute_command( "dosfsck -n -v " + partition .get_path(), output, error, true ) ;
exit_status = Utils::execute_command( check_cmd + " -n -v " + partition .get_path(), output, error, true ) ;
if ( exit_status == 0 || exit_status == 1 || exit_status == 256 )
{
//total file system size in logical sectors
@ -238,7 +252,7 @@ bool fat16::write_uuid( const Partition & partition, OperationDetail & operation
bool fat16::create( const Partition & new_partition, OperationDetail & operationdetail )
{
Glib::ustring fat_size = specific_type == FS_FAT16 ? "16" : "32" ;
return ! execute_command( "mkdosfs -F" + fat_size + " -v -I -n \"" + pad_label( new_partition .get_label() ) +
return ! execute_command( create_cmd + " -F" + fat_size + " -v -I -n \"" + pad_label( new_partition .get_label() ) +
"\" " + new_partition .get_path(),
operationdetail,
false,
@ -247,7 +261,7 @@ bool fat16::create( const Partition & new_partition, OperationDetail & operation
bool fat16::check_repair( const Partition & partition, OperationDetail & operationdetail )
{
exit_status = execute_command( "dosfsck -a -w -v " + partition .get_path(), operationdetail,
exit_status = execute_command( check_cmd + " -a -w -v " + partition .get_path(), operationdetail,
false, true );
return ( exit_status == 0 || exit_status == 1 || exit_status == 256 ) ;