From d0fec5e26ffae490c1005a19e062d5a1abad0a3d Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Sat, 29 Dec 2012 10:10:08 +0000 Subject: [PATCH] Remove redundant code trimming labels to length before use (#689318) No longer need to trim fat16, fat32 and xfs labels as all labels are limited to their maximum lengths during entry. Bug #689318 - filesystem type specific support for partition name maximum length --- include/Utils.h | 1 - src/Utils.cc | 9 --------- src/fat16.cc | 9 ++++----- src/fat32.cc | 8 ++++---- src/xfs.cc | 6 +----- 5 files changed, 9 insertions(+), 24 deletions(-) diff --git a/include/Utils.h b/include/Utils.h index 0cfbaab7..870cfebd 100644 --- a/include/Utils.h +++ b/include/Utils.h @@ -174,7 +174,6 @@ public: static Glib::ustring regexp_label( const Glib::ustring & text , const Glib::ustring & pattern ) ; - static Glib::ustring fat_compliant_label( const Glib::ustring & label ) ; static Glib::ustring create_mtoolsrc_file( char file_name[], const char drive_letter, const Glib::ustring & device_path ) ; static Glib::ustring delete_mtoolsrc_file( const char file_name[] ) ; diff --git a/src/Utils.cc b/src/Utils.cc index e38a3da7..76c87f5b 100644 --- a/src/Utils.cc +++ b/src/Utils.cc @@ -458,15 +458,6 @@ Glib::ustring Utils::regexp_label( const Glib::ustring & text return "" ; } -Glib::ustring Utils::fat_compliant_label( const Glib::ustring & label ) -{ - //Limit volume label to 11 characters - Glib::ustring text = label ; - if( text .length() > 11 ) - text .resize( 11 ) ; - return text ; -} - Glib::ustring Utils::create_mtoolsrc_file( char file_name[], const char drive_letter, const Glib::ustring & device_path ) { diff --git a/src/fat16.cc b/src/fat16.cc index e50096a1..6b85b567 100644 --- a/src/fat16.cc +++ b/src/fat16.cc @@ -190,10 +190,10 @@ bool fat16::write_label( const Partition & partition, OperationDetail & operatio cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ; else cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", - fname, dletter, Utils::fat_compliant_label( partition .get_label() ) ) ; - + fname, dletter, partition .get_label() ) ; + operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ; - + int exit_status = Utils::execute_command( cmd, output, error ) ; if ( ! output .empty() ) @@ -268,8 +268,7 @@ bool fat16::write_uuid( const Partition & partition, OperationDetail & operation bool fat16::create( const Partition & new_partition, OperationDetail & operationdetail ) { - return ! execute_command( "mkdosfs -F16 -v -n \"" + Utils::fat_compliant_label( new_partition .get_label() ) + - "\" " + new_partition .get_path(), operationdetail ) ; + return ! execute_command( "mkdosfs -F16 -v -n \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ; } bool fat16::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition ) diff --git a/src/fat32.cc b/src/fat32.cc index e58bef4c..3f4c0e59 100644 --- a/src/fat32.cc +++ b/src/fat32.cc @@ -178,9 +178,10 @@ bool fat32::write_label( const Partition & partition, OperationDetail & operatio cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ; else cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", - fname, dletter, Utils::fat_compliant_label( partition .get_label() ) ) ; + fname, dletter, partition .get_label() ) ; + operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ; - + int exit_status = Utils::execute_command( cmd, output, error ) ; if ( ! output .empty() ) @@ -256,8 +257,7 @@ bool fat32::write_uuid( const Partition & partition, OperationDetail & operation bool fat32::create( const Partition & new_partition, OperationDetail & operationdetail ) { - return ! execute_command( "mkdosfs -F32 -v -n \"" + Utils::fat_compliant_label( new_partition .get_label() ) + - "\" " + new_partition .get_path(), operationdetail ) ; + return ! execute_command( "mkdosfs -F32 -v -n \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ; } bool fat32::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition ) diff --git a/src/xfs.cc b/src/xfs.cc index dcaa20ed..a03782ac 100644 --- a/src/xfs.cc +++ b/src/xfs.cc @@ -164,11 +164,7 @@ bool xfs::write_uuid( const Partition & partition, OperationDetail & operationde bool xfs::create( const Partition & new_partition, OperationDetail & operationdetail ) { - //mkfs.xfs will not create file system if label is longer than 12 characters, hence truncation. - Glib::ustring label = new_partition .get_label() ; - if( label .length() > 12 ) - label = label.substr( 0, 12 ) ; - return ! execute_command( "mkfs.xfs -f -L \"" + label + "\" " + new_partition .get_path(), operationdetail ) ; + return ! execute_command( "mkfs.xfs -f -L \"" + new_partition .get_label() + "\" " + new_partition .get_path(), operationdetail ) ; } bool xfs::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )