Add BitLocker detection support.

CCBUG: 392892
This commit is contained in:
Andrius Štikonas 2019-01-13 02:24:06 +00:00
parent 9fa20fb1e2
commit 708318a5ad
7 changed files with 102 additions and 2 deletions

View File

@ -1,4 +1,5 @@
set(FS_SRC
fs/bitlocker.cpp
fs/btrfs.cpp
fs/exfat.cpp
fs/ext2.cpp
@ -35,6 +36,7 @@ set(FS_SRC
)
set(FS_LIB_HDRS
fs/bitlocker.h
fs/btrfs.h
fs/exfat.h
fs/ext2.h

30
src/fs/bitlocker.cpp Normal file
View File

@ -0,0 +1,30 @@
/*************************************************************************
* 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/bitlocker.h"
namespace FS
{
FileSystem::CommandSupportType bitlocker::m_Move = FileSystem::cmdSupportCore;
FileSystem::CommandSupportType bitlocker::m_Copy = FileSystem::cmdSupportCore;
FileSystem::CommandSupportType bitlocker::m_Backup = FileSystem::cmdSupportCore;
bitlocker::bitlocker(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::BitLocker)
{
}
}

61
src/fs/bitlocker.h Normal file
View File

@ -0,0 +1,61 @@
/*************************************************************************
* 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_BITLOCKER_H
#define KPMCORE_BITLOCKER_H
#include "util/libpartitionmanagerexport.h"
#include "fs/filesystem.h"
#include <QtGlobal>
class QString;
namespace FS
{
/** A Bitlocker encrypted file system.
@author Andrius Štikonas <stikonas@kde.org>
*/
class LIBKPMCORE_EXPORT bitlocker : public FileSystem
{
public:
bitlocker(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

View File

@ -68,8 +68,9 @@ const std::vector<QColor> FileSystem::defaultColorCode =
QColor( 170,120,255 ), // udf
QColor( 177,82,69 ), // iso9660
QColor( 223,39,104 ), // luks2
QColor( 204,179,255 ), // fat12
QColor( 255,100,100 ) // linux_raid_member
QColor( 204,179,255 ), // fat12
QColor( 255,100,100 ), // linux_raid_member
QColor( 110,20,50 ), // bitlocker
}
};
@ -448,6 +449,7 @@ static const KLocalizedString* typeNames()
kxi18nc("@item filesystem name", "luks2"),
kxi18nc("@item filesystem name", "fat12"),
kxi18nc("@item filesystem name", "linux_raid_member"),
kxi18nc("@item filesystem name", "BitLocker"),
};
return s;

View File

@ -92,6 +92,7 @@ public:
Luks2,
Fat12,
LinuxRaidMember,
BitLocker,
__lastType
};

View File

@ -19,6 +19,7 @@
#include "fs/filesystemfactory.h"
#include "fs/filesystem.h"
#include "fs/bitlocker.h"
#include "fs/btrfs.h"
#include "fs/exfat.h"
#include "fs/ext2.h"
@ -62,6 +63,7 @@ void FileSystemFactory::init()
qDeleteAll(m_FileSystems);
m_FileSystems.clear();
m_FileSystems.insert(FileSystem::Type::BitLocker, new FS::btrfs(-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()));
m_FileSystems.insert(FileSystem::Type::Ext2, new FS::ext2(-1, -1, -1, QString()));
@ -113,6 +115,7 @@ 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;

View File

@ -449,6 +449,7 @@ FileSystem::Type SfdiskBackend::detectFileSystem(const QString& partitionPath)
else if (s == QStringLiteral("udf")) rval = FileSystem::Type::Udf;
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
qWarning() << "unknown file system type " << s << " on " << partitionPath;
}