From 77ef2be08930688e20362f32e2708b59b0038782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= Date: Wed, 5 Jul 2017 17:40:20 +0200 Subject: [PATCH] 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 --- src/fat16.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fat16.cc b/src/fat16.cc index 178f10db..6e254db4 100644 --- a/src/fat16.cc +++ b/src/fat16.cc @@ -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 );