Added fat_compliant_label() method to limit volume labels to 11 characters.
Enforced fat compliant label for FAT16 and FAT32 file systems. svn path=/trunk/; revision=959
This commit is contained in:
parent
da37e4de04
commit
352641208a
1
AUTHORS
1
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).
|
We need to keep track of copyright (see the Maintainer HOWTO on www.gnu.org).
|
||||||
|
|
||||||
Curtis Gedak <gedakc@users.sourceforge.net>
|
Curtis Gedak <gedakc@users.sourceforge.net>
|
||||||
|
* Wrote Utils::fat_compliant_label() method
|
||||||
* Wrote Utils::cleanup_cursor() function
|
* Wrote Utils::cleanup_cursor() function
|
||||||
* Rewrote read_label functionality for hfs
|
* Rewrote read_label functionality for hfs
|
||||||
* Wrote create, read_label, and check_repair functionality for hfs+
|
* Wrote create, read_label, and check_repair functionality for hfs+
|
||||||
|
|
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2008-11-10 Curtis Gedak <gedakc@gmail.com>
|
||||||
|
|
||||||
|
* src/fat16.cc,
|
||||||
|
src/fat32.cc: Enforced fat compliant label before writing.
|
||||||
|
- Trimmed trailing spaces from label upon reading.
|
||||||
|
|
||||||
|
* include/Utils.h,
|
||||||
|
src/Utils.cc: Created new method fat_compliant_label().
|
||||||
|
- Limit volume label to 11 characters.
|
||||||
|
|
||||||
2008-11-08 Curtis Gedak <gedakc@gmail.com>
|
2008-11-08 Curtis Gedak <gedakc@gmail.com>
|
||||||
|
|
||||||
* include/ext2.h,
|
* include/ext2.h,
|
||||||
|
|
|
@ -136,6 +136,7 @@ public:
|
||||||
bool use_C_locale = false ) ;
|
bool use_C_locale = false ) ;
|
||||||
static Glib::ustring regexp_label( const Glib::ustring & text,
|
static Glib::ustring regexp_label( const Glib::ustring & text,
|
||||||
const Glib::ustring & regular_sub_expression ) ;
|
const Glib::ustring & regular_sub_expression ) ;
|
||||||
|
static Glib::ustring fat_compliant_label( const Glib::ustring & label ) ;
|
||||||
static Glib::ustring create_mtoolsrc_file( char file_name[],
|
static Glib::ustring create_mtoolsrc_file( char file_name[],
|
||||||
const char drive_letter, const Glib::ustring & device_path ) ;
|
const char drive_letter, const Glib::ustring & device_path ) ;
|
||||||
static Glib::ustring delete_mtoolsrc_file( const char file_name[] ) ;
|
static Glib::ustring delete_mtoolsrc_file( const char file_name[] ) ;
|
||||||
|
|
|
@ -279,6 +279,15 @@ Glib::ustring Utils::regexp_label( const Glib::ustring & text,
|
||||||
return label ;
|
return label ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,
|
Glib::ustring Utils::create_mtoolsrc_file( char file_name[], const char drive_letter,
|
||||||
const Glib::ustring & device_path )
|
const Glib::ustring & device_path )
|
||||||
{
|
{
|
||||||
|
|
|
@ -105,7 +105,7 @@ void fat16::read_label( Partition & partition )
|
||||||
|
|
||||||
if ( ! Utils::execute_command( cmd, output, error, true ) )
|
if ( ! Utils::execute_command( cmd, output, error, true ) )
|
||||||
{
|
{
|
||||||
partition .label = Utils::regexp_label( output, "Volume label is ([^(]*)" );
|
partition .label = Utils::trim( Utils::regexp_label( output, "Volume label is ([^(]*)" ) ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ bool fat16::write_label( const Partition & partition, OperationDetail & operatio
|
||||||
if( partition .label .empty() )
|
if( partition .label .empty() )
|
||||||
cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ;
|
cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ;
|
||||||
else
|
else
|
||||||
cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", fname, dletter, partition .label ) ;
|
cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", fname, dletter, Utils::fat_compliant_label( partition .label ) ) ;
|
||||||
|
|
||||||
operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
|
operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ bool fat16::write_label( const Partition & partition, OperationDetail & operatio
|
||||||
|
|
||||||
bool fat16::create( const Partition & new_partition, OperationDetail & operationdetail )
|
bool fat16::create( const Partition & new_partition, OperationDetail & operationdetail )
|
||||||
{
|
{
|
||||||
return ! execute_command( "mkdosfs -F16 -v -n \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
|
return ! execute_command( "mkdosfs -F16 -v -n \"" + Utils::fat_compliant_label( new_partition .label ) + "\" " + new_partition .get_path(), operationdetail ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fat16::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
|
bool fat16::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
|
||||||
|
|
|
@ -105,7 +105,7 @@ void fat32::read_label( Partition & partition )
|
||||||
|
|
||||||
if ( ! Utils::execute_command( cmd, output, error, true ) )
|
if ( ! Utils::execute_command( cmd, output, error, true ) )
|
||||||
{
|
{
|
||||||
partition .label = Utils::regexp_label( output, "Volume label is ([^(]*)" );
|
partition .label = Utils::trim( Utils::regexp_label( output, "Volume label is ([^(]*)" ) ) ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -132,7 +132,7 @@ bool fat32::write_label( const Partition & partition, OperationDetail & operatio
|
||||||
if( partition .label .empty() )
|
if( partition .label .empty() )
|
||||||
cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ;
|
cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel -c %2:", fname, dletter ) ;
|
||||||
else
|
else
|
||||||
cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", fname, dletter, partition .label ) ;
|
cmd = String::ucompose( "export MTOOLSRC=%1 && mlabel %2:\"%3\"", fname, dletter, Utils::fat_compliant_label( partition .label ) ) ;
|
||||||
operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
|
operationdetail .add_child( OperationDetail( cmd, STATUS_NONE, FONT_BOLD_ITALIC ) ) ;
|
||||||
|
|
||||||
int exit_status = Utils::execute_command( cmd, output, error ) ;
|
int exit_status = Utils::execute_command( cmd, output, error ) ;
|
||||||
|
@ -151,7 +151,7 @@ bool fat32::write_label( const Partition & partition, OperationDetail & operatio
|
||||||
|
|
||||||
bool fat32::create( const Partition & new_partition, OperationDetail & operationdetail )
|
bool fat32::create( const Partition & new_partition, OperationDetail & operationdetail )
|
||||||
{
|
{
|
||||||
return ! execute_command( "mkdosfs -F32 -v -n \"" + new_partition .label + "\" " + new_partition .get_path(), operationdetail ) ;
|
return ! execute_command( "mkdosfs -F32 -v -n \"" + Utils::fat_compliant_label( new_partition .label ) + "\" " + new_partition .get_path(), operationdetail ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fat32::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
|
bool fat32::resize( const Partition & partition_new, OperationDetail & operationdetail, bool fill_partition )
|
||||||
|
|
Loading…
Reference in New Issue