[partition] In logging, name device nicely
- Provide a convenience method that names a Partition* with the best human-readable name we can find (worst-case, spit out a pointer representation which will at least help figure out the identity of the Partition*).
This commit is contained in:
parent
33bd6c67c0
commit
7cfaba2d53
@ -42,6 +42,25 @@
|
|||||||
namespace PartUtils
|
namespace PartUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static QString
|
||||||
|
convenienceName( const Partition* const candidate )
|
||||||
|
{
|
||||||
|
if ( !candidate->mountPoint().isEmpty() )
|
||||||
|
return candidate->mountPoint();
|
||||||
|
if ( !candidate->partitionPath().isEmpty() )
|
||||||
|
return candidate->partitionPath();
|
||||||
|
if ( !candidate->devicePath().isEmpty() )
|
||||||
|
return candidate->devicePath();
|
||||||
|
if ( !candidate->deviceNode().isEmpty() )
|
||||||
|
return candidate->devicePath();
|
||||||
|
|
||||||
|
QString p;
|
||||||
|
QTextStream s( &p );
|
||||||
|
s << (void *)candidate;
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
canBeReplaced( Partition* candidate )
|
canBeReplaced( Partition* candidate )
|
||||||
{
|
{
|
||||||
@ -63,12 +82,12 @@ canBeReplaced( Partition* candidate )
|
|||||||
<< QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 );
|
<< QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 );
|
||||||
cDebug() << "Storage capacity B:" << availableStorageB
|
cDebug() << "Storage capacity B:" << availableStorageB
|
||||||
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
|
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
|
||||||
<< "for" << candidate->partitionPath() << " length:" << candidate->length();
|
<< "for" << convenienceName( candidate ) << " length:" << candidate->length();
|
||||||
|
|
||||||
if ( ok &&
|
if ( ok &&
|
||||||
availableStorageB > requiredStorageB )
|
availableStorageB > requiredStorageB )
|
||||||
{
|
{
|
||||||
cDebug() << "Partition" << candidate->partitionPath() << "authorized for replace install.";
|
cDebug() << "Partition" << convenienceName( candidate ) << "authorized for replace install.";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -85,7 +104,7 @@ canBeResized( Partition* candidate )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cDebug() << "Checking if" << candidate->partitionPath() << "can be resized.";
|
cDebug() << "Checking if" << convenienceName( candidate ) << "can be resized.";
|
||||||
if ( !candidate->fileSystem().supportGrow() ||
|
if ( !candidate->fileSystem().supportGrow() ||
|
||||||
!candidate->fileSystem().supportShrink() )
|
!candidate->fileSystem().supportShrink() )
|
||||||
{
|
{
|
||||||
@ -139,13 +158,13 @@ canBeResized( Partition* candidate )
|
|||||||
<< QString( "(%1GB)" ).arg( advisedStorageGB );
|
<< QString( "(%1GB)" ).arg( advisedStorageGB );
|
||||||
cDebug() << "Available storage B:" << availableStorageB
|
cDebug() << "Available storage B:" << availableStorageB
|
||||||
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
|
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
|
||||||
<< "for" << candidate->partitionPath() << " length:" << candidate->length()
|
<< "for" << convenienceName( candidate ) << " length:" << candidate->length()
|
||||||
<< " sectorsUsed:" << candidate->sectorsUsed() << " fsType:" << candidate->fileSystem().name();
|
<< " sectorsUsed:" << candidate->sectorsUsed() << " fsType:" << candidate->fileSystem().name();
|
||||||
|
|
||||||
if ( ok &&
|
if ( ok &&
|
||||||
availableStorageB > advisedStorageB )
|
availableStorageB > advisedStorageB )
|
||||||
{
|
{
|
||||||
cDebug() << "Partition" << candidate->partitionPath() << "authorized for resize + autopartition install.";
|
cDebug() << "Partition" << convenienceName( candidate ) << "authorized for resize + autopartition install.";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -381,7 +400,7 @@ isEfiSystem()
|
|||||||
bool
|
bool
|
||||||
isEfiBootable( const Partition* candidate )
|
isEfiBootable( const Partition* candidate )
|
||||||
{
|
{
|
||||||
cDebug() << "Check EFI bootable" << candidate->partitionPath() << candidate->devicePath();
|
cDebug() << "Check EFI bootable" << convenienceName( candidate ) << candidate->devicePath();
|
||||||
cDebug() << " .. flags" << candidate->activeFlags();
|
cDebug() << " .. flags" << candidate->activeFlags();
|
||||||
|
|
||||||
auto flags = PartitionInfo::flags( candidate );
|
auto flags = PartitionInfo::flags( candidate );
|
||||||
|
Loading…
Reference in New Issue
Block a user