Commit 559c326b authored by Andrius Štikonas's avatar Andrius Štikonas

Add detection support for Apple File System (APFS).

parent e749b01b
set(FS_SRC
fs/apfs.cpp
fs/bitlocker.cpp
fs/btrfs.cpp
fs/exfat.cpp
......@@ -36,6 +37,7 @@ set(FS_SRC
)
set(FS_LIB_HDRS
fs/apfs.h
fs/bitlocker.h
fs/btrfs.h
fs/exfat.h
......
/*************************************************************************
* Copyright (C) 2019 by Andrius Štikonas <stikonas@kde.org> *
* *
* 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 "fs/apfs.h"
namespace FS
{
FileSystem::CommandSupportType apfs::m_Move = FileSystem::cmdSupportCore;
FileSystem::CommandSupportType apfs::m_Copy = FileSystem::cmdSupportCore;
FileSystem::CommandSupportType apfs::m_Backup = FileSystem::cmdSupportCore;
apfs::apfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Apfs)
{
}
}
/*************************************************************************
* Copyright (C) 2019 by Andrius Štikonas <stikonas@kde.org> *
* *
* 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/>.*
*************************************************************************/
#ifndef KPMCORE_APFS_H
#define KPMCORE_APFS_H
#include "util/libpartitionmanagerexport.h"
#include "fs/filesystem.h"
#include <QtGlobal>
class QString;
namespace FS
{
/** An APFS file system.
@author Andrius Štikonas <stikonas@kde.org>
*/
class LIBKPMCORE_EXPORT apfs : public FileSystem
{
public:
apfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
public:
CommandSupportType supportMove() const override {
return m_Move;
}
CommandSupportType supportCopy() const override {
return m_Copy;
}
CommandSupportType supportBackup() const override {
return m_Backup;
}
bool supportToolFound() const override {
return true;
}
public:
static CommandSupportType m_Move;
static CommandSupportType m_Copy;
static CommandSupportType m_Backup;
};
}
#endif
......@@ -71,6 +71,7 @@ const std::vector<QColor> FileSystem::defaultColorCode =
QColor( 204,179,255 ), // fat12
QColor( 255,100,100 ), // linux_raid_member
QColor( 110,20,50 ), // bitlocker
QColor( 255,155,174 ), // apfs
}
};
......@@ -450,6 +451,7 @@ static const KLocalizedString* typeNames()
kxi18nc("@item filesystem name", "fat12"),
kxi18nc("@item filesystem name", "linux_raid_member"),
kxi18nc("@item filesystem name", "BitLocker"),
kxi18nc("@item filesystem name", "apfs"),
};
return s;
......
......@@ -93,6 +93,7 @@ public:
Fat12,
LinuxRaidMember,
BitLocker,
Apfs,
__lastType
};
......
......@@ -19,6 +19,7 @@
#include "fs/filesystemfactory.h"
#include "fs/filesystem.h"
#include "fs/apfs.h"
#include "fs/bitlocker.h"
#include "fs/btrfs.h"
#include "fs/exfat.h"
......@@ -63,6 +64,7 @@ void FileSystemFactory::init()
qDeleteAll(m_FileSystems);
m_FileSystems.clear();
m_FileSystems.insert(FileSystem::Type::Apfs, new FS::apfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::BitLocker, new FS::bitlocker(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Btrfs, new FS::btrfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Type::Exfat, new FS::exfat(-1, -1, -1, QString()));
......@@ -115,38 +117,39 @@ FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qi
FileSystem* fs = nullptr;
switch (t) {
case FileSystem::Type::BitLocker: fs = new FS::bitlocker(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Btrfs: fs = new FS::btrfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Exfat: fs = new FS::exfat(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ext2: fs = new FS::ext2(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ext3: fs = new FS::ext3(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ext4: fs = new FS::ext4(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Extended: fs = new FS::extended(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::F2fs: fs = new FS::f2fs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Fat12: fs = new FS::fat12(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Fat16: fs = new FS::fat16(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Fat32: fs = new FS::fat32(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Hfs: fs = new FS::hfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::HfsPlus: fs = new FS::hfsplus(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Hpfs: fs = new FS::hpfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Iso9660: fs = new FS::iso9660(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Jfs: fs = new FS::jfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Apfs: fs = new FS::apfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::BitLocker: fs = new FS::bitlocker (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Btrfs: fs = new FS::btrfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Exfat: fs = new FS::exfat (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ext2: fs = new FS::ext2 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ext3: fs = new FS::ext3 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ext4: fs = new FS::ext4 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Extended: fs = new FS::extended (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::F2fs: fs = new FS::f2fs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Fat12: fs = new FS::fat12 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Fat16: fs = new FS::fat16 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Fat32: fs = new FS::fat32 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Hfs: fs = new FS::hfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::HfsPlus: fs = new FS::hfsplus (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Hpfs: fs = new FS::hpfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Iso9660: fs = new FS::iso9660 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Jfs: fs = new FS::jfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::LinuxRaidMember: fs = new FS::linuxraidmember(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::LinuxSwap: fs = new FS::linuxswap(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Luks: fs = new FS::luks(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Luks2: fs = new FS::luks2(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Lvm2_PV: fs = new FS::lvm2_pv(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Nilfs2: fs = new FS::nilfs2(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ntfs: fs = new FS::ntfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ocfs2: fs = new FS::ocfs2(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::ReiserFS: fs = new FS::reiserfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Reiser4: fs = new FS::reiser4(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Udf: fs = new FS::udf(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ufs: fs = new FS::ufs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Unformatted: fs = new FS::unformatted(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Unknown: fs = new FS::unknown(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Xfs: fs = new FS::xfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Zfs: fs = new FS::zfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::LinuxSwap: fs = new FS::linuxswap (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Luks: fs = new FS::luks (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Luks2: fs = new FS::luks2 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Lvm2_PV: fs = new FS::lvm2_pv (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Nilfs2: fs = new FS::nilfs2 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ntfs: fs = new FS::ntfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ocfs2: fs = new FS::ocfs2 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::ReiserFS: fs = new FS::reiserfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Reiser4: fs = new FS::reiser4 (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Udf: fs = new FS::udf (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Ufs: fs = new FS::ufs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Unformatted: fs = new FS::unformatted (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Unknown: fs = new FS::unknown (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Xfs: fs = new FS::xfs (firstsector, lastsector, sectorsused, label); break;
case FileSystem::Type::Zfs: fs = new FS::zfs (firstsector, lastsector, sectorsused, label); break;
default: break;
}
......
......@@ -450,6 +450,7 @@ FileSystem::Type SfdiskBackend::detectFileSystem(const QString& partitionPath)
else if (s == QStringLiteral("iso9660")) rval = FileSystem::Type::Iso9660;
else if (s == QStringLiteral("linux_raid_member")) rval = FileSystem::Type::LinuxRaidMember;
else if (s == QStringLiteral("BitLocker")) rval = FileSystem::Type::BitLocker;
else if (s == QStringLiteral("apfs")) rval = FileSystem::Type::Apfs;
else
qWarning() << "unknown file system type " << s << " on " << partitionPath;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment