2020-09-29 23:55:11 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2020 Gaël PORTAY <gael.portay@collabora.com>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
Add new job to set the GPT partition UUID
The GPT partition layout supports unique GUID partitions.
The CLI sfdisk sets the partition UUID using the option --part-uuid.
See the examples below:
$ cat <<EOF | sfdisk disk.img
label: gpt
type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, size=64M
type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
EOF
(...)
$ sfdisk --dump disk.img
(...)
disk.img1 : start= 2048, size= 131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=BBE806BB-8567-A843-9FF5-9B6B35D2908E
disk.img2 : start= 133120, size= 1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=7DB39F08-C138-664B-B38E-ED2DEB549AA6
$ sfdisk --part-uuid disk.img 1 00000000^C000-0000-0000-000000000000
(...)
$ sfdisk --part-uuid disk.img 2 11111111-1111-1111-1111-111111111111
(...)
$ sfdisk --dump disk.img
(...)
disk.img1 : start= 2048, size= 131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=00000000-0000-0000-0000-000000000000
disk.img2 : start= 133120, size= 1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=11111111-1111-1111-1111-111111111111
This commit introduces the new job set-partition-uuid that is used in
the new-operation to set the UUID of the partition. The job uses the
newly introduced method setPartitionUUID that is implemented by the
sfdisk and dummy backends.
Note: This is a copypaste of what was done for GTP partition label in
commit f585f6c (Add new job to set the GPT partition label).
2020-03-18 18:24:27 +00:00
|
|
|
|
|
|
|
|
2020-09-29 23:55:11 +01:00
|
|
|
#ifndef KPMCORE_SETPARTITIONUUIDJOB_H
|
Add new job to set the GPT partition UUID
The GPT partition layout supports unique GUID partitions.
The CLI sfdisk sets the partition UUID using the option --part-uuid.
See the examples below:
$ cat <<EOF | sfdisk disk.img
label: gpt
type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, size=64M
type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
EOF
(...)
$ sfdisk --dump disk.img
(...)
disk.img1 : start= 2048, size= 131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=BBE806BB-8567-A843-9FF5-9B6B35D2908E
disk.img2 : start= 133120, size= 1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=7DB39F08-C138-664B-B38E-ED2DEB549AA6
$ sfdisk --part-uuid disk.img 1 00000000^C000-0000-0000-000000000000
(...)
$ sfdisk --part-uuid disk.img 2 11111111-1111-1111-1111-111111111111
(...)
$ sfdisk --dump disk.img
(...)
disk.img1 : start= 2048, size= 131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=00000000-0000-0000-0000-000000000000
disk.img2 : start= 133120, size= 1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=11111111-1111-1111-1111-111111111111
This commit introduces the new job set-partition-uuid that is used in
the new-operation to set the UUID of the partition. The job uses the
newly introduced method setPartitionUUID that is implemented by the
sfdisk and dummy backends.
Note: This is a copypaste of what was done for GTP partition label in
commit f585f6c (Add new job to set the GPT partition label).
2020-03-18 18:24:27 +00:00
|
|
|
#define KPMCORE_SETPARTITIONUUIDJOB_H
|
|
|
|
|
|
|
|
#include "jobs/job.h"
|
|
|
|
|
|
|
|
class Partition;
|
|
|
|
class Device;
|
|
|
|
class Report;
|
|
|
|
|
|
|
|
class QString;
|
|
|
|
|
|
|
|
/** Set a Partition UUID (GPT only).
|
|
|
|
@author Gaël PORTAY <gael.portay@collabora.com>
|
|
|
|
*/
|
|
|
|
class SetPartitionUUIDJob : public Job
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SetPartitionUUIDJob(Device& d, Partition& p, const QString& newUUID);
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool run(Report& parent) override;
|
|
|
|
QString description() const override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Partition& partition() {
|
|
|
|
return m_Partition;
|
|
|
|
}
|
|
|
|
const Partition& partition() const {
|
|
|
|
return m_Partition;
|
|
|
|
}
|
|
|
|
|
|
|
|
Device& device() {
|
|
|
|
return m_Device;
|
|
|
|
}
|
|
|
|
const Device& device() const {
|
|
|
|
return m_Device;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString& uuid() const {
|
|
|
|
return m_UUID;
|
|
|
|
}
|
|
|
|
void setUUID(const QString& u) {
|
|
|
|
m_UUID = u;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Device& m_Device;
|
|
|
|
Partition& m_Partition;
|
|
|
|
QString m_UUID;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|