Fix setting empty label when creating FAT16/32 file systems (#784564)

A FAT file system label in the partition boot sector should be set to
"NO NAME    " when the label is empty [1][2].  mkdosfs/mkfs.fat always
sets this to the label specified on the command line, even when the
label is blank [3].  Fix by not specifying the label when it is blank.

[1] The FAT File System, BIOS Parameter Block and Extended BIOS
    Parameter Block
    https://social.technet.microsoft.com/wiki/contents/articles/6771.the-fat-file-system.aspx#BPB_and_EBPB
[2] FAT16 File System, Volume Label
    http://www.maverick-os.dk/FileSystemFormats/FAT16_FileSystem.html#VolumeLabel
[3] mkfs.fat -n "" generates file system with invalid label
    https://github.com/dosfstools/dosfstools/issues/54

Bug 784564 - GParted calls mkfs.fat incorrectly when user does not specify label
This commit is contained in:
Pali Rohár 2017-07-05 17:40:20 +02:00 committed by Mike Fleetwood
parent 59c8a7d6df
commit 77ef2be089
1 changed files with 3 additions and 2 deletions

View File

@ -236,8 +236,9 @@ 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( create_cmd + " -F" + fat_size + " -v -I -n \"" +
sanitize_label( new_partition.get_filesystem_label() ) + "\" " +
Glib::ustring label_args = new_partition.get_filesystem_label().empty() ? "" :
"-n \"" + sanitize_label( new_partition.get_filesystem_label() ) + "\" ";
return ! execute_command( create_cmd + " -F" + fat_size + " -v -I " + label_args +
new_partition.get_path(),
operationdetail,
EXEC_CHECK_STATUS|EXEC_CANCEL_SAFE );