[gparted] Stop showing duplicate mount points for unmounted encrypted file systems (#771323)



commit 8c870cf72f535c27f316d00a1408787aaae35bc9
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Mon Sep 12 19:58:36 2016 +0100

    Stop showing duplicate mount points for unmounted encrypted file systems (#771323)
    
    Have an unmounted file system within an open encrypted mapping and an
    entry in /etc/fstab for the file system like this:
    
        # lsblk
        NAME           MAJ:MIN RM   SIZE RO TYPE   MOUNTPOINT
        ...
        sdb              8:16   0     8G  0 disk
        +-sdb1           8:17   0     1G  0 part
          +-sdb1_crypt 253:0    0  1022M  0 crypt
        # blkid | grep sdb1
        /dev/sdb1: TYPE="crypto_LUKS" ...
        /dev/mapper/sdb1_crypt: TYPE="ext4" ...
        # ls -l /dev/mapper/sdb1_crypt /dev/dm-0
        brw-rw----. 1 root disk 253, 0 Sep 12 19:09 /dev/dm-0
        lrwxrwxrwx. 1 root root      7 Sep 12 19:09 /dev/mapper/sdb1_crypt -> ../dm-0
        # grep sdb1 /etc/fstab
        /dev/mapper/sdb1_crypt   /mnt/1   ext4   defaults    0 0
    
    The mount point will be shown twice for the partition:
        /mnt/1, /mnt/1
    
    This is because add_node_and_mountpoint() adds two entries for both the
    symbolic and real block special names:
        map["/dev/mapper/sdb1_crypt"] = ["/mnt/1"]
        map["/dev/dm-0"]              = ["/mnt/1"]
    This was needed for the old code which used string compare to match
    block devices so that the mount point could be looked up by either name.
    However since bug 767842 introduced major, minor number comparison it
    became unnecessary.  As both names refer to the same device the mount
    point gets added twice to the same entry.  Hence display of the double
    mount.
        map[BlockSpecial{"/dev/mapper/sdb1_crypt", 253, 0}] =
                                                        ["/mnt/1", "/mnt/1"]
    
    It is always going to be the case that the symbolic link and real block
    special names have the same major, minor numbers.  That was the
    requirement of the BlockSpecial class and the reason for using stat() to
    lookup the numbers.  Therefore adding entries for both names will always
    add duplicate entries.  Fix by stop using realpath() to lookup the real
    name and adding the duplicate entry.
    
    Introduced by:
        a800ca8b68d60251101ee27e569dfa2a97b67886
        Add BlockSpecial into mount_info and fstab_info (#767842)
    
    Bug 771323 - GParted is showing duplicate mount points for unmounted
                 encrypted file systems

 src/Mount_Info.cc |   16 +---------------
 1 files changed, 1 insertions(+), 15 deletions(-)
---
diff --git a/src/Mount_Info.cc b/src/Mount_Info.cc
index b7ae764..c73f41c 100644
--- a/src/Mount_Info.cc
+++ b/src/Mount_Info.cc
@@ -144,23 +144,9 @@ void Mount_Info::add_node_and_mountpoint( MountMapping & map,
                                           Glib::ustring & node,
                                           Glib::ustring & mountpoint )
 {
-       // Only add node path(s) if mount point exists
+       // Only add node path if mount point exists
        if ( file_test( mountpoint, Glib::FILE_TEST_EXISTS ) )
-       {
                map[BlockSpecial( node )].push_back( mountpoint );
-
-               // If node is a symbolic link (e.g., /dev/root)
-               // then find real path and add entry too
-               if ( file_test( node, Glib::FILE_TEST_IS_SYMLINK ) )
-               {
-                       char * rpath = realpath( node.c_str(), NULL );
-                       if ( rpath != NULL )
-                       {
-                               map[BlockSpecial( rpath )].push_back( mountpoint );
-                               free( rpath );
-                       }
-               }
-       }
 }
 
 void Mount_Info::read_mountpoints_from_file_swaps( const Glib::ustring & filename, MountMapping & map )


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