Implement usage reporting of active encrypted swap partitions (#771670)
GParted does not show the usage of active encrypted swap partitions, instead showing partition warning "Unable to read the contents of this file system! ...". OS setup: # ls -l /dev/mapper/sdb4_crypt /dev/dm-3 brw-rw----. 1 root disk 253, 3 Sep 14 07:26 /dev/dm-3 lrwxrwxrwx. 1 root root 7 Sep 14 07:26 /dev/mapper/sdb4_crypt -> ../dm-3 # mkswap -L encrypted_swap /dev/mapper/sdb4_crypt # swapon /dev/mapper/sdb4_crypt # cat /proc/swaps Filename Type Size Used Priority /dev/sda2 partition 2097148 237632 -1 /dev/dm-3 partition 1046524 0 -2 This is because the code was performing a string compare between the canonical /dev/mapper/sdb4_crypt name GParted is using and the /dev/dm-3 name reported by the kernel via /proc/swaps. Fix by creating BlockSpecial objects from the names and compare those so that comparison is done correctly using major, minor numbers. Bug 771670 - Usage of active encrypted swap is not shown
This commit is contained in:
parent
3d7804576f
commit
3966cc3e6f
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "../include/linux_swap.h"
|
#include "../include/linux_swap.h"
|
||||||
|
#include "../include/BlockSpecial.h"
|
||||||
#include "../include/Partition.h"
|
#include "../include/Partition.h"
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
@ -79,13 +80,13 @@ void linux_swap::set_used_sectors( Partition & partition )
|
||||||
std::ifstream input( "/proc/swaps" ) ;
|
std::ifstream input( "/proc/swaps" ) ;
|
||||||
if ( input )
|
if ( input )
|
||||||
{
|
{
|
||||||
Glib::ustring path = partition .get_path() ;
|
BlockSpecial bs_path = BlockSpecial( partition.get_path() );
|
||||||
Glib::ustring::size_type path_len = path.length() ;
|
|
||||||
while ( getline( input, line ) )
|
while ( getline( input, line ) )
|
||||||
{
|
{
|
||||||
if ( line .substr( 0, path_len ) == path )
|
Glib::ustring filename = Utils::regexp_label( line, "^([[:graph:]]+)" );
|
||||||
|
if ( bs_path == BlockSpecial( filename ) )
|
||||||
{
|
{
|
||||||
sscanf( line.substr( path_len ).c_str(), " %*s %*d %lld", &N );
|
sscanf( line.c_str(), "%*s %*s %*d %lld", &N );
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue