Probe for devices on our own, using /proc/partitions, and making libparted look
at each device separately instead of relying on parted_probe_all. The latter segfaults when it finds entries in /dev/mapper it cannot understand and hangs for a long time when a floppy is configured in the machine's BIOS but not actually present. Of course this is nothing more than a workaround. BUG: 221580 svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1070840
This commit is contained in:
parent
034d26e5da
commit
79aed672b6
|
@ -38,6 +38,7 @@
|
|||
#include <QList>
|
||||
#include <QFile>
|
||||
#include <QMap>
|
||||
#include <QRegExp>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
|
@ -266,7 +267,35 @@ void LibParted::scanDevices(OperationStack& ostack)
|
|||
ostack.clearOperations();
|
||||
ostack.clearDevices();
|
||||
|
||||
ped_device_probe_all();
|
||||
// LibParted's ped_device_probe_all()
|
||||
// 1) segfaults when it finds "illegal" entries in /dev/mapper
|
||||
// 2) takes several minutes to time out if the BIOS says there's a floppy drive present
|
||||
// when in fact there is none.
|
||||
// For that reason we scan devices on our own if possible, using what the kernel knows and
|
||||
// tells us about in /proc/partitions.
|
||||
QFile partitions("/proc/partitions");
|
||||
if (partitions.open(QIODevice::ReadOnly))
|
||||
{
|
||||
QRegExp rxLine("\\s*(\\d+)\\s+(\\d+)\\s+(\\d+)\\s([^0-9]+)\\s+");
|
||||
QByteArray line;
|
||||
|
||||
while (!(line = partitions.readLine()).isEmpty())
|
||||
{
|
||||
if (rxLine.indexIn(line) != -1)
|
||||
{
|
||||
const QString device = "/dev/" + rxLine.cap(4);
|
||||
// kDebug() << "device:" << device;
|
||||
ped_device_get(device.toLocal8Bit());
|
||||
}
|
||||
}
|
||||
|
||||
partitions.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
log(log::information) << i18nc("@info/plain", "Probing for devices using LibParted. This may crash or take a very long time. Read the manual's FAQ section for details.");
|
||||
ped_device_probe_all();
|
||||
}
|
||||
|
||||
PedDevice* pedDevice = ped_device_get_next(NULL);
|
||||
|
||||
|
|
Loading…
Reference in New Issue