After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 771670 - Usage of active encrypted swap is not shown
Usage of active encrypted swap is not shown
Status: RESOLVED FIXED
Product: gparted
Classification: Other
Component: application
GIT HEAD
Other Linux
: Normal normal
: ---
Assigned To: Mike Fleetwood
gparted maintainers alias
Depends on:
Blocks:
 
 
Reported: 2016-09-19 20:40 UTC by Mike Fleetwood
Modified: 2016-10-19 16:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Report usage of encrypted swap partitions (v1) (3.82 KB, patch)
2016-09-19 20:53 UTC, Mike Fleetwood
none Details | Review
Report usage of encrypted swap partitions (v2) (6.51 KB, patch)
2016-10-05 12:23 UTC, Mike Fleetwood
none Details | Review

Description Mike Fleetwood 2016-09-19 20:40:13 UTC
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
    
Fix to follow
Comment 1 Mike Fleetwood 2016-09-19 20:53:20 UTC
Created attachment 335876 [details] [review]
Report usage of encrypted swap partitions (v1)

Hi Curtis,

Here's the fix for this.  Also a minor correction else where.

Thanks,
Mike
Comment 2 Curtis Gedak 2016-10-04 18:04:18 UTC
Hi Mike,

I'm unsure if I am testing patch v1 from comment #1 properly.


To set up the test I performed the following on openSUSE 13.2:

1) Create /dev/sdb2 128 MiB unformatted primary partition using GParted.

2) Encrypt the partition.

       # cryptsetup -y luksFormat /dev/sdb2

3) Open the encrypted partition.

       # cryptsetup luksOpen /dev/sdb2 encrypted_swap

4) Format the encrypted partition as swap.

       # mkswap -L encrypted_swap /dev/mapper/encrypted_swap

5) Run GParted and check /dev/sdb2 usage.

       Usage is reported for partition /dev/sdb2.
       E.g., Used 2.00 MiB, Unused 126.00 MiB, Size 128.00 MiB

6) Enable swap.

       # swapon /dev/mapper/encrypted_swap

7) Run GParted and check /dev/sdb2 usage.

       Note that usage is **not** reported for partition /dev/sdb2.
       E.g., Size 128.00 MiB
             **Used and Unused not shown**


Perhaps I missed a step?

Perhaps openSUSE is behaving differently (for example with the symbolic
link from /dev/mapper/encrypted_swap to /dev/dm-0)?


Following is a list of information similar to the initial bug report
OS setup description.

# ls -l /dev/mapper/encrypted_swap /dev/dm-0
brw-rw---- 1 root disk 254, 0 Oct  4 11:47 /dev/dm-0
lrwxrwxrwx 1 root root      7 Oct  4 11:47 /dev/mapper/encrypted_swap -> ../dm-0
# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda1                               partition       1541116 0       -1
/dev/dm-0                               partition       129020  0       -2


Curtis
Comment 3 Curtis Gedak 2016-10-04 18:32:45 UTC
One further clarification.  I saw the same results both without and with patch v1 applied to the current master branch of GParted.


1824997ab311fb04e5de1ef496779d78a8f45363 Updated Croatian translation
Comment 4 Mike Fleetwood 2016-10-04 20:29:33 UTC
Hi Curtis,

As per IM conversation you have found another bug; in operation==()
comparing BlockSpecials.  It requires both the major and minor numbers
to be greater than 0 before it matches by number.  However /dev/dm-0 has
major 254, minor 0.  Therefore it falls back to name compare and GParted
/dev/mapper/encrypted_swap and /proc/swaps name of /dev/dm-0 don't
match.

I'll add another patch to this set to fix this.

Mike


bool operator==( const BlockSpecial & lhs, const BlockSpecial & rhs )
{
	if ( lhs.m_major > 0UL && lhs.m_minor > 0UL )
		// Match block special files by major, minor device numbers.
		return lhs.m_major == rhs.m_major && lhs.m_minor == rhs.m_minor;
	else
		// For non-block special files fall back to name string compare.
		return lhs.m_name == rhs.m_name;
}
Comment 5 Mike Fleetwood 2016-10-05 12:23:00 UTC
Created attachment 336982 [details] [review]
Report usage of encrypted swap partitions (v2)

Hi Curtis,

Here's patchset v2.  Just adds a patch to fix the issue you found.

Thanks,
Mike
Comment 6 Curtis Gedak 2016-10-05 16:44:15 UTC
Hi Mike,

Thank you for the updated patch set.

Patch set v2 from comment #5 worked for me in my testing on the
following GNU/Linux distributions:

Debian    8
Fedora   24
openSUSE 13.2
Ubuntu   16.04

This patch set has been committed to the git repository for inclusion
in the next release of GParted.

The relevant git commits can be viewed at the following links:

Implement usage reporting of active encrypted swap partitions (#771670)
https://git.gnome.org/browse/gparted/commit/?id=3966cc3e6f6d7fefcf786ddb033973d4a8b8fdfb

Fix BlockSpecial comparison (#771670)
https://git.gnome.org/browse/gparted/commit/?id=253c4d641687f21a4656af0926af18371d47d654

Include extended partitions in the count of active partitions
https://git.gnome.org/browse/gparted/commit/?id=c6d29aa7e8456d688e5efea21d4b363cb92a54be


Curtis
Comment 7 Curtis Gedak 2016-10-19 16:23:08 UTC
This enhancement was included in the GParted 0.27.0 release on October 19, 2016.