[gparted] Prevent incorrect no usage values warning for luks/unknown (#760080)



commit 40c2cdda0b9a106b45a131a116a5c58ea3f57cb0
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sat Jan 2 11:55:27 2016 +0000

    Prevent incorrect no usage values warning for luks/unknown (#760080)
    
    Create and open a LUKS mapping but don't create any file system within.
    
        # cryptsetup luksFormat /dev/sdb5
        # cryptsetup luksOpen /dev/sdb5 sdb5_crypt
    
    GParted was incorrectly reporting this warning:
    
        Unable to read the contents of this file system!
        Because of this some operations may be unavailable.
        The cause might be a missing software package.
        The following list of software packages is required for luks file
        system support:  dmsetup.
    
    This is even though the usage figures for the on disk LUKS encryption
    are fully known.  See luks::set_used_sectors().
    
    This was occurring because derived PartitionLUKS::set_usage_known()
    was checking usage figures for the outer LUKS and the inner encrypted
    file system, unknown in this case.  Correct when displaying figures in
    the UI, but not correct in GParted_Core::set_used_sectors() when only
    checking the outer LUKS usage figures were set correctly.  Fix this.
    
    Bug 760080 - Implement read-only LUKS support

 src/GParted_Core.cc |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 2e30387..3ce1dea 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1970,7 +1970,14 @@ void GParted_Core::set_used_sectors( Partition & partition, PedDisk* lp_disk )
                }
 
                Sector unallocated;
-               if ( ! partition.sector_usage_known() )
+               // Only confirm that the above code succeeded in setting the sector usage
+               // values for this base Partition object, hence the explicit call to the
+               // base Partition class sector_usage_known() method.  For LUKS this avoids
+               // calling derived PartitionLUKS class sector_usage_known() which also
+               // checks for known sector usage in the encrypted file system.  But that
+               // wasn't set by the above code so in the case of luks/unknown would
+               // produce a false positive.
+               if ( ! partition.Partition::sector_usage_known() )
                {
                        Glib::ustring temp = _("Unable to read the contents of this file system!");
                        temp += "\n";


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