gparted/include
Mike Fleetwood a800ca8b68 Add BlockSpecial into mount_info and fstab_info (#767842)
On some distributions having btrfs on top of LUKS encrypted partitions,
adding a second device and removing the first device used to mount the
file system causes GParted to no longer be able to report the file
system as busy or the mount points themselves.

For example, on CentOS 7, create a single btrfs file system and mount
it.  The provided /dev/mapper/sdb1_crypt name is reported, via
/proc/mounts, as the mounting device:
    # cryptsetup luksFormat --force-password /dev/sdb1
    # cryptsetup luksOpen /dev/sdb1 sdb1_crypt
    # mkfs.btrfs -L encrypted-btrfs /dev/mapper/sdb1_crypt
    # mount /dev/mapper/sdb1_crypt /mnt/1

    # ls -l /dev/mapper
    total 0
    lrwxrwxrwx. 1 root root       7 Jul  2 14:15 centos-root -> ../dm-1
    lrwxrwxrwx. 1 root root       7 Jul  2 14:15 centos-swap -> ../dm-0
    crw-------. 1 root root 10, 236 Jul  2 14:15 control
    lrwxrwxrwx. 1 root root       7 Jul  2 15:14 sdb1_crypt -> ../dm-2
    # fgrep btrfs /proc/mounts
    /dev/mapper/sdb1_crypt /mnt/1 btrfs rw,seclabel,relatime,space_cache 0 0

Add a second device to the btrfs file system:
    # cryptsetup luksFormat --force-password /dev/sdb2
    # cryptsetup luksOpen /dev/sdb2 sdb2_crypt
    # btrfs device add /dev/mapper/sdb2_crypt /mnt/1

    # ls -l /dev/mapper
    ...
    lrwxrwxrwx. 1 root root       7 Jul  2 15:12 sdb2_crypt -> ../dm-3
    # btrfs filesystem show /dev/mapper/sdb1_crypt
    Label: 'encrypted-btrfs'  uuid: 45d7b1ef-820c-4ef8-8abd-c70d928afb49
            Total devices 2 FS bytes used 32.00KiB
            devid    1 size 1022.00MiB used 12.00MiB path /dev/mapper/sdb1_crypt
            devid    2 size 1022.00MiB used 0.00B path /dev/mapper/sdb2_crypt

Remove the first mounting device from the btrfs file system.  Now the
non-canonical name /dev/dm-3 is reported, via /proc/mounts, as the
mounting device:
    # btrfs device delete /dev/mapper/sdb1_crypt /mnt/1

    # btrfs filesystem show /dev/mapper/sdb2_crypt
    Label: 'encrypted-btrfs'  uuid: 45d7b1ef-820c-4ef8-8abd-c70d928afb49
            Total devices 1 FS bytes used 96.00KiB
            devid    2 size 1022.00MiB used 144.00MiB path /dev/mapper/sdb2_crypt
    # fgrep btrfs /proc/mounts
    /dev/dm-3 /mnt/1 btrfs rw,seclabel,relatime,space_cache 0 0
    # ls -l /dev/dm-3
    brw-rw----. 1 root disk 253, 3 Jul  2 15:12 /dev/dm-3

GParted loads the mount_info mapping from /proc/mounts and with it the
/dev/dm-3 name.  When GParted is determining if the encrypted btrfs file
system is mounted or getting the mount points it is using the
/dev/mapper/sdb2_crypt name.  Therefore no information is found and the
file system is incorrectly reported as unmounted.

Fix by changing mount_info and fstab_info to use BlockSpecial objects
instead of strings so that matching is performed by major, minor device
numbers rather than by string compare.  Note that as BlockSpecial
objects are used as the key of std::map [1] mappings operator<() [2]
needs to be provided to order the key values.

[1] std::map
    http://www.cplusplus.com/reference/map/map/
[2] std::map::key_comp
    http://www.cplusplus.com/reference/map/map/key_comp/

Bug 767842 - File system usage missing when tools report alternate block
             device names
2016-08-06 09:47:58 -06:00
..
.cvsignore added *.swp some modifications to pass 'make distcheck' minor cleanups 2005-11-25 12:59:47 +00:00
BlockSpecial.h Add BlockSpecial into mount_info and fstab_info (#767842) 2016-08-06 09:47:58 -06:00
Copy_Blocks.h Use a single progress bar for the internal block copy operation (#762367) 2016-02-23 10:41:20 -07:00
DMRaid.h Move DEV_MAPPER_PATH from DMRaid.h to Utils.h (#760080) 2016-01-29 13:41:40 -07:00
Device.h Rename Device::add_path() to set_path() (#767842) 2016-08-06 09:47:58 -06:00
DialogFeatures.h Make the File System Support dialog resizable (#342682) 2014-01-27 10:54:48 -07:00
DialogManageFlags.h Stop copying selected partition object in Manage Flags dialog (#750168) 2015-06-10 10:44:33 -06:00
Dialog_Base_Partition.h Remove unnecessary sector_size parameter from Get_New_Partition methods 2016-01-26 10:11:35 -07:00
Dialog_Disklabel.h Replace obsolete FSF postal address in copyright notices (#721565) 2014-01-26 10:53:23 +00:00
Dialog_FileSystem_Label.h Rename class to Dialog_FileSystem_Label (#741424) 2015-02-01 10:08:23 -07:00
Dialog_Partition_Copy.h Remove unnecessary sector_size parameter from Get_New_Partition methods 2016-01-26 10:11:35 -07:00
Dialog_Partition_Info.h Add encryption section into the Information dialog (#760080) 2016-01-29 13:41:41 -07:00
Dialog_Partition_Name.h Make support of naming for other partition table types possible (#746214) 2015-03-25 10:02:42 -06:00
Dialog_Partition_New.h Remove unnecessary sector_size parameter from Get_New_Partition methods 2016-01-26 10:11:35 -07:00
Dialog_Partition_Resize_Move.h Use pointer to Partition in Dialog_Base_Partition and derived classes (#759726) 2016-01-26 10:11:35 -07:00
Dialog_Progress.h Change OperationDetail to not store complex objects in STL containers (#729139) 2014-05-18 10:07:45 -06:00
Dialog_Rescue_Data.h Use PartitionVector class throughout the code (#759726) 2016-01-26 10:11:35 -07:00
DrawingAreaVisualDisk.h Use PartitionVector class throughout the code (#759726) 2016-01-26 10:11:35 -07:00
FS_Info.h Workaround older blkid not distinguishing between FAT16 and FAT32 (#743181) 2015-03-09 11:04:13 -06:00
FileSystem.h Replace 32-bit member variable "index" with wider local variables (#764658) 2016-04-07 09:56:00 -06:00
Frame_Resizer_Base.h Replace obsolete FSF postal address in copyright notices (#721565) 2014-01-26 10:53:23 +00:00
Frame_Resizer_Extended.h Replace obsolete FSF postal address in copyright notices (#721565) 2014-01-26 10:53:23 +00:00
GParted_Core.h Add BlockSpecial into mount_info and fstab_info (#767842) 2016-08-06 09:47:58 -06:00
HBoxOperations.h Replace obsolete FSF postal address in copyright notices (#721565) 2014-01-26 10:53:23 +00:00
LUKS_Info.h Implement demand loading of LUKS_Info cache (#760080) 2016-01-29 13:41:40 -07:00
LVM2_PV_Info.h Create BlockSpecial class and use in LVM2_PV_Info (#767842) 2016-08-06 09:47:58 -06:00
Makefile.am Create BlockSpecial class and use in LVM2_PV_Info (#767842) 2016-08-06 09:47:58 -06:00
Operation.h Use pointers to Partitions in Operation classes (#759726) 2016-01-26 10:11:35 -07:00
OperationChangeUUID.h Add virtual qualifier to derived Operation class destructors 2016-01-26 10:11:36 -07:00
OperationCheck.h Prevent assert failure from OperationCheck::get_partition_new() (#767233) 2016-06-05 13:14:34 -06:00
OperationCopy.h Add virtual qualifier to derived Operation class destructors 2016-01-26 10:11:36 -07:00
OperationCreate.h Add virtual qualifier to derived Operation class destructors 2016-01-26 10:11:36 -07:00
OperationDelete.h Add virtual qualifier to derived Operation class destructors 2016-01-26 10:11:36 -07:00
OperationDetail.h Remove unused OperationDetail members (#760709) 2016-02-12 09:09:57 -07:00
OperationFormat.h Add virtual qualifier to derived Operation class destructors 2016-01-26 10:11:36 -07:00
OperationLabelFileSystem.h Add virtual qualifier to derived Operation class destructors 2016-01-26 10:11:36 -07:00
OperationNamePartition.h Add virtual qualifier to derived Operation class destructors 2016-01-26 10:11:36 -07:00
OperationResizeMove.h Add virtual qualifier to derived Operation class destructors 2016-01-26 10:11:36 -07:00
Partition.h Rename Partition::add_path() to set_path() (#767842) 2016-08-06 09:47:58 -06:00
PartitionLUKS.h Display messages for encrypted file systems (#760080) 2016-01-29 13:41:41 -07:00
PartitionVector.h Replace all Partition object copy assignment (#759726) 2016-01-26 10:11:35 -07:00
PipeCapture.h Prevent cross thread write after free in _OnReadable() (#731752) 2014-07-06 10:22:40 -06:00
Proc_Partitions_Info.h Remove now unused Proc_Partitions_Info::get_alternate_paths() (#767842) 2016-08-06 09:47:58 -06:00
ProgressBar.h Write a generic progress bar class (#760709) 2016-02-12 09:09:56 -07:00
SWRaid_Info.h Ensure SWRaid_Info cache is loaded at least once (#756829) 2015-11-02 10:03:45 -07:00
TreeView_Detail.h Use PartitionVector class throughout the code (#759726) 2016-01-26 10:11:35 -07:00
Utils.h Recognise GRUB2 core.img (#766989) 2016-06-15 12:45:05 -06:00
Win_GParted.h Change copied_partition into a pointer (#759726) 2016-01-26 10:11:35 -07:00
btrfs.h Include Partition.h header everywhere it's used 2016-01-26 10:11:35 -07:00
exfat.h Replace obsolete FSF postal address in copyright notices (#721565) 2014-01-26 10:53:23 +00:00
ext2.h Only enable ext4 64bit feature when required (#766910) 2016-06-05 09:40:11 -06:00
f2fs.h Include Partition.h header everywhere it's used 2016-01-26 10:11:35 -07:00
fat16.h Include Partition.h header everywhere it's used 2016-01-26 10:11:35 -07:00
hfs.h Include Partition.h header everywhere it's used 2016-01-26 10:11:35 -07:00
hfsplus.h Include Partition.h header everywhere it's used 2016-01-26 10:11:35 -07:00
i18n.h Make include guards unique (#539297) 2013-06-05 10:57:39 -06:00
jfs.h Include Partition.h header everywhere it's used 2016-01-26 10:11:35 -07:00
linux_swap.h Include Partition.h header everywhere it's used 2016-01-26 10:11:35 -07:00
luks.h Populate LUKS partition usage (#760080) 2016-01-29 13:41:40 -07:00
lvm2_pv.h Include Partition.h header everywhere it's used 2016-01-26 10:11:35 -07:00
nilfs2.h Include Partition.h header everywhere it's used 2016-01-26 10:11:35 -07:00
ntfs.h Display progress of NTFS file system specific copy operation (#762366) 2016-02-23 10:02:03 -07:00
reiser4.h Include Partition.h header everywhere it's used 2016-01-26 10:11:35 -07:00
reiserfs.h Include Partition.h header everywhere it's used 2016-01-26 10:11:35 -07:00
ufs.h Replace obsolete FSF postal address in copyright notices (#721565) 2014-01-26 10:53:23 +00:00
xfs.h Display progress of XFS file system specific copy operation (#760709) 2016-02-12 09:09:57 -07:00