Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/sfdisk/sfdiskbackend.cpp
Show All 15 Lines | |||||
16 | *************************************************************************/ | 16 | *************************************************************************/ | ||
17 | 17 | | |||
18 | /** @file | 18 | /** @file | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "plugins/sfdisk/sfdiskbackend.h" | 21 | #include "plugins/sfdisk/sfdiskbackend.h" | ||
22 | #include "plugins/sfdisk/sfdiskdevice.h" | 22 | #include "plugins/sfdisk/sfdiskdevice.h" | ||
23 | 23 | | |||
24 | #include "core/copysourcedevice.h" | ||||
25 | #include "core/copytargetbytearray.h" | ||||
24 | #include "core/diskdevice.h" | 26 | #include "core/diskdevice.h" | ||
25 | #include "core/lvmdevice.h" | 27 | #include "core/lvmdevice.h" | ||
26 | #include "core/partitiontable.h" | 28 | #include "core/partitiontable.h" | ||
27 | #include "core/partitionalignment.h" | 29 | #include "core/partitionalignment.h" | ||
28 | #include "core/raid/softwareraid.h" | 30 | #include "core/raid/softwareraid.h" | ||
29 | 31 | | |||
30 | #include "fs/filesystemfactory.h" | 32 | #include "fs/filesystemfactory.h" | ||
31 | #include "fs/luks.h" | 33 | #include "fs/luks.h" | ||
▲ Show 20 Lines • Show All 295 Lines • ▼ Show 20 Line(s) | 303 | { | |||
327 | } | 329 | } | ||
328 | 330 | | |||
329 | setPartitionTableForDevice(d, new PartitionTable(type, firstUsableSector, lastUsableSector)); | 331 | setPartitionTableForDevice(d, new PartitionTable(type, firstUsableSector, lastUsableSector)); | ||
330 | switch (type) { | 332 | switch (type) { | ||
331 | case PartitionTable::gpt: | 333 | case PartitionTable::gpt: | ||
332 | { | 334 | { | ||
333 | // Read the maximum number of GPT partitions | 335 | // Read the maximum number of GPT partitions | ||
334 | qint32 maxEntries; | 336 | qint32 maxEntries; | ||
335 | ExternalCommand ddCommand(QStringLiteral("dd"), | 337 | QByteArray gptHeader; | ||
336 | { QStringLiteral("skip=1"), QStringLiteral("count=1"), (QStringLiteral("if=") + d.deviceNode()) }, | 338 | CopySourceDevice source(d, 512, 1023); | ||
337 | QProcess::SeparateChannels); | 339 | CopyTargetByteArray target(gptHeader); | ||
338 | if (ddCommand.run(-1) && ddCommand.exitCode() == 0 ) { | 340 | | ||
339 | QByteArray gptHeader = ddCommand.rawOutput(); | 341 | ExternalCommand copyCmd; | ||
342 | if (copyCmd.copyBlocks(source, target)) { | ||||
340 | QByteArray gptMaxEntries = gptHeader.mid(80, 4); | 343 | QByteArray gptMaxEntries = gptHeader.mid(80, 4); | ||
341 | QDataStream stream(&gptMaxEntries, QIODevice::ReadOnly); | 344 | QDataStream stream(&gptMaxEntries, QIODevice::ReadOnly); | ||
342 | stream.setByteOrder(QDataStream::LittleEndian); | 345 | stream.setByteOrder(QDataStream::LittleEndian); | ||
343 | stream >> maxEntries; | 346 | stream >> maxEntries; | ||
344 | } | 347 | } | ||
345 | else | 348 | else | ||
346 | maxEntries = 128; | 349 | maxEntries = 128; | ||
347 | CoreBackend::setPartitionTableMaxPrimaries(*d.partitionTable(), maxEntries); | 350 | CoreBackend::setPartitionTableMaxPrimaries(*d.partitionTable(), maxEntries); | ||
▲ Show 20 Lines • Show All 166 Lines • Show Last 20 Lines |