Optimize luks::mapperName function.
Now it uses lsblk to find out mapper node. It also makes opened luks volumes to be properly detected when no cryptsetup is found, e.g. crypt is opened in initramfs.
This commit is contained in:
parent
25e28a0e16
commit
6b772f3332
|
@ -511,18 +511,16 @@ bool luks::updateUUID(Report& report, const QString& deviceNode) const
|
||||||
|
|
||||||
QString luks::mapperName(const QString& deviceNode)
|
QString luks::mapperName(const QString& deviceNode)
|
||||||
{
|
{
|
||||||
ExternalCommand cmd(QStringLiteral("find"),
|
ExternalCommand cmd(QStringLiteral("lsblk"),
|
||||||
{ QStringLiteral("/dev/mapper/"),
|
{ QStringLiteral("--raw"),
|
||||||
QStringLiteral("-exec"),
|
QStringLiteral("--noheadings"),
|
||||||
QStringLiteral("cryptsetup"),
|
QStringLiteral("--output"),
|
||||||
QStringLiteral("status"),
|
QStringLiteral("name"),
|
||||||
QStringLiteral("{}"),
|
deviceNode });
|
||||||
QStringLiteral(";") });
|
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||||
if (cmd.run()) {
|
QStringList output=cmd.output().split(QStringLiteral("\n"));
|
||||||
QRegExp rxDeviceName(QStringLiteral("(/dev/mapper/[A-Za-z0-9-/]+) is "
|
output.removeFirst();
|
||||||
"active[A-Za-z0-9- \\.\n]+[A-Za-z0-9-: \n]+") + deviceNode);
|
return QStringLiteral("/dev/mapper/") + output.first();
|
||||||
if (rxDeviceName.indexIn(cmd.output()) > -1)
|
|
||||||
return rxDeviceName.cap(1);
|
|
||||||
}
|
}
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue