[gparted] Avoid detecting exfat-utils commands as exfatprogs commands (#137)



commit 4a8495205814e72c1b900da1cedae4e8175c8173
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Tue Feb 2 19:29:40 2021 +0000

    Avoid detecting exfat-utils commands as exfatprogs commands (#137)
    
    A user had exfat-utils installed and tried to use GParted to create an
    exfat file system.  GParted ran this command but it failed:
        # mkfs.exfat -L '' '/dev/sdb1'
        mkexfatfs 1.3.0
        mkfs.exfat: invalid option -- 'L'
        Usage: mkfs.exfat [-i volume-id] [-n label] [-p partition-first-sector] [-s sectors-per-cluster] [-V] 
<device>
    
    The problem is that both exfat-utils and exfatprogs packages provide
    mkfs.exfat and fsck.exfat commands but they have incompatible command
    line options and GParted is programmed for exfatprogs.  So far GParted
    just checks the executable exists, hence the mis-identification.
    
    Reported version of exfat-utils commands:
        $ mkfs.exfat -V 2> /dev/null
        mkexfatfs 1.3.0
        Copyright (C) 2011-2018  Andrew Nayenko
        $ fsck.exfat -V 2> /dev/null
        exfatfsck 1.3.0
        Copyright (C) 2011-2018  Andrew Nayenko
    
    Reported versions of exfatprogs commands:
        $ mkfs.exfat -V 2> /dev/null
        exfatprogs version : 1.0.4
        $ fsck.exfat -V 2> /dev/null
        exfatprogs version : 1.0.4
    
    Fix this by only enabling exfat support also when the version string of
    each command starts "exfatprogs version".  Note that this extra checking
    is not needed for tune.exfat because only exfatprogs provides that
    executable.
    
    Closes #137 - Creating exfat partition with a label fails with error

 src/exfat.cc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/exfat.cc b/src/exfat.cc
index 41d0e726..c0eab9a2 100644
--- a/src/exfat.cc
+++ b/src/exfat.cc
@@ -38,7 +38,11 @@ FS exfat::get_filesystem_support()
        fs .online_read = FS::GPARTED ;
 
        if (! Glib::find_program_in_path("mkfs.exfat").empty())
-               fs.create = FS::EXTERNAL;
+       {
+               Utils::execute_command("mkfs.exfat -V", output, error, true);
+               if (output.compare(0, 18, "exfatprogs version") == 0)
+                       fs.create = FS::EXTERNAL;
+       }
 
        if (! Glib::find_program_in_path("tune.exfat").empty())
        {
@@ -47,7 +51,11 @@ FS exfat::get_filesystem_support()
        }
 
        if (! Glib::find_program_in_path("fsck.exfat").empty())
-               fs.check = FS::EXTERNAL;
+       {
+               Utils::execute_command("fsck.exfat -V", output, error, true);
+               if (output.compare(0, 18, "exfatprogs version") == 0)
+                       fs.check = FS::EXTERNAL;
+       }
 
        return fs;
 }


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