Skip to content
  • Mike Fleetwood's avatar
    Simplify Device object to a single path (#767842) · 902afaa0
    Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
    Background
    
    GParted stored a list of paths for Device and Partition objects.  It
    sorted this list [1][2] and treated the first specially as that is what
    get_path() returned and was used almost everywhere; with the file system
    specific tools, looked up in various *_Info caches, etc.
    
    [1] Device::add_path(), ::add_paths()
    [2] Partition::add_path(), ::add_paths()
    
    Mount point display [3] was the only bit of GParted which really worked
    with the path list.  Busy file system detection [4] just used the path
    provided by libparted, or for LUKS /dev/mapper/* names.  It checked that
    single path against the mounted file systems found from /proc/mounts,
    expanded with additional block device names when symlinks were
    encountered.
    
    [3] GParted_Core::set_mountpoints() -> set_mountpoints_helper()
    [4] GParted_Core::set_device_partitions() -> is_busy()
        GParted_Core::set_device_one_partition() -> is_busy()
        GParted_Core::set_luks_partition() -> is_busy()
    
    Having the first path, by sort order, treated specially by being used
    everywhere and virtually ignoring the others was wrong, complicated to
    remember and difficult code with.  As all the additional paths were
    virtually unused and made no difference, remove them.  The "improved
    detection of mountpoins, free space, etc.." benefit from commit [5]
    doesn't seem to exist.  Therefore simplify to a single path for Device
    and Partition objects.
    
    [5] commit 6d8b169e
        changed the way devices and partitions store their device paths.
        Instead of holding a 'realpath' and a symbolic path we store paths
        in a list.  This allows for improved detection of mountpoins, free
        space, etc..
    
    This patch
    
    Simplify the Device object from a vector of paths to a single path.
    Remove add_paths() and get_paths() methods.  Keep add_path() and
    get_path() for now.
    
    Bug 767842 - File system usage missing when tools report alternate block
                 device names
    902afaa0