2015-06-04 01:29:22 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* Copyright (C) 2010, 2012 by Volker Lanz <vl@fidra.de> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "plugins/dummy/dummypartitiontable.h"
|
|
|
|
#include "plugins/dummy/dummybackend.h"
|
|
|
|
|
|
|
|
#include "core/partition.h"
|
|
|
|
#include "core/device.h"
|
|
|
|
|
|
|
|
#include "fs/filesystem.h"
|
|
|
|
|
|
|
|
#include "util/report.h"
|
|
|
|
|
|
|
|
DummyPartitionTable::DummyPartitionTable() :
|
2015-07-13 15:16:36 +01:00
|
|
|
CoreBackendPartitionTable()
|
2015-06-04 01:29:22 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DummyPartitionTable::~DummyPartitionTable()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DummyPartitionTable::open()
|
|
|
|
{
|
2015-07-13 15:16:36 +01:00
|
|
|
return true;
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DummyPartitionTable::commit(quint32 timeout)
|
|
|
|
{
|
2017-11-07 22:55:28 +00:00
|
|
|
Q_UNUSED(timeout)
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
return true;
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
QString DummyPartitionTable::createPartition(Report& report, const Partition& partition)
|
|
|
|
{
|
2017-11-07 22:55:28 +00:00
|
|
|
Q_UNUSED(report)
|
|
|
|
Q_UNUSED(partition)
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
return QStringLiteral("dummy");
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DummyPartitionTable::deletePartition(Report& report, const Partition& partition)
|
|
|
|
{
|
2017-11-07 22:55:28 +00:00
|
|
|
Q_UNUSED(report)
|
|
|
|
Q_UNUSED(partition)
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
return true;
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DummyPartitionTable::updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end)
|
|
|
|
{
|
2017-11-07 22:55:28 +00:00
|
|
|
Q_UNUSED(report)
|
|
|
|
Q_UNUSED(partition)
|
|
|
|
Q_UNUSED(sector_start)
|
|
|
|
Q_UNUSED(sector_end)
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
return true;
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DummyPartitionTable::clobberFileSystem(Report& report, const Partition& partition)
|
|
|
|
{
|
2017-11-07 22:55:28 +00:00
|
|
|
Q_UNUSED(report)
|
|
|
|
Q_UNUSED(partition)
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
return true;
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DummyPartitionTable::resizeFileSystem(Report& report, const Partition& partition, qint64 newLength)
|
|
|
|
{
|
2017-11-07 22:55:28 +00:00
|
|
|
Q_UNUSED(report)
|
|
|
|
Q_UNUSED(partition)
|
|
|
|
Q_UNUSED(newLength)
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
return true;
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
FileSystem::Type DummyPartitionTable::detectFileSystemBySector(Report& report, const Device& device, qint64 sector)
|
|
|
|
{
|
2017-11-07 22:55:28 +00:00
|
|
|
Q_UNUSED(report)
|
|
|
|
Q_UNUSED(device)
|
|
|
|
Q_UNUSED(sector)
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2018-04-07 19:54:30 +01:00
|
|
|
FileSystem::Type rval = FileSystem::Type::Unknown;
|
2015-07-13 15:16:36 +01:00
|
|
|
return rval;
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DummyPartitionTable::setPartitionSystemType(Report& report, const Partition& partition)
|
|
|
|
{
|
2017-11-07 22:55:28 +00:00
|
|
|
Q_UNUSED(report)
|
|
|
|
Q_UNUSED(partition)
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-03-18 18:24:27 +00:00
|
|
|
bool DummyPartitionTable::setPartitionLabel(Report& report, const Partition& partition, const QString& label)
|
|
|
|
{
|
|
|
|
Q_UNUSED(report)
|
|
|
|
Q_UNUSED(partition)
|
|
|
|
Q_UNUSED(label)
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-05-15 16:22:57 +01:00
|
|
|
QString DummyPartitionTable::getPartitionUUID(Report& report, const Partition& partition)
|
|
|
|
{
|
|
|
|
Q_UNUSED(report)
|
|
|
|
Q_UNUSED(partition)
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
bool DummyPartitionTable::setPartitionUUID(Report& report, const Partition& partition, const QString& uuid)
|
|
|
|
{
|
|
|
|
Q_UNUSED(report)
|
|
|
|
Q_UNUSED(partition)
|
|
|
|
Q_UNUSED(uuid)
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Add new job to set the GPT partition attributes
The GPT partition layout supports partition attributes.
The CLI sfdisk sets the partition attributes using the option
--part-attrs. 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 --part-attrs disk.img 1 RequiredPartition,NoBlockIOProtocol,LegacyBIOSBootable,48
(...)
$ sfdisk --part-attrs disk.img 2 60,61,62,63
(...)
$ sfdisk --dump disk.img
(...)
disk.img1 : start= 2048, size= 131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=BBE806BB-8567-A843-9FF5-9B6B35D2908E, attrs="RequiredPartition NoBlockIOProtocol LegacyBIOSBootable GUID:48"
disk.img2 : start= 133120, size= 1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=7DB39F08-C138-664B-B38E-ED2DEB549AA6, attrs="GUID:60,61,62,63"
This commit introduces the new job set-partition-attributes that is used
in the new-operation to set the attributes of the partition. The job
uses the newly introduced method setPartitionAttributes that is
implemented by the sfdisk and dummy backends.
Note: This is a copypaste of what was done for GPT partition label in
commit f585f6c (Add new job to set the GPT partition label) and GPT
partition UUID in commit 1dde035 (Add new job to set the GPT partition
UUID).
Note: RequiredPartition, NoBlockIOProtocol, LegacyBIOSBootable are
key words for 0, 1 and 2.
2020-05-15 17:24:06 +01:00
|
|
|
bool DummyPartitionTable::setPartitionAttributes(Report& report, const Partition& partition, quint64 attrs)
|
|
|
|
{
|
|
|
|
Q_UNUSED(report)
|
|
|
|
Q_UNUSED(partition)
|
|
|
|
Q_UNUSED(attrs)
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-07 22:55:28 +00:00
|
|
|
bool DummyPartitionTable::setFlag(Report& report, const Partition& partition, PartitionTable::Flag partitionManagerFlag, bool state)
|
|
|
|
{
|
|
|
|
Q_UNUSED(report)
|
|
|
|
Q_UNUSED(partition)
|
|
|
|
Q_UNUSED(partitionManagerFlag)
|
|
|
|
Q_UNUSED(state)
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
return true;
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|