2015-06-04 01:29:22 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* Copyright (C) 2010 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/>.*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2017-09-10 20:12:52 +01:00
|
|
|
#if !defined(KPMCORE_PARTITIONALIGNMENT_H)
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2017-09-10 20:12:52 +01:00
|
|
|
#define KPMCORE_PARTITIONALIGNMENT_H
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2016-04-18 17:14:31 +01:00
|
|
|
#include "QtGlobal"
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2016-05-06 22:36:24 +01:00
|
|
|
#include "util/libpartitionmanagerexport.h"
|
2015-06-04 01:29:22 +01:00
|
|
|
|
|
|
|
class Device;
|
|
|
|
class Partition;
|
|
|
|
|
|
|
|
class LIBKPMCORE_EXPORT PartitionAlignment
|
|
|
|
{
|
2015-07-13 15:16:36 +01:00
|
|
|
private:
|
|
|
|
PartitionAlignment();
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
public:
|
2015-07-15 17:33:35 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
static bool isAligned(const Device& d, const Partition& p, bool quiet = false);
|
|
|
|
static bool isAligned(const Device& d, const Partition& p, qint64 newFirst, qint64 newLast, bool quiet);
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
static qint64 alignedFirstSector(const Device& d, const Partition& p, qint64 s, qint64 min_first, qint64 max_first, qint64 min_length, qint64 max_length);
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
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);
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
static qint64 sectorAlignment(const Device& d);
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-15 17:33:35 +01:00
|
|
|
/** Sets the sector alignment multiplier for ALL devices henceforth except
|
|
|
|
* for devices that have a disklabel which aligns to cylinder boundaries.
|
|
|
|
* The default is 2048.
|
|
|
|
* This should probably be only set once on startup if necessary and not
|
|
|
|
* changed afterwards.
|
|
|
|
*/
|
|
|
|
static void setSectorAlignment( int sectorAlignment );
|
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
static qint64 firstDelta(const Device& d, const Partition& p, qint64 s);
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
static qint64 lastDelta(const Device& d, const Partition& p, qint64 s);
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
static bool isLengthAligned(const Device& d, const Partition& p);
|
2015-07-15 17:33:35 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
static int s_sectorAlignment;
|
2015-06-04 01:29:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|