Browse Source

Add support for exfatprogs

Bug: 430907
master
Andrius Štikonas 2 months ago
parent
commit
06f15334ec
3 changed files with 31 additions and 7 deletions
  1. +25
    -6
      src/fs/exfat.cpp
  2. +3
    -0
      src/fs/exfat.h
  3. +3
    -1
      src/util/externalcommand_whitelist.h

+ 25
- 6
src/fs/exfat.cpp View File

@ -28,6 +28,7 @@ FileSystem::CommandSupportType exfat::m_Backup = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType exfat::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType exfat::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType exfat::m_GetUUID = FileSystem::cmdSupportNone;
bool exfat::exfatUtils = false;
exfat::exfat(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Exfat)
@ -36,11 +37,20 @@ exfat::exfat(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QS
void exfat::init()
{
m_Create = findExternal(QStringLiteral("mkfs.exfat")) ? cmdSupportFileSystem : cmdSupportNone;
m_Check = findExternal(QStringLiteral("exfatfsck"), QStringList(), 1) ? cmdSupportFileSystem : cmdSupportNone;
// Check if we are using exfat-utils or exfatprogs
exfatUtils = findExternal(QStringLiteral("mkexfatfs"));
if (exfatUtils) {
m_Create = cmdSupportFileSystem;
m_Check = findExternal(QStringLiteral("fsck.exfat"), {}, 1) ? cmdSupportFileSystem : cmdSupportNone;
m_SetLabel = findExternal(QStringLiteral("exfatlabel")) ? cmdSupportFileSystem : cmdSupportNone;
}
else {
m_Create = findExternal(QStringLiteral("mkfs.exfat"), {}, 1) ? cmdSupportFileSystem : cmdSupportNone;
m_Check = findExternal(QStringLiteral("fsck.exfat"), {}, 16) ? cmdSupportFileSystem : cmdSupportNone;
m_SetLabel = findExternal(QStringLiteral("tune.exfat")) ? cmdSupportFileSystem : cmdSupportNone;
}
m_GetLabel = cmdSupportCore;
m_SetLabel = findExternal(QStringLiteral("exfatlabel")) ? cmdSupportFileSystem : cmdSupportNone;
m_UpdateUUID = cmdSupportNone;
m_Copy = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone;
@ -70,7 +80,7 @@ bool exfat::supportToolFound() const
FileSystem::SupportTool exfat::supportToolName() const
{
return SupportTool(QStringLiteral("exfat-utils"), QUrl(QStringLiteral("https://github.com/relan/exfat")));
return SupportTool(QStringLiteral("exfatprogs"), QUrl(QStringLiteral("https://github.com/exfatprogs/exfatprogs")));
}
qint64 exfat::maxCapacity() const
@ -85,7 +95,7 @@ int exfat::maxLabelLength() const
bool exfat::check(Report& report, const QString& deviceNode) const
{
ExternalCommand cmd(report, QStringLiteral("exfatfsck"), { deviceNode });
ExternalCommand cmd(report, QStringLiteral("fsck.exfat"), { deviceNode });
return cmd.run(-1) && cmd.exitCode() == 0;
}
@ -97,7 +107,16 @@ bool exfat::create(Report& report, const QString& deviceNode)
bool exfat::writeLabel(Report& report, const QString& deviceNode, const QString& newLabel)
{
ExternalCommand cmd(report, QStringLiteral("exfatlabel"), { deviceNode, newLabel });
ExternalCommand cmd(report);
if (exfatUtils) {
cmd.setCommand(QStringLiteral("exfatlabel"));
cmd.setArgs({ deviceNode, newLabel });
}
else {
cmd.setCommand(QStringLiteral("tune.exfat"));
cmd.setArgs({ deviceNode, QStringLiteral("-L"), newLabel });
}
return cmd.run(-1) && cmd.exitCode() == 0;
}


+ 3
- 0
src/fs/exfat.h View File

@ -96,6 +96,9 @@ public:
static CommandSupportType m_SetLabel;
static CommandSupportType m_UpdateUUID;
static CommandSupportType m_GetUUID;
private:
static bool exfatUtils;
};
}


+ 3
- 1
src/util/externalcommand_whitelist.h View File

@ -31,9 +31,11 @@ QStringLiteral("smartctl"),
QStringLiteral("btrfs"),
QStringLiteral("mkfs.btrfs"),
QStringLiteral("btrfstune"),
QStringLiteral("exfatfsck"),
QStringLiteral("fsck.exfat"),
QStringLiteral("mkexfatfs"),
QStringLiteral("mkfs.exfat"),
QStringLiteral("exfatlabel"),
QStringLiteral("tune.exfat"),
QStringLiteral("dumpe2fs"),
QStringLiteral("e2fsck"),
QStringLiteral("mkfs.ext2"),


Loading…
Cancel
Save