remove all traces of libparted from the main binary and lib
svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1097708
This commit is contained in:
parent
2f2a8589f2
commit
1e2a852df9
3
TODO
3
TODO
|
@ -19,4 +19,5 @@ Random plans and ideas for 1.1 and beyond:
|
|||
|
||||
|
||||
Bugs:
|
||||
|
||||
* creating a partition table on a device that doesn't have one crashes
|
||||
somewhere in the createpartitiontable op
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
|
||||
#include "backend/corebackend.h"
|
||||
|
||||
#include "core/device.h"
|
||||
#include "core/partitiontable.h"
|
||||
|
||||
#include <kpluginfactory.h>
|
||||
#include <kpluginloader.h>
|
||||
#include <kdebug.h>
|
||||
|
@ -52,3 +55,14 @@ void CoreBackend::emitProgress(int i)
|
|||
{
|
||||
emit progress(i);
|
||||
}
|
||||
|
||||
void CoreBackend::setPartitionTableForDevice(Device& d, PartitionTable* p)
|
||||
{
|
||||
d.setPartitionTable(p);
|
||||
}
|
||||
|
||||
void CoreBackend::setPartitionTableMaxPrimaries(PartitionTable& p, qint32 max_primaries)
|
||||
{
|
||||
p.setMaxPrimaries(max_primaries);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
class CoreBackendDevice;
|
||||
class Device;
|
||||
class PartitionTable;
|
||||
|
||||
class QString;
|
||||
|
||||
class LIBPARTITIONMANAGERPRIVATE_EXPORT CoreBackend : public QObject
|
||||
|
@ -43,18 +45,17 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT CoreBackend : public QObject
|
|||
|
||||
public:
|
||||
static CoreBackend* self();
|
||||
|
||||
virtual CoreBackendDevice* openDevice(const QString& device_node) = 0;
|
||||
virtual CoreBackendDevice* openDeviceExclusive(const QString& device_node) = 0;
|
||||
|
||||
virtual bool closeDevice(CoreBackendDevice* core_device) = 0;
|
||||
|
||||
virtual QString about() const = 0;
|
||||
|
||||
void emitProgress(int i);
|
||||
|
||||
public:
|
||||
virtual Device* scanDevice(const QString& device_node) = 0;
|
||||
virtual CoreBackendDevice* openDevice(const QString& device_node) = 0;
|
||||
virtual CoreBackendDevice* openDeviceExclusive(const QString& device_node) = 0;
|
||||
virtual bool closeDevice(CoreBackendDevice* core_device) = 0;
|
||||
virtual void emitProgress(int i);
|
||||
|
||||
protected:
|
||||
static void setPartitionTableForDevice(Device& d, PartitionTable* p);
|
||||
static void setPartitionTableMaxPrimaries(PartitionTable& p, qint32 max_primaries);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include <kpluginfactory.h>
|
||||
|
||||
K_PLUGIN_FACTORY(DummyBackendFactory, registerPlugin<DummyBackend>(); )
|
||||
K_EXPORT_PLUGIN(DummyBackendFactory("pluginpmlibparted"))
|
||||
K_EXPORT_PLUGIN(DummyBackendFactory("pluginpmdummy"))
|
||||
|
||||
|
||||
DummyBackend::DummyBackend(QObject*, const QList<QVariant>&) :
|
||||
|
@ -53,8 +53,8 @@ QString DummyBackend::about() const
|
|||
Device* DummyBackend::scanDevice(const QString& device_node)
|
||||
{
|
||||
Device* d = new Device("Dummy Device", QString("/tmp" + device_node), 255, 0xffff, 63, 512);
|
||||
d->setPartitionTable(new PartitionTable(PartitionTable::msdos_sectorbased, 2048, d->totalSectors() - 2048));
|
||||
d->partitionTable()->setMaxPrimaries(128);
|
||||
CoreBackend::setPartitionTableForDevice(*d, new PartitionTable(PartitionTable::msdos_sectorbased, 2048, d->totalSectors() - 2048));
|
||||
CoreBackend::setPartitionTableMaxPrimaries(*d->partitionTable(), 128);
|
||||
d->partitionTable()->updateUnallocated(*d);
|
||||
return d;
|
||||
}
|
||||
|
|
|
@ -366,8 +366,8 @@ Device* LibPartedBackend::scanDevice(const QString& device_node)
|
|||
if (pedDisk)
|
||||
{
|
||||
const PartitionTable::TableType type = PartitionTable::nameToTableType(pedDisk->type->name);
|
||||
d->setPartitionTable(new PartitionTable(type, firstUsableSector(*d), lastUsableSector(*d)));
|
||||
d->partitionTable()->setMaxPrimaries(ped_disk_get_max_primary_partition_count(pedDisk));
|
||||
CoreBackend::setPartitionTableForDevice(*d, new PartitionTable(type, firstUsableSector(*d), lastUsableSector(*d)));
|
||||
CoreBackend::setPartitionTableMaxPrimaries(*d->partitionTable(), ped_disk_get_max_primary_partition_count(pedDisk));
|
||||
|
||||
scanDevicePartitions(pedDevice, *d, pedDisk);
|
||||
}
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
|
||||
class PartitionTable;
|
||||
class CreatePartitionTableOperation;
|
||||
class LibPartedBackend;
|
||||
class DummyBackend;
|
||||
class CoreBackend;
|
||||
|
||||
/** @brief A device.
|
||||
|
||||
|
@ -38,7 +37,7 @@ class DummyBackend;
|
|||
|
||||
Devices are the outermost entity; they contain a PartitionTable that itself contains Partitions.
|
||||
|
||||
@see PartitionTable, Partition, LibParted::scanDevices()
|
||||
@see PartitionTable, Partition
|
||||
@author vl@fidra.de
|
||||
*/
|
||||
class LIBPARTITIONMANAGERPRIVATE_EXPORT Device : public QObject
|
||||
|
@ -47,8 +46,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT Device : public QObject
|
|||
Q_DISABLE_COPY(Device)
|
||||
|
||||
friend class CreatePartitionTableOperation;
|
||||
friend class LibPartedBackend;
|
||||
friend class DummyBackend;
|
||||
friend class CoreBackend;
|
||||
|
||||
public:
|
||||
Device(const QString& name, const QString& devicenode, qint32 heads, qint32 numSectors, qint32 cylinders, qint64 sectorSize, const QString& iconname = QString());
|
||||
|
|
|
@ -41,10 +41,10 @@
|
|||
@param sectorStart the first sector of the Partition on its Device
|
||||
@param sectorEnd the last sector of the Partition on its Device
|
||||
@param number the Partition's device number, e.g. 7 for /dev/sdd7
|
||||
@param availableFlags the flags available for this Partition according to libparted
|
||||
@param availableFlags the flags available for this Partition
|
||||
@param mountPoints string list of mount points found for this Partition
|
||||
@param mounted true if the Partition is mounted
|
||||
@param activeFlags active flags for this Partition according to libparted
|
||||
@param activeFlags active flags for this Partition
|
||||
@param state the Partition's state
|
||||
*/
|
||||
Partition::Partition(PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem* fs, qint64 sectorStart, qint64 sectorEnd, qint32 number, PartitionTable::Flags availableFlags, const QStringList& mountPoints, bool mounted, PartitionTable::Flags activeFlags, State state) :
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
class Device;
|
||||
class OperationStack;
|
||||
class LibPartedPartitionTable;
|
||||
class CoreBackendPartitionTable;
|
||||
|
||||
class PartResizerWidget;
|
||||
class InsertDialog;
|
||||
|
@ -74,7 +74,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT Partition : public PartitionNode
|
|||
friend class OperationStack;
|
||||
friend class Device;
|
||||
friend class PartitionNode;
|
||||
friend class LibPartedPartitionTable;
|
||||
friend class CoreBackendPartitionTable;
|
||||
|
||||
friend class PartResizerWidget;
|
||||
friend class InsertDialog;
|
||||
|
|
|
@ -584,7 +584,7 @@ qint64 PartitionTable::defaultLastUsable(const Device& d, TableType t)
|
|||
|
||||
static struct
|
||||
{
|
||||
const char* name; /**< name of partition table type in libparted */
|
||||
const char* name; /**< name of partition table type */
|
||||
quint32 maxPrimaries; /**< max numbers of primary partitions supported */
|
||||
bool canHaveExtended; /**< does partition table type support extended partitions */
|
||||
bool isReadOnly; /**< does KDE Partition Manager support this only in read only mode */
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
|
||||
class Device;
|
||||
class Partition;
|
||||
class LibPartedBackend;
|
||||
class DummyBackend; // TODO: this is nonsense. also see Device
|
||||
class CoreBackend;
|
||||
|
||||
/** @brief The partition table (a.k.a Disk Label)
|
||||
|
||||
|
@ -46,8 +45,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT PartitionTable : public PartitionNode
|
|||
{
|
||||
Q_DISABLE_COPY(PartitionTable)
|
||||
|
||||
friend class LibPartedBackend;
|
||||
friend class DummyBackend;
|
||||
friend class CoreBackend;
|
||||
|
||||
public:
|
||||
enum TableType
|
||||
|
@ -68,7 +66,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT PartitionTable : public PartitionNode
|
|||
sun
|
||||
};
|
||||
|
||||
/** Partition flags as defined by libparted */
|
||||
/** Partition flags */
|
||||
enum Flag
|
||||
{
|
||||
FlagNone = 0,
|
||||
|
@ -117,7 +115,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT PartitionTable : public PartitionNode
|
|||
int maxPrimaries() const { return m_MaxPrimaries; } /**< @return max number of primary partitions this PartitionTable can handle */
|
||||
|
||||
PartitionTable::TableType type() const { return m_Type; } /**< @return the PartitionTable's type */
|
||||
const QString typeName() const { return tableTypeToName(type()); } /**< @return the name of this PartitionTable type according to libparted */
|
||||
const QString typeName() const { return tableTypeToName(type()); } /**< @return the name of this PartitionTable type */
|
||||
|
||||
qint64 firstUsable() const { return m_FirstUsable; }
|
||||
qint64 lastUsable() const { return m_LastUsable; }
|
||||
|
|
|
@ -54,7 +54,7 @@ bool MoveFileSystemJob::run(Report& parent)
|
|||
Report* report = jobStarted(parent);
|
||||
|
||||
// A scope for moveSource and moveTarget, so CopyTargetDevice's dtor runs before we
|
||||
// say we're finished: The CopyTargetDevice dtor asks libparted to close the device
|
||||
// say we're finished: The CopyTargetDevice dtor asks the backend to close the device
|
||||
// and that may take a while.
|
||||
{
|
||||
CopySourceDevice moveSource(device(), partition().fileSystem().firstSector(), partition().fileSystem().lastSector());
|
||||
|
|
|
@ -85,7 +85,7 @@ bool ResizeFileSystemJob::run(Report& parent)
|
|||
case FileSystem::cmdSupportCore:
|
||||
{
|
||||
Report* childReport = report->newChild();
|
||||
childReport->line() << i18nc("@info/plain", "Resizing a %1 file system using LibParted internal functions.", partition().fileSystem().name());
|
||||
childReport->line() << i18nc("@info/plain", "Resizing a %1 file system using internal backend functions.", partition().fileSystem().name());
|
||||
rval = resizeFileSystemInternal(*childReport);
|
||||
break;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ bool ResizeFileSystemJob::resizeFileSystemInternal(Report& report)
|
|||
|
||||
if (rval)
|
||||
{
|
||||
report.line() << i18nc("@info/plain", "Successfully resized file system using LibParted.");
|
||||
report.line() << i18nc("@info/plain", "Successfully resized file system using internal backend functions.");
|
||||
backendPartitionTable->commit();
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ ResizeOperation::ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint6
|
|||
m_CheckResizedJob(NULL)
|
||||
{
|
||||
addJob(checkOriginalJob());
|
||||
|
||||
|
||||
if (partition().roles().has(PartitionRole::Extended))
|
||||
{
|
||||
m_MoveExtendedJob = new SetPartGeometryJob(targetDevice(), partition(), newFirstSector(), newLength());
|
||||
|
@ -85,7 +85,7 @@ ResizeOperation::ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint6
|
|||
// At this point, we need to set the partition's length to either the resized length, if it has already been
|
||||
// shrunk, or to the original length (it may or may not then later be grown, we don't care here)
|
||||
const qint64 currentLength = (resizeAction() & Shrink) ? newLength() : partition().length();
|
||||
|
||||
|
||||
m_MoveSetGeomJob = new SetPartGeometryJob(targetDevice(), partition(), newFirstSector(), currentLength);
|
||||
m_MoveFileSystemJob = new MoveFileSystemJob(targetDevice(), partition(), newFirstSector());
|
||||
|
||||
|
@ -101,7 +101,7 @@ ResizeOperation::ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint6
|
|||
addJob(growSetGeomJob());
|
||||
addJob(growResizeJob());
|
||||
}
|
||||
|
||||
|
||||
m_CheckResizedJob = new CheckFileSystemJob(partition());
|
||||
|
||||
addJob(checkResizedJob());
|
||||
|
@ -118,12 +118,12 @@ void ResizeOperation::preview()
|
|||
partition().setFirstSector(origFirstSector());
|
||||
partition().setLastSector(origLastSector());
|
||||
}
|
||||
|
||||
|
||||
removePreviewPartition(targetDevice(), partition());
|
||||
|
||||
|
||||
partition().setFirstSector(newFirstSector());
|
||||
partition().setLastSector(newLastSector());
|
||||
|
||||
|
||||
insertPreviewPartition(targetDevice(), partition());
|
||||
}
|
||||
|
||||
|
@ -146,7 +146,7 @@ bool ResizeOperation::execute(Report& parent)
|
|||
// Extended partitions are a special case: They don't have any file systems and so there's no
|
||||
// need to move, shrink or grow their contents before setting the new geometry. In fact, trying
|
||||
// to first shrink THEN move would not work for an extended partition that has children, because
|
||||
// they might temporarily be outside the extended partition and libparted would not let us do that.
|
||||
// they might temporarily be outside the extended partition and the backend would not let us do that.
|
||||
if (moveExtendedJob())
|
||||
{
|
||||
if (!(rval = moveExtendedJob()->run(*report)))
|
||||
|
@ -156,7 +156,7 @@ bool ResizeOperation::execute(Report& parent)
|
|||
{
|
||||
// We run all three methods. Any of them returns true if it has nothing to do.
|
||||
rval = shrink(*report) && move(*report) && grow(*report);
|
||||
|
||||
|
||||
if (rval)
|
||||
{
|
||||
if (!(rval = checkResizedJob()->run(*report)))
|
||||
|
@ -170,9 +170,9 @@ bool ResizeOperation::execute(Report& parent)
|
|||
report->line() << i18nc("@info/plain", "Checking partition <filename>%1</filename> before resize/move failed.", partition().deviceNode());
|
||||
|
||||
setStatus(rval ? StatusFinishedSuccess : StatusError);
|
||||
|
||||
|
||||
report->setStatus(i18nc("@info/plain status (success, error, warning...) of operation", "%1: %2", description(), statusText()));
|
||||
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ bool ResizeOperation::shrink(Report& report)
|
|||
{
|
||||
report.line() << i18nc("@info/plain", "Resize/move failed: Could not shrink partition <filename>%1</filename>.", partition().deviceNode());
|
||||
return false;
|
||||
|
||||
|
||||
/** @todo if this fails, no one undoes the shrinking of the file system above, because we
|
||||
rely upon there being a maximize job at the end, but that's no longer the case. */
|
||||
}
|
||||
|
@ -276,9 +276,9 @@ bool ResizeOperation::move(Report& report)
|
|||
{
|
||||
// We must make sure not to overwrite the partition's metadata if it's a logical partition
|
||||
// and we're moving to the left. The easiest way to achieve this is to move the
|
||||
// partition itself first (libparted will then move the metadata) and only afterwards
|
||||
// copy the filesystem. Disadvantage: We need to move the partition back to its
|
||||
// original position if copyBlocks fails.
|
||||
// partition itself first (it's the backend's responsibility to then move the metadata) and
|
||||
// only afterwards copy the filesystem. Disadvantage: We need to move the partition
|
||||
// back to its original position if copyBlocks fails.
|
||||
const qint64 oldStart = partition().firstSector();
|
||||
if (moveSetGeomJob() && !moveSetGeomJob()->run(report))
|
||||
{
|
||||
|
@ -303,7 +303,7 @@ bool ResizeOperation::move(Report& report)
|
|||
bool ResizeOperation::grow(Report& report)
|
||||
{
|
||||
const qint64 oldLength = partition().length();
|
||||
|
||||
|
||||
if (growSetGeomJob() && !growSetGeomJob()->run(report))
|
||||
{
|
||||
report.line() << i18nc("@info/plain", "Resize/move failed: Could not grow partition <filename>%1</filename>.", partition().deviceNode());
|
||||
|
@ -313,10 +313,10 @@ bool ResizeOperation::grow(Report& report)
|
|||
if (growResizeJob() && !growResizeJob()->run(report))
|
||||
{
|
||||
report.line() << i18nc("@info/plain", "Resize/move failed: Could not resize the file system on partition <filename>%1</filename>", partition().deviceNode());
|
||||
|
||||
|
||||
if (!SetPartGeometryJob(targetDevice(), partition(), partition().firstSector(), oldLength).run(report))
|
||||
report.line() << i18nc("@info/plain", "Could not restore old partition size for partition <filename>%1</filename>.", partition().deviceNode());
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ bool ResizeOperation::canGrow(const Partition* p)
|
|||
{
|
||||
if (p == NULL)
|
||||
return false;
|
||||
|
||||
|
||||
// we can always grow, shrink or move a partition not yet written to disk
|
||||
if (p->state() == Partition::StateNew)
|
||||
return true;
|
||||
|
@ -350,7 +350,7 @@ bool ResizeOperation::canShrink(const Partition* p)
|
|||
{
|
||||
if (p == NULL)
|
||||
return false;
|
||||
|
||||
|
||||
// we can always grow, shrink or move a partition not yet written to disk
|
||||
if (p->state() == Partition::StateNew)
|
||||
return true;
|
||||
|
@ -372,7 +372,7 @@ bool ResizeOperation::canMove(const Partition* p)
|
|||
{
|
||||
if (p == NULL)
|
||||
return false;
|
||||
|
||||
|
||||
// we can always grow, shrink or move a partition not yet written to disk
|
||||
if (p->state() == Partition::StateNew)
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue