[gparted] Add fallback busy detection for btrfs file systems (#723842)



commit d47783eff8d01d4d887f4f3935021fd0f10e23b1
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Sun Apr 20 19:56:12 2014 +0100

    Add fallback busy detection for btrfs file systems (#723842)
    
    In a number of cases there may be no btrfs device cache entry.  Some of
    the reasons why this can occur:
    1)  Mounting device removed from btrfs on linux <= 3.4 so old mount
        point in /proc/mounts;
    2)  btrfs and btrfs-show commands don't exist;
    3)  btrfs or btrfs-show command returned non-zero exit status;
    4)  get_cache_entry() failed to parse output from btrfs filesystem show
        or btrfs-show.
    
    Without a valid btrfs device cache entry, busy detection for all member
    devices fails.  Search the GParted internal mounted partitions map as
    the fallback busy detection method.  This can only determine if the
    mounting device is mounted or not, not any of the other members of a
    multi-device btrfs file system.
    
    Bug #723842 - GParted resizes the wrong filesystem (does not pass the
                  devid to btrfs filesystem resize)

 src/btrfs.cc |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/src/btrfs.cc b/src/btrfs.cc
index 48f6aed..7d0e493 100644
--- a/src/btrfs.cc
+++ b/src/btrfs.cc
@@ -441,6 +441,18 @@ void btrfs::clear_cache()
 Glib::ustring btrfs::get_mount_device( const Glib::ustring & path )
 {
        BTRFS_Device btrfs_dev = get_cache_entry( path ) ;
+       if ( btrfs_dev .devid == -1 || btrfs_dev .members .empty() )
+       {
+               //WARNING:
+               //  No btrfs device cache entry found or entry without any member devices.
+               //  Use fallback busy detection method which can only determine if the
+               //  mounting device is mounted or not, not any of the other members of a
+               //  multi-device btrfs file system.
+               if ( GParted_Core::is_dev_mounted( path ) )
+                       return path ;
+               return "" ;
+       }
+
        for ( unsigned int i = 0 ; i < btrfs_dev .members .size() ; i ++ )
                if ( GParted_Core::is_dev_mounted( btrfs_dev .members[ i ] ) )
                        return btrfs_dev .members[ i ] ;


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