diff --git a/README.md b/README.md index 15e4127..9b16d66 100644 --- a/README.md +++ b/README.md @@ -1,104 +1,104 @@ # KPMcore > KPMcore, the KDE Partition Manager core, is a library for examining > and modifying partitions, disk devices, and filesystems on a > Linux system. It provides a unified programming interface over > top of (external) system-manipulation tools. KPMcore is a library for examining and manipulating all facets of storage devices on a system: * raw disk devices * partition tables on a device * filesystems within a partition There are multiple backends so that KPMcore can support different operating systems, although the only functional backend is the one for Linux systems: -* libparted backend (Linux) +* sfdisk backend (Linux) * null backend ## Using KPMcore Most of the usage information on KPMcore is included in the API documentation; this section contains only high-level usage information. ### Finding KPMcore with CMake KPMcore supports CMake as (meta-)build system and installs suitable CMake support files. Typical use of of KPMcore in a `CMakeLists.txt` looks like this: ``` find_package( KPMcore 3.2 REQUIRED ) include_directories( ${KPMCORE_INCLUDE_DIR} ) target_link_libraries( target kpmcore ) ``` There are no imported targets defined for KPMcore. ### Initialization An application must initialize the library and load a suitable backend before using KPMcore functions. By convention, the environment variable `KPMCORE_BACKEND` names a backend, and typical initialization code will look like this (or use the class `KPMCoreInitializer` from `test/helpers.h`): ``` #include #include bool initKPMcore() { static bool inited = false; if ( inited ) return true; QByteArray env = qgetenv( "KPMCORE_BACKEND" ); auto backendName = env.isEmpty() ? CoreBackendManager::defaultBackendName() : env; if ( !CoreBackendManager::self()->load( backendName ) { qWarning() << "Failed to load backend plugin" << backendName; return false; } inited = true; return true; } ``` This code uses the environment variable if set, and otherwise falls back to a default backend suitable for the current platform. Calling KPMcore functions before the library is initialized will result in undefined behavior. ### Devices After the backend is initialized you can scan for available devices. If you only want devices from the loaded backend you can call ``` QList devices = backend->scanDevices( excludeReadOnly ); ``` where `bool` option `excludeReadOnly` specifies whether to exclude read only devices. #### KPMcore device scanner Alternatively, you can use KPMcore device scanner ``` #include #include #include // First create operationStack with another QObject as parent, we will use nullptr here. OperationStack *operationStack = new OperationStack(nullptr); DeviceScanner *deviceScanner = new DeviceScanner(nullptr, *operationStack); deviceScanner->scan(); // use start() for scanning in the background thread QList devices = operationStack->previewDevices(); ``` Then `deviceScanner` scans for the devices in a background thread. After scanning is complete `DeviceScanner::finished()` signal will be emitted. Then the devices can accessed using `operationStack->previewDevices()`. diff --git a/src/fs/f2fs.h b/src/fs/f2fs.h index 280fe82..4d2d92b 100644 --- a/src/fs/f2fs.h +++ b/src/fs/f2fs.h @@ -1,120 +1,119 @@ /************************************************************************* * Copyright (C) 2016 by Andrius Štikonas * * * * 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 .* *************************************************************************/ -#if !defined(KPMCORE_F2FS_H) - +#ifndef KPMCORE_F2FS_H #define KPMCORE_F2FS_H #include "util/libpartitionmanagerexport.h" #include "fs/filesystem.h" #include class Report; class QString; namespace FS { /** A f2fs file system. @author Andrius Štikonas */ class LIBKPMCORE_EXPORT f2fs : public FileSystem { public: f2fs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label); public: void init() override; // qint64 readUsedCapacity(const QString& deviceNode) const override; bool check(Report& report, const QString& deviceNode) const override; bool create(Report& report, const QString& deviceNode) override; bool createWithLabel(Report& report, const QString& deviceNode, const QString& label) override; // qint64 readUsedCapacity(const QString& deviceNode) const override; bool resize(Report& report, const QString& deviceNode, qint64 length) const override; // bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; // bool updateUUID(Report& report, const QString& deviceNode) const override; CommandSupportType supportGetUsed() const override { return m_GetUsed; } CommandSupportType supportGetLabel() const override { return m_GetLabel; } CommandSupportType supportCreate() const override { return m_Create; } CommandSupportType supportCreateWithLabel() const override { return m_Create; } CommandSupportType supportGrow() const override { return m_Grow; } CommandSupportType supportShrink() const override { return m_Shrink; } CommandSupportType supportMove() const override { return m_Move; } CommandSupportType supportCheck() const override { return m_Check; } CommandSupportType supportCopy() const override { return m_Copy; } CommandSupportType supportBackup() const override { return m_Backup; } CommandSupportType supportSetLabel() const override { return m_SetLabel; } CommandSupportType supportUpdateUUID() const override { return m_UpdateUUID; } CommandSupportType supportGetUUID() const override { return m_GetUUID; } qint64 minCapacity() const override; qint64 maxCapacity() const override; int maxLabelLength() const override; SupportTool supportToolName() const override; bool supportToolFound() const override; public: static CommandSupportType m_GetUsed; static CommandSupportType m_GetLabel; static CommandSupportType m_Create; static CommandSupportType m_Grow; static CommandSupportType m_Shrink; static CommandSupportType m_Move; static CommandSupportType m_Check; static CommandSupportType m_Copy; static CommandSupportType m_Backup; static CommandSupportType m_SetLabel; static CommandSupportType m_UpdateUUID; static CommandSupportType m_GetUUID; private: static bool oldVersion; }; } #endif