/* SPDX-FileCopyrightText: 2010-2011 Volker Lanz SPDX-FileCopyrightText: 2014-2018 Andrius Štikonas SPDX-FileCopyrightText: 2015 Teo Mrnjavac SPDX-FileCopyrightText: 2015 Chris Campbell SPDX-FileCopyrightText: 2020 Gaël PORTAY SPDX-License-Identifier: GPL-3.0-or-later */ #ifndef KPMCORE_COREBACKENDPARTITIONTABLE_H #define KPMCORE_COREBACKENDPARTITIONTABLE_H #include "core/partitiontable.h" #include "fs/filesystem.h" #include class CoreBackendPartition; class Report; class Partition; /** * Interface class to represent a partition table in the backend. * @author Volker Lanz */ class CoreBackendPartitionTable { public: virtual ~CoreBackendPartitionTable() {} public: /** * Open the partition table * @return true on success */ virtual bool open() = 0; /** * Commit changes to the partition table to disk and to the OS. * @param timeout timeout in seconds to wait for the commit to succeed * @return true on success */ virtual bool commit(quint32 timeout = 10) = 0; /** * Delete a partition. * @param report the report to write information to * @param partition the Partition to delete * @return true on success */ virtual bool deletePartition(Report& report, const Partition& partition) = 0; /** * Delete a file system on disk so it cannot be detected anymore. * @param report the report to write information to * @param partition the Partition for which to clobber the file system * @return true on success */ virtual bool clobberFileSystem(Report& report, const Partition& partition) = 0; /** * Resize a file system to a new length. * @param report the report to write information to * @param partition the partition the FileSystem to resize is on * @param newLength the new length for the FileSystem in sectors * @return true on success */ virtual bool resizeFileSystem(Report& report, const Partition& partition, qint64 newLength) = 0; /** * Detect which FileSystem is present at a given start sector. * @param report the report to write information to * @param device the Device on which the FileSystem resides * @param sector the sector where to look for a FileSystem * @return the detected FileSystem::Type */ virtual FileSystem::Type detectFileSystemBySector(Report& report, const Device& device, qint64 sector) = 0; /** * Create a new partition. * @param report the report to write information to * @param partition the new partition to create on disk * @return the new number the OS sees the partition under (e.g. 7 for "/dev/sda7") or -1 on failure */ virtual QString createPartition(Report& report, const Partition& partition) = 0; /** * Update the geometry for a partition in the partition table. * @param report the report to write information to * @param partition the partition to update the geometry for * @param sector_start the new start sector for the partition * @param sector_end the new last sector for the partition * @return true on success */ virtual bool updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end) = 0; /** * Get the UUID of a partition in the partition table (GPT only). * The partition UUID is known as PARTUUID by several utilities. The device-manager links * the device under /dev/disk/by-partuuid/. * @param report the report to write information to * @param partition the partition to get the UUID for * @return the partition UUID */ virtual QString getPartitionUUID(Report& report, const Partition& partition) = 0; /** * Set the label of a partition in the partition table (GPT only). * The label is set in the GPT partition name entry. The partition name is known as PARTLABEL by * several utilities. The device-manager links the device under /dev/disk/by-partlabel/