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



commit 77ef2be08930688e20362f32e2708b59b0038782
Author: Pali Rohár <pali rohar gmail com>
Date:   Wed Jul 5 17:40:20 2017 +0200

    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 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/fat16.cc b/src/fat16.cc
index 178f10d..6e254db 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 );


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]