diff --git a/src/fs/exfat.cpp b/src/fs/exfat.cpp index f5b381a..a6193ca 100644 --- a/src/fs/exfat.cpp +++ b/src/fs/exfat.cpp @@ -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; } diff --git a/src/fs/exfat.h b/src/fs/exfat.h index 0960424..4b69076 100644 --- a/src/fs/exfat.h +++ b/src/fs/exfat.h @@ -96,6 +96,9 @@ public: static CommandSupportType m_SetLabel; static CommandSupportType m_UpdateUUID; static CommandSupportType m_GetUUID; + +private: + static bool exfatUtils; }; } diff --git a/src/util/externalcommand_whitelist.h b/src/util/externalcommand_whitelist.h index a224dc8..17455a5 100644 --- a/src/util/externalcommand_whitelist.h +++ b/src/util/externalcommand_whitelist.h @@ -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"),