Use diskdev_cmds instead of obsolete hfsplusutils for HFS+ file systems.

This commit is contained in:
Andrius Štikonas 2016-06-12 13:33:04 +01:00
parent b6911285dc
commit 2514f7d8f4
2 changed files with 27 additions and 7 deletions

View File

@ -25,10 +25,12 @@
namespace FS
{
FileSystem::CommandSupportType hfsplus::m_GetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hfsplus::m_GetUsed = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hfsplus::m_Shrink = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hfsplus::m_Move = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hfsplus::m_Check = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hfsplus::m_Create = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hfsplus::m_Copy = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hfsplus::m_Backup = FileSystem::cmdSupportNone;
@ -39,19 +41,21 @@ hfsplus::hfsplus(qint64 firstsector, qint64 lastsector, qint64 sectorsused, cons
void hfsplus::init()
{
m_Check = findExternal(QStringLiteral("hpfsck")) ? cmdSupportFileSystem : cmdSupportNone;
m_Check = findExternal(QStringLiteral("fsck_hfs")) ? cmdSupportFileSystem : cmdSupportNone;
m_Create = findExternal(QStringLiteral("newfs_hfs")) ? cmdSupportFileSystem : cmdSupportNone;
m_Copy = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone;
m_Move = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone;
m_Backup = cmdSupportCore;
m_GetLabel = cmdSupportCore;
}
bool hfsplus::supportToolFound() const
{
return
// m_GetUsed != cmdSupportNone &&
// m_GetLabel != cmdSupportNone &&
m_GetLabel != cmdSupportNone &&
// m_SetLabel != cmdSupportNone &&
// m_Create != cmdSupportNone &&
m_Create != cmdSupportNone &&
m_Check != cmdSupportNone &&
// m_UpdateUUID != cmdSupportNone &&
// m_Grow != cmdSupportNone &&
@ -59,17 +63,17 @@ bool hfsplus::supportToolFound() const
m_Copy != cmdSupportNone &&
m_Move != cmdSupportNone &&
m_Backup != cmdSupportNone;
// m_GetUUID != cmdSupportNone;
// m_GetUUID != cmdSupportNone;
}
FileSystem::SupportTool hfsplus::supportToolName() const
{
return SupportTool(QStringLiteral("hfsplus"), QUrl());
return SupportTool(QStringLiteral("diskdev_cmds"), QUrl(QStringLiteral("http://opendarwin.org")));
}
qint64 hfsplus::maxCapacity() const
{
return 8 * Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
}
qint64 hfsplus::maxLabelLength() const
@ -79,7 +83,14 @@ qint64 hfsplus::maxLabelLength() const
bool hfsplus::check(Report& report, const QString& deviceNode) const
{
ExternalCommand cmd(report, QStringLiteral("hpfsck"), { QStringLiteral("-v"), deviceNode });
ExternalCommand cmd(report, QStringLiteral("fsck_hfs"), { deviceNode });
return cmd.run(-1) && cmd.exitCode() == 0;
}
bool hfsplus::create(Report& report, const QString& deviceNode) const
{
ExternalCommand cmd(report, QStringLiteral("newfs_hfs"), { deviceNode });
return cmd.run(-1) && cmd.exitCode() == 0;
}
}

View File

@ -43,7 +43,11 @@ public:
void init() override;
bool check(Report& report, const QString& deviceNode) const override;
bool create(Report& report, const QString& deviceNode) const override;
CommandSupportType supportGetLabel() const override {
return m_GetLabel;
}
CommandSupportType supportGetUsed() const override {
return m_GetUsed;
}
@ -56,6 +60,9 @@ public:
CommandSupportType supportCheck() const override {
return m_Check;
}
CommandSupportType supportCreate() const override {
return m_Create;
}
CommandSupportType supportCopy() const override {
return m_Copy;
}
@ -69,9 +76,11 @@ public:
bool supportToolFound() const override;
public:
static CommandSupportType m_GetLabel;
static CommandSupportType m_GetUsed;
static CommandSupportType m_Shrink;
static CommandSupportType m_Move;
static CommandSupportType m_Create;
static CommandSupportType m_Check;
static CommandSupportType m_Copy;
static CommandSupportType m_Backup;