File indexing completed on 2024-04-28 05:45:46
0001 /* 0002 SPDX-FileCopyrightText: 2010 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2016 Andrius Štikonas <andrius@stikonas.eu> 0004 SPDX-FileCopyrightText: 2015-2015 Teo Mrnjavac <teo@kde.org> 0005 SPDX-FileCopyrightText: 2015 Chris Campbell <c.j.campbell@ed.ac.uk> 0006 0007 SPDX-License-Identifier: GPL-3.0-or-later 0008 */ 0009 0010 #ifndef KPMCORE_PARTITIONALIGNMENT_H 0011 #define KPMCORE_PARTITIONALIGNMENT_H 0012 0013 #include "QtGlobal" 0014 0015 #include "util/libpartitionmanagerexport.h" 0016 0017 class Device; 0018 class Partition; 0019 0020 class LIBKPMCORE_EXPORT PartitionAlignment 0021 { 0022 private: 0023 PartitionAlignment(); 0024 0025 public: 0026 0027 static bool isAligned(const Device& d, const Partition& p, bool quiet = false); 0028 static bool isAligned(const Device& d, const Partition& p, qint64 newFirst, qint64 newLast, bool quiet); 0029 0030 static qint64 alignedFirstSector(const Device& d, const Partition& p, qint64 s, qint64 min_first, qint64 max_first, qint64 min_length, qint64 max_length); 0031 0032 static qint64 alignedLastSector(const Device& d, const Partition& p, qint64 s, qint64 min_last, qint64 max_last, qint64 min_length, qint64 max_length, qint64 original_length = -1, bool original_aligned = false); 0033 0034 static qint64 sectorAlignment(const Device& d); 0035 0036 /** Sets the sector alignment multiplier for ALL devices henceforth except 0037 * for devices that have a disklabel which aligns to cylinder boundaries. 0038 * The default is 2048. 0039 * This should probably be only set once on startup if necessary and not 0040 * changed afterwards. 0041 */ 0042 static void setSectorAlignment( int sectorAlignment ); 0043 0044 static qint64 firstDelta(const Device& d, const Partition& p, qint64 s); 0045 0046 static qint64 lastDelta(const Device& d, const Partition& p, qint64 s); 0047 0048 static bool isLengthAligned(const Device& d, const Partition& p); 0049 0050 private: 0051 static int s_sectorAlignment; 0052 }; 0053 0054 #endif