Add support for FAT12 file system.
This commit is contained in:
parent
8de54d390e
commit
5123411f1f
|
@ -6,6 +6,7 @@ set(FS_SRC
|
|||
fs/ext4.cpp
|
||||
fs/extended.cpp
|
||||
fs/f2fs.cpp
|
||||
fs/fat12.cpp
|
||||
fs/fat16.cpp
|
||||
fs/fat32.cpp
|
||||
fs/filesystem.cpp
|
||||
|
@ -40,6 +41,7 @@ set(FS_LIB_HDRS
|
|||
fs/ext4.h
|
||||
fs/extended.h
|
||||
fs/f2fs.h
|
||||
fs/fat12.h
|
||||
fs/fat16.h
|
||||
fs/fat32.h
|
||||
fs/filesystem.h
|
||||
|
|
|
@ -0,0 +1,178 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2008,2009,2011 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2017 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* *
|
||||
* 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/fat12.h"
|
||||
|
||||
#include "util/externalcommand.h"
|
||||
#include "util/capacity.h"
|
||||
#include "util/report.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
namespace FS
|
||||
{
|
||||
FileSystem::CommandSupportType fat12::m_GetUsed = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat12::m_GetLabel = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat12::m_SetLabel = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat12::m_Create = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat12::m_Grow = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat12::m_Shrink = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat12::m_Move = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat12::m_Check = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat12::m_Copy = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat12::m_Backup = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat12::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat12::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
fat12::fat12(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, t)
|
||||
{
|
||||
}
|
||||
|
||||
void fat12::init()
|
||||
{
|
||||
m_Create = m_GetUsed = m_Check = findExternal(QStringLiteral("mkfs.fat"), {}, 1) ? cmdSupportFileSystem : cmdSupportNone;
|
||||
m_GetLabel = cmdSupportCore;
|
||||
m_SetLabel = findExternal(QStringLiteral("fatlabel")) ? cmdSupportFileSystem : cmdSupportNone;
|
||||
m_Move = cmdSupportCore;
|
||||
m_Copy = cmdSupportCore;
|
||||
m_Backup = cmdSupportCore;
|
||||
m_UpdateUUID = findExternal(QStringLiteral("dd")) ? cmdSupportFileSystem : cmdSupportNone;
|
||||
m_GetUUID = cmdSupportCore;
|
||||
}
|
||||
|
||||
bool fat12::supportToolFound() const
|
||||
{
|
||||
return
|
||||
m_GetUsed != cmdSupportNone &&
|
||||
m_GetLabel != cmdSupportNone &&
|
||||
m_SetLabel != cmdSupportNone &&
|
||||
m_Create != cmdSupportNone &&
|
||||
m_Check != cmdSupportNone &&
|
||||
m_UpdateUUID != cmdSupportNone &&
|
||||
m_Copy != cmdSupportNone &&
|
||||
m_Move != cmdSupportNone &&
|
||||
m_Backup != cmdSupportNone &&
|
||||
m_GetUUID != cmdSupportNone;
|
||||
}
|
||||
|
||||
FileSystem::SupportTool fat12::supportToolName() const
|
||||
{
|
||||
// also, dd for updating the UUID, but let's assume it's there ;-)
|
||||
return SupportTool(QStringLiteral("dosfstools"), QUrl(QStringLiteral("http://www.daniel-baumann.ch/software/dosfstools/")));
|
||||
}
|
||||
|
||||
|
||||
qint64 fat12::minCapacity() const
|
||||
{
|
||||
return 1 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
}
|
||||
|
||||
qint64 fat12::maxCapacity() const
|
||||
{
|
||||
return 255 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
}
|
||||
|
||||
int fat12::maxLabelLength() const
|
||||
{
|
||||
return 11;
|
||||
}
|
||||
|
||||
QValidator* fat12::labelValidator(QObject *parent) const
|
||||
{
|
||||
QRegularExpressionValidator *m_LabelValidator = new QRegularExpressionValidator(parent);
|
||||
m_LabelValidator->setRegularExpression(QRegularExpression(QStringLiteral(R"(^[^\x{0000}-\x{001F}\x{007F}-\x{FFFF}*?.,;:\/\\|+=<>\[\]"]*$)")));
|
||||
return m_LabelValidator;
|
||||
}
|
||||
|
||||
qint64 fat12::readUsedCapacity(const QString& deviceNode) const
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("fsck.fat"), { QStringLiteral("-n"), QStringLiteral("-v"), deviceNode });
|
||||
|
||||
// Exit code 1 is returned when FAT dirty bit is set
|
||||
if (cmd.run(-1) && (cmd.exitCode() == 0 || cmd.exitCode() == 1)) {
|
||||
qint64 usedClusters = -1;
|
||||
QRegularExpression re(QStringLiteral("files, (\\d+)/\\d+ "));
|
||||
QRegularExpressionMatch reClusters = re.match(cmd.output());
|
||||
|
||||
if (reClusters.hasMatch())
|
||||
usedClusters = reClusters.captured(1).toLongLong();
|
||||
|
||||
qint64 clusterSize = -1;
|
||||
|
||||
re.setPattern(QStringLiteral("(\\d+) bytes per cluster"));
|
||||
QRegularExpressionMatch reClusterSize = re.match(cmd.output());
|
||||
|
||||
if (reClusterSize.hasMatch())
|
||||
clusterSize = reClusterSize.captured(1).toLongLong();
|
||||
|
||||
if (usedClusters > -1 && clusterSize > -1)
|
||||
return usedClusters * clusterSize;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool fat12::writeLabel(Report& report, const QString& deviceNode, const QString& newLabel)
|
||||
{
|
||||
report.line() << xi18nc("@info:progress", "Setting label for partition <filename>%1</filename> to %2", deviceNode, newLabel.toUpper());
|
||||
|
||||
ExternalCommand cmd(report, QStringLiteral("fatlabel"), { deviceNode, newLabel.toUpper() });
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
||||
bool fat12::check(Report& report, const QString& deviceNode) const
|
||||
{
|
||||
ExternalCommand cmd(report, QStringLiteral("fsck.fat"), { QStringLiteral("-a"), QStringLiteral("-w"), QStringLiteral("-v"), deviceNode });
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
||||
bool fat12::create(Report& report, const QString& deviceNode)
|
||||
{
|
||||
ExternalCommand cmd(report, QStringLiteral("mkfs.fat"), { QStringLiteral("-F12"), QStringLiteral("-I"), QStringLiteral("-v"), deviceNode });
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
||||
bool fat12::updateUUID(Report& report, const QString& deviceNode) const
|
||||
{
|
||||
qint64 t = time(nullptr);
|
||||
|
||||
char uuid[4];
|
||||
for (auto &u : uuid) {
|
||||
u = static_cast<char>(t & 0xff);
|
||||
t >>= 8;
|
||||
}
|
||||
|
||||
ExternalCommand cmd(report, QStringLiteral("dd"), { QStringLiteral("of=") + deviceNode , QStringLiteral("bs=1"), QStringLiteral("count=4"), QStringLiteral("seek=39") });
|
||||
|
||||
if (!cmd.start())
|
||||
return false;
|
||||
|
||||
if (cmd.write(uuid, sizeof(uuid)) != sizeof(uuid))
|
||||
return false;
|
||||
|
||||
return cmd.waitFor(-1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2008,2009 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2017 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* *
|
||||
* 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/>.*
|
||||
*************************************************************************/
|
||||
|
||||
#if !defined(KPMCORE_FAT12_H)
|
||||
|
||||
#define KPMCORE_FAT12_H
|
||||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
#include "fs/filesystem.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
class Report;
|
||||
|
||||
class QString;
|
||||
|
||||
namespace FS
|
||||
{
|
||||
/** A fat12 file system.
|
||||
@author Andrius Štikonas <vl@fidra.de>
|
||||
*/
|
||||
class LIBKPMCORE_EXPORT fat12 : public FileSystem
|
||||
{
|
||||
public:
|
||||
fat12(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Fat12);
|
||||
|
||||
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 updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
|
||||
CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
CommandSupportType supportCreate() 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 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;
|
||||
QValidator* labelValidator(QObject *parent) const override;
|
||||
SupportTool supportToolName() const override;
|
||||
bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
static CommandSupportType m_GetLabel;
|
||||
static CommandSupportType m_SetLabel;
|
||||
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_UpdateUUID;
|
||||
static CommandSupportType m_GetUUID;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
104
src/fs/fat16.cpp
104
src/fs/fat16.cpp
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2008,2009,2011 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* Copyright (C) 2016-2017 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -25,7 +25,6 @@
|
|||
#include <KLocalizedString>
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
|
@ -33,21 +32,13 @@
|
|||
|
||||
namespace FS
|
||||
{
|
||||
FileSystem::CommandSupportType fat16::m_GetUsed = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat16::m_GetLabel = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat16::m_SetLabel = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat16::m_Create = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat16::m_Grow = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat16::m_Shrink = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat16::m_Move = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat16::m_Check = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat16::m_Copy = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat16::m_Backup = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat16::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat16::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
fat16::fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
|
||||
fat12(firstsector, lastsector, sectorsused, label, FileSystem::Fat16)
|
||||
{
|
||||
}
|
||||
|
||||
fat16::fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, t)
|
||||
fat16::fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type type) :
|
||||
fat12(firstsector, lastsector, sectorsused, label, type)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -82,13 +73,6 @@ bool fat16::supportToolFound() const
|
|||
m_GetUUID != cmdSupportNone;
|
||||
}
|
||||
|
||||
FileSystem::SupportTool fat16::supportToolName() const
|
||||
{
|
||||
// also, dd for updating the UUID, but let's assume it's there ;-)
|
||||
return SupportTool(QStringLiteral("dosfstools"), QUrl(QStringLiteral("http://www.daniel-baumann.ch/software/dosfstools/")));
|
||||
}
|
||||
|
||||
|
||||
qint64 fat16::minCapacity() const
|
||||
{
|
||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
|
@ -99,60 +83,6 @@ qint64 fat16::maxCapacity() const
|
|||
return 4 * Capacity::unitFactor(Capacity::Byte, Capacity::GiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
}
|
||||
|
||||
int fat16::maxLabelLength() const
|
||||
{
|
||||
return 11;
|
||||
}
|
||||
|
||||
QValidator* fat16::labelValidator(QObject *parent) const
|
||||
{
|
||||
QRegularExpressionValidator *m_LabelValidator = new QRegularExpressionValidator(parent);
|
||||
m_LabelValidator->setRegularExpression(QRegularExpression(QStringLiteral(R"(^[^\x{0000}-\x{001F}\x{007F}-\x{FFFF}*?.,;:\/\\|+=<>\[\]"]*$)")));
|
||||
return m_LabelValidator;
|
||||
}
|
||||
|
||||
qint64 fat16::readUsedCapacity(const QString& deviceNode) const
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("fsck.fat"), { QStringLiteral("-n"), QStringLiteral("-v"), deviceNode });
|
||||
|
||||
// Exit code 1 is returned when FAT dirty bit is set
|
||||
if (cmd.run(-1) && (cmd.exitCode() == 0 || cmd.exitCode() == 1)) {
|
||||
qint64 usedClusters = -1;
|
||||
QRegularExpression re(QStringLiteral("files, (\\d+)/\\d+ "));
|
||||
QRegularExpressionMatch reClusters = re.match(cmd.output());
|
||||
|
||||
if (reClusters.hasMatch())
|
||||
usedClusters = reClusters.captured(1).toLongLong();
|
||||
|
||||
qint64 clusterSize = -1;
|
||||
|
||||
re.setPattern(QStringLiteral("(\\d+) bytes per cluster"));
|
||||
QRegularExpressionMatch reClusterSize = re.match(cmd.output());
|
||||
|
||||
if (reClusterSize.hasMatch())
|
||||
clusterSize = reClusterSize.captured(1).toLongLong();
|
||||
|
||||
if (usedClusters > -1 && clusterSize > -1)
|
||||
return usedClusters * clusterSize;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool fat16::writeLabel(Report& report, const QString& deviceNode, const QString& newLabel)
|
||||
{
|
||||
report.line() << xi18nc("@info:progress", "Setting label for partition <filename>%1</filename> to %2", deviceNode, newLabel.toUpper());
|
||||
|
||||
ExternalCommand cmd(report, QStringLiteral("fatlabel"), { deviceNode, newLabel.toUpper() });
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
||||
bool fat16::check(Report& report, const QString& deviceNode) const
|
||||
{
|
||||
ExternalCommand cmd(report, QStringLiteral("fsck.fat"), { QStringLiteral("-a"), QStringLiteral("-w"), QStringLiteral("-v"), deviceNode });
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
||||
bool fat16::create(Report& report, const QString& deviceNode)
|
||||
{
|
||||
ExternalCommand cmd(report, QStringLiteral("mkfs.fat"), { QStringLiteral("-F16"), QStringLiteral("-I"), QStringLiteral("-v"), deviceNode });
|
||||
|
@ -165,24 +95,4 @@ bool fat16::resize(Report& report, const QString& deviceNode, qint64 length) con
|
|||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
||||
bool fat16::updateUUID(Report& report, const QString& deviceNode) const
|
||||
{
|
||||
qint64 t = time(nullptr);
|
||||
|
||||
char uuid[4];
|
||||
for (auto &u : uuid) {
|
||||
u = static_cast<char>(t & 0xff);
|
||||
t >>= 8;
|
||||
}
|
||||
|
||||
ExternalCommand cmd(report, QStringLiteral("dd"), { QStringLiteral("of=") + deviceNode , QStringLiteral("bs=1"), QStringLiteral("count=4"), QStringLiteral("seek=39") });
|
||||
|
||||
if (!cmd.start())
|
||||
return false;
|
||||
|
||||
if (cmd.write(uuid, sizeof(uuid)) != sizeof(uuid))
|
||||
return false;
|
||||
|
||||
return cmd.waitFor(-1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2008,2009 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2017 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -19,11 +20,7 @@
|
|||
|
||||
#define KPMCORE_FAT16_H
|
||||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
#include "fs/filesystem.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include "fs/fat12.h"
|
||||
|
||||
class Report;
|
||||
|
||||
|
@ -34,78 +31,21 @@ namespace FS
|
|||
/** A fat16 file system.
|
||||
@author Volker Lanz <vl@fidra.de>
|
||||
*/
|
||||
class LIBKPMCORE_EXPORT fat16 : public FileSystem
|
||||
class LIBKPMCORE_EXPORT fat16 : public fat12
|
||||
{
|
||||
public:
|
||||
fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Fat16);
|
||||
fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
|
||||
fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type type);
|
||||
|
||||
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 updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
|
||||
CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
CommandSupportType supportCreate() 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 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;
|
||||
QValidator* labelValidator(QObject *parent) const override;
|
||||
SupportTool supportToolName() const override;
|
||||
bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
static CommandSupportType m_GetLabel;
|
||||
static CommandSupportType m_SetLabel;
|
||||
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_UpdateUUID;
|
||||
static CommandSupportType m_GetUUID;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ const std::array< QColor, FileSystem::__lastType > FileSystem::defaultColorCode
|
|||
QColor( 170,120,255 ), // udf
|
||||
QColor( 177,82,69 ), // iso9660
|
||||
QColor( 223,39,104 ), // luks2
|
||||
// QColor( 204,179,255 ) // fat12
|
||||
QColor( 204,179,255 ) // fat12
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -446,7 +446,8 @@ static const KLocalizedString* typeNames()
|
|||
kxi18nc("@item filesystem name", "f2fs"),
|
||||
kxi18nc("@item filesystem name", "udf"),
|
||||
kxi18nc("@item filesystem name", "iso9660"),
|
||||
kxi18nc("@item filesystem name", "luks2")
|
||||
kxi18nc("@item filesystem name", "luks2"),
|
||||
kxi18nc("@item filesystem name", "fat12")
|
||||
};
|
||||
|
||||
return s;
|
||||
|
|
|
@ -88,8 +88,9 @@ public:
|
|||
Udf = 26,
|
||||
Iso9660 = 27,
|
||||
Luks2 = 28,
|
||||
Fat12 = 29,
|
||||
|
||||
__lastType = 29
|
||||
__lastType = 30
|
||||
};
|
||||
|
||||
/** The type of support for a given FileSystem action */
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "fs/ext4.h"
|
||||
#include "fs/extended.h"
|
||||
#include "fs/f2fs.h"
|
||||
#include "fs/fat12.h"
|
||||
#include "fs/fat16.h"
|
||||
#include "fs/fat32.h"
|
||||
#include "fs/hfs.h"
|
||||
|
@ -67,6 +68,7 @@ void FileSystemFactory::init()
|
|||
m_FileSystems.insert(FileSystem::Ext4, new FS::ext4(-1, -1, -1, QString()));
|
||||
m_FileSystems.insert(FileSystem::Extended, new FS::extended(-1, -1, -1, QString()));
|
||||
m_FileSystems.insert(FileSystem::F2fs, new FS::f2fs(-1, -1, -1, QString()));
|
||||
m_FileSystems.insert(FileSystem::Fat12, new FS::fat12(-1, -1, -1, QString()));
|
||||
m_FileSystems.insert(FileSystem::Fat16, new FS::fat16(-1, -1, -1, QString()));
|
||||
m_FileSystems.insert(FileSystem::Fat32, new FS::fat32(-1, -1, -1, QString()));
|
||||
m_FileSystems.insert(FileSystem::Hfs, new FS::hfs(-1, -1, -1, QString()));
|
||||
|
@ -116,6 +118,7 @@ FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qi
|
|||
case FileSystem::Ext4: fs = new FS::ext4(firstsector, lastsector, sectorsused, label); break;
|
||||
case FileSystem::Extended: fs = new FS::extended(firstsector, lastsector, sectorsused, label); break;
|
||||
case FileSystem::F2fs: fs = new FS::f2fs(firstsector, lastsector, sectorsused, label); break;
|
||||
case FileSystem::Fat12: fs = new FS::fat12(firstsector, lastsector, sectorsused, label); break;
|
||||
case FileSystem::Fat16: fs = new FS::fat16(firstsector, lastsector, sectorsused, label); break;
|
||||
case FileSystem::Fat32: fs = new FS::fat32(firstsector, lastsector, sectorsused, label); break;
|
||||
case FileSystem::Hfs: fs = new FS::hfs(firstsector, lastsector, sectorsused, label); break;
|
||||
|
|
|
@ -327,10 +327,12 @@ FileSystem::Type SfdiskBackend::detectFileSystem(const QString& partitionPath)
|
|||
else if (s == QStringLiteral("hfsplus")) rval = FileSystem::HfsPlus;
|
||||
else if (s == QStringLiteral("ufs")) rval = FileSystem::Ufs;
|
||||
else if (s == QStringLiteral("vfat")) {
|
||||
if (version == QStringLiteral("FAT12") || version == QStringLiteral("FAT16"))
|
||||
rval = FileSystem::Fat16;
|
||||
else if (version == QStringLiteral("FAT32"))
|
||||
if (version == QStringLiteral("FAT32"))
|
||||
rval = FileSystem::Fat32;
|
||||
else if (version == QStringLiteral("FAT16"))
|
||||
rval = FileSystem::Fat16;
|
||||
else if (version == QStringLiteral("FAT12"))
|
||||
rval = FileSystem::Fat12;
|
||||
}
|
||||
else if (s == QStringLiteral("btrfs")) rval = FileSystem::Btrfs;
|
||||
else if (s == QStringLiteral("ocfs2")) rval = FileSystem::Ocfs2;
|
||||
|
|
Loading…
Reference in New Issue