Recognise Linux Swap Suspend and Software RAID partitions (#709640)

Recognise in kernel, Linux Swap Suspend partitions.  (When hibernated
the kernel write the RAM out to swap space and changes the magic string
from swap space to suspend).  Recognition required either
libparted >= 1.8.8.1 or blkid from util-linux >= 2.15 or before that
blkid from e2fsprogs >= 1.39.

Recognise Linux Software RAID partitions.  Recognition requires blkid
from util-linux >= 2.15.

Example:

    # blkid /dev/sda10 /dev/sda11
    /dev/sda10: ... TYPE="swsuspend"
    /dev/sda11: ... TYPE="linux_raid_member"

    # parted /dev/sda print
    Model: ATA SAMSUNG HM500JI (scsi)
    Disk /dev/sda: 500GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos

    Number  Start   End     Size    Type      File system     Flags
    ...
    10      361GB   362GB   1074MB  logical   swsusp
    11      362GB   363GB   1074MB  logical                   raid

Bug #709640 - Linux Swap Suspend and Software RAID partitions not
              recognised
This commit is contained in:
Mike Fleetwood 2013-10-05 16:28:24 +01:00 committed by Curtis Gedak
parent be2689ad25
commit fac3f5b865
6 changed files with 83 additions and 60 deletions

View File

@ -87,7 +87,9 @@ enum FILESYSTEM
FS_USED = 24,
FS_UNUSED = 25,
FS_LUKS = 26
FS_LUKS = 26,
FS_LINUX_SWRAID = 27,
FS_LINUX_SWSUSPEND = 28
} ;
enum SIZE_UNIT

View File

@ -123,10 +123,12 @@ void DialogFeatures::load_filesystems( const std::vector<FS> & FILESYSTEMS )
//fill the features chart with valid file systems
for ( unsigned short t = 0; t < FILESYSTEMS .size() ; t++ )
{
//Skip unknown, cleared and luks because these are not file systems
//Skip non-file systems or file systems only recognised but not otherwise supported
if ( FILESYSTEMS[ t ] .filesystem == FS_UNKNOWN
|| FILESYSTEMS[ t ] .filesystem == FS_CLEARED
|| FILESYSTEMS[ t ] .filesystem == FS_LUKS
|| FILESYSTEMS[ t ] .filesystem == FS_LINUX_SWRAID
|| FILESYSTEMS[ t ] .filesystem == FS_LINUX_SWSUSPEND
)
continue ;
show_filesystem( FILESYSTEMS[ t ] ) ;

View File

@ -47,13 +47,15 @@ void Dialog_Partition_New::Set_Data( const Partition & partition,
// the order of items in the file system menu, built by Build_Filesystems_Menu().
this ->FILESYSTEMS = FILESYSTEMS ;
//... remove all non-valid file systems
//... remove all non-file systems or file systems only recognised but not otherwise supported
std::vector< FS >::iterator f ;
for ( f = this->FILESYSTEMS .begin(); f != this->FILESYSTEMS .end(); f++ )
{
if ( f ->filesystem == FS_UNKNOWN
|| f ->filesystem == FS_CLEARED
|| f ->filesystem == FS_LUKS
|| f ->filesystem == FS_LINUX_SWRAID
|| f ->filesystem == FS_LINUX_SWSUSPEND
)
//Compensate for subsequent 'f++' ...
f = this ->FILESYSTEMS .erase( f ) - 1 ;

View File

@ -118,12 +118,14 @@ void GParted_Core::find_supported_filesystems()
FILESYSTEM_MAP[ FS_UFS ] = new ufs() ;
FILESYSTEM_MAP[ FS_XFS ] = new xfs() ;
FILESYSTEM_MAP[ FS_LUKS ] = NULL ;
FILESYSTEM_MAP[ FS_LINUX_SWRAID ] = NULL ;
FILESYSTEM_MAP[ FS_LINUX_SWSUSPEND ] = NULL ;
//Iteration of std::map is ordered according to operator< of the key.
// Hence the FILESYSTEMS vector is constructed in FILESYSTEM enum
// order: FS_UNKNOWN, FS_CLEARED, FS_BTRFS, ..., FS_XFS, FS_LUKS
// which ultimately controls the default order of file systems in menus
// and dialogs.
// order: FS_UNKNOWN, FS_CLEARED, FS_BTRFS, ..., FS_LINUX_SWRAID,
// LINUX_SWSUSPEND which ultimately controls the default order of file
// systems in menus and dialogs.
FILESYSTEMS .clear() ;
FS fs_notsupp;
@ -1268,6 +1270,11 @@ GParted::FILESYSTEM GParted_Core::get_filesystem( PedDevice* lp_device, PedParti
return GParted::FS_HFSPLUS ;
else if ( fs_type == "ufs" )
return GParted::FS_UFS ;
else if ( fs_type == "linux_raid_member" )
return FS_LINUX_SWRAID ;
else if ( fs_type == "swsusp" ||
fs_type == "swsuspend" )
return FS_LINUX_SWSUSPEND ;
}
@ -1468,9 +1475,11 @@ void GParted_Core::set_mountpoints( std::vector<Partition> & partitions )
if ( ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||
partitions[ t ] .type == GParted::TYPE_LOGICAL
) &&
partitions[ t ] .filesystem != GParted::FS_LINUX_SWAP &&
partitions[ t ] .filesystem != GParted::FS_LVM2_PV &&
partitions[ t ] .filesystem != GParted::FS_LUKS
partitions[ t ] .filesystem != FS_LINUX_SWAP &&
partitions[ t ] .filesystem != FS_LVM2_PV &&
partitions[ t ] .filesystem != FS_LUKS &&
partitions[ t ] .filesystem != FS_LINUX_SWRAID &&
partitions[ t ] .filesystem != FS_LINUX_SWSUSPEND
)
{
if ( partitions[ t ] .busy )
@ -1539,8 +1548,10 @@ void GParted_Core::set_used_sectors( std::vector<Partition> & partitions, PedDis
{
for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
{
if ( partitions[ t ] .filesystem != GParted::FS_LUKS &&
partitions[ t ] .filesystem != GParted::FS_UNKNOWN
if ( partitions[ t ] .filesystem != FS_UNKNOWN &&
partitions[ t ] .filesystem != FS_LUKS &&
partitions[ t ] .filesystem != FS_LINUX_SWRAID &&
partitions[ t ] .filesystem != FS_LINUX_SWSUSPEND
)
{
if ( partitions[ t ] .type == GParted::TYPE_PRIMARY ||

View File

@ -106,6 +106,8 @@ Glib::ustring Utils::get_color( FILESYSTEM filesystem )
case FS_UNUSED : return "#FFFFFF" ; //white
case FS_LVM2_PV : return "#CC9966" ; // ~ medium brown
case FS_LUKS : return "#625B81" ; //purple dark
case FS_LINUX_SWRAID : return "#5A4733" ; // ~ dark brown
case FS_LINUX_SWSUSPEND : return "#884631" ; //red dark
default : return "#000000" ;
}
@ -233,6 +235,8 @@ Glib::ustring Utils::get_filesystem_string( FILESYSTEM filesystem )
case FS_UNUSED : return _("unused") ;
case FS_LVM2_PV : return "lvm2 pv" ;
case FS_LUKS : return "crypt-luks" ;
case FS_LINUX_SWRAID : return "linux-raid" ;
case FS_LINUX_SWSUSPEND : return "linux-suspend" ;
default : return "" ;
}

View File

@ -416,10 +416,12 @@ Gtk::Menu * Win_GParted::create_format_menu()
for ( unsigned int t = 0 ; t < fss .size() ; t++ )
{
//Skip unknown, cleared and luks because these are not file systems
//Skip non-file systems or file systems only recognised but not otherwise supported
if ( fss[ t ] .filesystem == FS_UNKNOWN
|| fss[ t ] .filesystem == FS_CLEARED
|| fss[ t ] .filesystem == FS_LUKS
|| fss[ t ] .filesystem == FS_LINUX_SWRAID
|| fss[ t ] .filesystem == FS_LINUX_SWSUSPEND
)
continue ;