[gparted/psusi/refactor: 5/7] Remove mtoolsrc file
- From: Phillip Susi <psusi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted/psusi/refactor: 5/7] Remove mtoolsrc file
- Date: Sun, 20 Jan 2013 18:33:18 +0000 (UTC)
commit 7b0a2381dc62ea4b46950d6209cd39575bf0744c
Author: Phillip Susi <psusi ubuntu com>
Date: Thu Jan 17 21:13:25 2013 -0500
Remove mtoolsrc file
fat16 and fat32 were creating a temp mtoolsrc file to configure the
command to reference a drive letter and ignore certain errors. They have
been changed to pass this information via the command line and environment
instead.
src/fat16.cc | 57 ++++++++-------------------------------------------------
src/fat32.cc | 56 ++++++++------------------------------------------------
2 files changed, 16 insertions(+), 97 deletions(-)
---
diff --git a/src/fat16.cc b/src/fat16.cc
index 6b85b56..9e74de3 100644
--- a/src/fat16.cc
+++ b/src/fat16.cc
@@ -63,6 +63,9 @@ FS fat16::get_filesystem_support()
FS fs ;
fs .filesystem = GParted::FS_FAT16 ;
+ // hack to disable silly mtools warnings
+ setenv( "MTOOLS_SKIP_CHECK", "1", 0 );
+
//find out if we can create fat16 file systems
if ( ! Glib::find_program_in_path( "mkdosfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
@@ -150,17 +153,7 @@ void fat16::set_used_sectors( Partition & partition )
void fat16::read_label( Partition & partition )
{
- //Create mtools config file
- char fname[] = "/tmp/gparted-XXXXXXXX" ;
- char dletter = 'H' ;
- Glib::ustring err_msg = "" ;
- err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
- if( err_msg.length() != 0 )
- partition .messages .push_back( err_msg );
-
- Glib::ustring cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -s %2:", fname, dletter ) ;
-
- if ( ! Utils::execute_command( cmd, output, error, true ) )
+ if ( ! Utils::execute_command( "mlabel -s :: -i " + partition.get_path(), output, error, true ) )
{
partition .set_label( Utils::trim( Utils::regexp_label( output, "Volume label is ([^(]*)" ) ) ) ;
}
@@ -172,25 +165,15 @@ void fat16::read_label( Partition & partition )
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
-
- //Delete mtools config file
- err_msg = Utils::delete_mtoolsrc_file( fname );
}
bool fat16::write_label( const Partition & partition, OperationDetail & operationdetail )
{
- //Create mtools config file
- char fname[] = "/tmp/gparted-XXXXXXXX" ;
- char dletter = 'H' ;
- Glib::ustring err_msg = "" ;
- err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
-
Glib::ustring cmd = "" ;
if ( partition .get_label() .empty() )
- cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ;
+ cmd = "mlabel -c :: -i " + partition.get_path();
else
- cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"",
- fname, dletter, partition .get_label() ) ;
+ cmd = "mlabel ::\"" + partition.get_label() + "\" -i " + partition.get_path();
operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
@@ -202,23 +185,12 @@ bool fat16::write_label( const Partition & partition, OperationDetail & operatio
if ( ! error .empty() )
operationdetail .get_last_child() .add_child( OperationDetail( error, STATUS_NONE, FONT_ITALIC ) ) ;
- //Delete mtools config file
- err_msg = Utils::delete_mtoolsrc_file( fname );
-
return ( exit_status == 0 );
}
void fat16::read_uuid( Partition & partition )
{
- //Create mtools config file
- char fname[] = "/tmp/gparted-XXXXXXXX" ;
- char dletter = 'H' ;
- Glib::ustring err_msg = "" ;
- err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
- if( err_msg.length() != 0 )
- partition .messages .push_back( err_msg );
-
- Glib::ustring cmd = String::ucompose( "export MTOOLSRC=%1 && mdir -f %2:", fname, dletter ) ;
+ Glib::ustring cmd = "mdir -f :: -i " + partition.get_path();
if ( ! Utils::execute_command( cmd, output, error, true ) )
{
@@ -234,21 +206,11 @@ void fat16::read_uuid( Partition & partition )
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
-
- err_msg = Utils::delete_mtoolsrc_file( fname );
}
bool fat16::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
- //Create mtools config file
- char fname[] = "/tmp/gparted-XXXXXXXX" ;
- char dletter = 'H' ;
- Glib::ustring err_msg = "" ;
- err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
-
- // Wait some time - 'random' UUIDs turn out identical if generated in quick succession...
- sleep(1);
- Glib::ustring cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -s -n %2:", fname, dletter ) ;
+ Glib::ustring cmd = "mlabel -s -n :: -i " + partition.get_path();
operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
@@ -260,9 +222,6 @@ bool fat16::write_uuid( const Partition & partition, OperationDetail & operation
if ( ! error .empty() )
operationdetail .get_last_child() .add_child( OperationDetail( error, STATUS_NONE, FONT_ITALIC ) ) ;
- //Delete mtools config file
- err_msg = Utils::delete_mtoolsrc_file( fname );
-
return ( exit_status == 0 );
}
diff --git a/src/fat32.cc b/src/fat32.cc
index 3f4c0e5..1a1d4f4 100644
--- a/src/fat32.cc
+++ b/src/fat32.cc
@@ -50,7 +50,9 @@ FS fat32::get_filesystem_support()
{
FS fs ;
fs .filesystem = GParted::FS_FAT32 ;
-
+
+ // hack to disable silly mtools warnings
+ setenv( "MTOOLS_SKIP_CHECK", "1", 0 );
//find out if we can create fat32 file systems
if ( ! Glib::find_program_in_path( "mkdosfs" ) .empty() )
fs .create = GParted::FS::EXTERNAL ;
@@ -138,15 +140,7 @@ void fat32::set_used_sectors( Partition & partition )
void fat32::read_label( Partition & partition )
{
- //Create mtools config file
- char fname[] = "/tmp/gparted-XXXXXXXX" ;
- char dletter = 'H' ;
- Glib::ustring err_msg = "" ;
- err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
- if( err_msg.length() != 0 )
- partition .messages .push_back( err_msg );
-
- Glib::ustring cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -s %2:", fname, dletter ) ;
+ Glib::ustring cmd = "mlabel -s :: -i " + partition.get_path();
if ( ! Utils::execute_command( cmd, output, error, true ) )
{
@@ -160,25 +154,15 @@ void fat32::read_label( Partition & partition )
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
-
- //Delete mtools config file
- err_msg = Utils::delete_mtoolsrc_file( fname );
}
bool fat32::write_label( const Partition & partition, OperationDetail & operationdetail )
{
- //Create mtools config file
- char fname[] = "/tmp/gparted-XXXXXXXX" ;
- char dletter = 'H' ;
- Glib::ustring err_msg = "" ;
- err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
-
Glib::ustring cmd = "" ;
if ( partition .get_label() .empty() )
- cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ;
+ cmd = "mlabel -c :: -i " + partition.get_path();
else
- cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"",
- fname, dletter, partition .get_label() ) ;
+ cmd = "mlabel ::\"" + partition.get_label() + "\" -i " + partition.get_path();
operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
@@ -190,23 +174,12 @@ bool fat32::write_label( const Partition & partition, OperationDetail & operatio
if ( ! error .empty() )
operationdetail .get_last_child() .add_child( OperationDetail( error, STATUS_NONE, FONT_ITALIC ) ) ;
- //Delete mtools config file
- err_msg = Utils::delete_mtoolsrc_file( fname );
-
return ( exit_status == 0 );
}
void fat32::read_uuid( Partition & partition )
{
- //Create mtools config file
- char fname[] = "/tmp/gparted-XXXXXXXX" ;
- char dletter = 'H' ;
- Glib::ustring err_msg = "" ;
- err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
- if( err_msg.length() != 0 )
- partition .messages .push_back( err_msg );
-
- Glib::ustring cmd = String::ucompose( "export MTOOLSRC=%1 && mdir -f %2:", fname, dletter ) ;
+ Glib::ustring cmd = "mdir -f :: -i " + partition.get_path();
if ( ! Utils::execute_command( cmd, output, error, true ) )
{
@@ -222,22 +195,12 @@ void fat32::read_uuid( Partition & partition )
if ( ! error .empty() )
partition .messages .push_back( error ) ;
}
-
- err_msg = Utils::delete_mtoolsrc_file( fname );
}
bool fat32::write_uuid( const Partition & partition, OperationDetail & operationdetail )
{
- //Create mtools config file
- char fname[] = "/tmp/gparted-XXXXXXXX" ;
- char dletter = 'H' ;
- Glib::ustring err_msg = "" ;
- err_msg = Utils::create_mtoolsrc_file( fname, dletter, partition.get_path() ) ;
-
- // Wait some time - 'random' UUIDs turn out identical if generated in quick succession...
- sleep(1);
- Glib::ustring cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -s -n %2:", fname, dletter ) ;
+ Glib::ustring cmd = "mlabel -s -n :: -i " + partition.get_path();
operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
@@ -249,9 +212,6 @@ bool fat32::write_uuid( const Partition & partition, OperationDetail & operation
if ( ! error .empty() )
operationdetail .get_last_child() .add_child( OperationDetail( error, STATUS_NONE, FONT_ITALIC ) ) ;
- //Delete mtools config file
- err_msg = Utils::delete_mtoolsrc_file( fname );
-
return ( exit_status == 0 );
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]