Fix busy detection of file systems inside Linux Software RAID (#712533)

On some distributions GParted doesn't detect when a file system is busy
and mounted when the partition is within a Linux Software RAID array.
Affected distributions include: Debian 6, Debian 7 and RHEL/CentOS 6.x.

This is because of a bug in libparted 2.3 and earlier.  It was fixed by
this change in libparted 2.4:
    http://git.savannah.gnu.org/cgit/parted.git/commit/?id=db52898c214310dab4ed84e6cb2f9ffc8c3aa502
    linux: also detect "in-use" dmraid and scsi-Nth (N>=16) partition

Ubuntu 13.10 with libparted 2.3 is not affected because it contains a
distribution specific patch to correct it.

Fix by using GParted's internal mounted partitions map, mount_info, to
determine if a partition is busy, in addition to using libparted's
ped_partition_is_busy().

Bug #712533 - Partitions not detected as busy inside Software RAID on
              some distros
This commit is contained in:
Mike Fleetwood 2013-11-16 16:00:28 +00:00
parent 103fd9a0c6
commit 4d7ebe0314
1 changed files with 17 additions and 3 deletions

View File

@ -1051,10 +1051,21 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
}
else
#endif
partition_is_busy = ped_partition_is_busy( lp_partition )
|| ( filesystem == FS_LVM2_PV && lvm2_pv_info .has_active_lvs( partition_path ) )
{
//Determine if partition is busy:
// 1st search GParted internal mounted partitions map;
// 2nd custom checks for none file system partitions;
// 3rd use libparted.
iter_mp = mount_info .find( partition_path ) ;
if ( iter_mp != mount_info .end() )
partition_is_busy = true ;
partition_is_busy |= ( filesystem == FS_LVM2_PV && lvm2_pv_info .has_active_lvs( partition_path ) )
|| ( filesystem == FS_LINUX_SWRAID && Utils::swraid_member_is_active( partition_path ) ) ;
partition_is_busy |= ped_partition_is_busy( lp_partition ) ;
}
partition_temp .Set( device .get_path(),
partition_path,
lp_partition ->num,
@ -1095,7 +1106,10 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
}
else
#endif
{
//For extended partitions only use libparted to determine if it's busy.
partition_is_busy = ped_partition_is_busy( lp_partition ) ;
}
partition_temp .Set( device .get_path(),
partition_path,