diff --git a/TODO b/TODO index 1622aca..eeeb7a3 100644 --- a/TODO +++ b/TODO @@ -12,9 +12,6 @@ Bugs to fix for 1.1: * why does CoreBackendPartitionTable::detectFileSystemBySector() take a Device and not a CoreBackendDevice? -* why can't CoreBackendPartitionTable::createPartition() return an int and use 0 - or -1 as error code and otherwise return the new number? - =============================================================================== For releases after 1.1: diff --git a/src/backend/corebackendpartitiontable.h b/src/backend/corebackendpartitiontable.h index 552537b..5bc6082 100644 --- a/src/backend/corebackendpartitiontable.h +++ b/src/backend/corebackendpartitiontable.h @@ -104,11 +104,9 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT CoreBackendPartitionTable * Create a new partition. * @param report the report to write information to * @param partition the new partition to create on disk - * @param new_number output value holding the new number the OS sees the partition under - * (e.g. 7 for "/dev/sda7") - * @return true on success + * @return the new number the OS sees the partition under (e.g. 7 for "/dev/sda7") or -1 on failure */ - virtual bool createPartition(Report& report, const Partition& partition, quint32& new_number) = 0; + virtual qint32 createPartition(Report& report, const Partition& partition) = 0; /** * Update the geometry for a partition in the partition table. diff --git a/src/jobs/createpartitionjob.cpp b/src/jobs/createpartitionjob.cpp index e585cf7..7fb620b 100644 --- a/src/jobs/createpartitionjob.cpp +++ b/src/jobs/createpartitionjob.cpp @@ -58,11 +58,11 @@ bool CreatePartitionJob::run(Report& parent) if (backendPartitionTable) { - quint32 num = -1; - rval = backendPartitionTable->createPartition(*report, partition(), num); + qint32 num = backendPartitionTable->createPartition(*report, partition()); - if (rval) + if (num > 0) { + rval = true; partition().setNumber(num); partition().setState(Partition::StateNone); backendPartitionTable->commit(); diff --git a/src/plugins/dummy/dummypartitiontable.cpp b/src/plugins/dummy/dummypartitiontable.cpp index 4a67998..b06186a 100644 --- a/src/plugins/dummy/dummypartitiontable.cpp +++ b/src/plugins/dummy/dummypartitiontable.cpp @@ -67,11 +67,10 @@ CoreBackendPartition* DummyPartitionTable::getPartitionBySector(qint64 sector) return new DummyPartition(); } -bool DummyPartitionTable::createPartition(Report& report, const Partition& partition, quint32& new_number) +qint32 DummyPartitionTable::createPartition(Report& report, const Partition& partition) { Q_UNUSED(report); Q_UNUSED(partition); - Q_UNUSED(new_number); return true; } diff --git a/src/plugins/dummy/dummypartitiontable.h b/src/plugins/dummy/dummypartitiontable.h index 6e08a2b..0205c5a 100644 --- a/src/plugins/dummy/dummypartitiontable.h +++ b/src/plugins/dummy/dummypartitiontable.h @@ -45,7 +45,7 @@ class DummyPartitionTable : public CoreBackendPartitionTable virtual CoreBackendPartition* getExtendedPartition(); virtual CoreBackendPartition* getPartitionBySector(qint64 sector); - virtual bool createPartition(Report& report, const Partition& partition, quint32& new_number); + virtual qint32 createPartition(Report& report, const Partition& partition); virtual bool deletePartition(Report& report, const Partition& partition); virtual bool updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end); virtual bool clobberFileSystem(Report& report, const Partition& partition); diff --git a/src/plugins/libparted/libpartedpartitiontable.cpp b/src/plugins/libparted/libpartedpartitiontable.cpp index 646365b..f433da9 100644 --- a/src/plugins/libparted/libpartedpartitiontable.cpp +++ b/src/plugins/libparted/libpartedpartitiontable.cpp @@ -144,11 +144,11 @@ static PedFileSystemType* getPedFileSystemType(FileSystem::Type t) return ped_file_system_type_get("ext2"); } -bool LibPartedPartitionTable::createPartition(Report& report, const Partition& partition, quint32& new_number) +qint32 LibPartedPartitionTable::createPartition(Report& report, const Partition& partition) { Q_ASSERT(partition.devicePath() == pedDevice()->path); - bool rval = false; + qint32 rval = -1; // According to libParted docs, PedPartitionType can be "NULL if unknown". That's obviously wrong, // it's a typedef for an enum. So let's use something the libparted devs will hopefully never @@ -187,14 +187,11 @@ bool LibPartedPartitionTable::createPartition(Report& report, const Partition& p if (pedConstraint == NULL) { report.line() << i18nc("@info/plain", "Failed to create a new partition: could not get geometry for constraint."); - return false; + return -1; } if (ped_disk_add_partition(pedDisk(), pedPartition, pedConstraint)) - { - new_number = pedPartition->num; - rval = true; - } + rval = pedPartition->num; else report.line() << i18nc("@info/plain", "Failed to add partition %1 to device %2.", partition.deviceNode(), pedDisk()->dev->path); diff --git a/src/plugins/libparted/libpartedpartitiontable.h b/src/plugins/libparted/libpartedpartitiontable.h index e9a229b..9d033d7 100644 --- a/src/plugins/libparted/libpartedpartitiontable.h +++ b/src/plugins/libparted/libpartedpartitiontable.h @@ -48,7 +48,7 @@ class LibPartedPartitionTable : public CoreBackendPartitionTable virtual CoreBackendPartition* getExtendedPartition(); virtual CoreBackendPartition* getPartitionBySector(qint64 sector); - virtual bool createPartition(Report& report, const Partition& partition, quint32& new_number); + virtual qint32 createPartition(Report& report, const Partition& partition); virtual bool deletePartition(Report& report, const Partition& partition); virtual bool updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end); virtual bool clobberFileSystem(Report& report, const Partition& partition);