Add support for getting fat16 and fat32 volume labels (no support for setting,
still). svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=964225
This commit is contained in:
parent
9a1a21f3e7
commit
9c5580d1e2
|
@ -22,6 +22,8 @@
|
||||||
#include "util/externalcommand.h"
|
#include "util/externalcommand.h"
|
||||||
#include "util/capacity.h"
|
#include "util/capacity.h"
|
||||||
|
|
||||||
|
#include <kdebug.h>
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
|
@ -31,6 +33,7 @@
|
||||||
namespace FS
|
namespace FS
|
||||||
{
|
{
|
||||||
FileSystem::SupportType fat16::m_GetUsed = FileSystem::SupportNone;
|
FileSystem::SupportType fat16::m_GetUsed = FileSystem::SupportNone;
|
||||||
|
FileSystem::SupportType fat16::m_GetLabel = FileSystem::SupportNone;
|
||||||
FileSystem::SupportType fat16::m_Create = FileSystem::SupportNone;
|
FileSystem::SupportType fat16::m_Create = FileSystem::SupportNone;
|
||||||
FileSystem::SupportType fat16::m_Grow = FileSystem::SupportNone;
|
FileSystem::SupportType fat16::m_Grow = FileSystem::SupportNone;
|
||||||
FileSystem::SupportType fat16::m_Shrink = FileSystem::SupportNone;
|
FileSystem::SupportType fat16::m_Shrink = FileSystem::SupportNone;
|
||||||
|
@ -39,7 +42,7 @@ namespace FS
|
||||||
FileSystem::SupportType fat16::m_Copy = FileSystem::SupportNone;
|
FileSystem::SupportType fat16::m_Copy = FileSystem::SupportNone;
|
||||||
FileSystem::SupportType fat16::m_Backup = FileSystem::SupportNone;
|
FileSystem::SupportType fat16::m_Backup = FileSystem::SupportNone;
|
||||||
FileSystem::SupportType fat16::m_UpdateUUID = FileSystem::SupportNone;
|
FileSystem::SupportType fat16::m_UpdateUUID = FileSystem::SupportNone;
|
||||||
|
|
||||||
|
|
||||||
fat16::fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t) :
|
fat16::fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t) :
|
||||||
FileSystem(firstsector, lastsector, sectorsused, label, t)
|
FileSystem(firstsector, lastsector, sectorsused, label, t)
|
||||||
|
@ -48,13 +51,14 @@ namespace FS
|
||||||
|
|
||||||
void fat16::init()
|
void fat16::init()
|
||||||
{
|
{
|
||||||
// There is no support for getting or setting labels for FAT16 and FAT32 right now.
|
// There is no support for setting labels for FAT16 and FAT32 right now.
|
||||||
// The mtools package is able to do that, but requires mappings from Unix device nodes
|
// The mtools package is able to do that, but requires mappings from Unix device nodes
|
||||||
// to Windows-like drive letters -- something we cannot support. It would, however,
|
// to Windows-like drive letters -- something we cannot support. It would, however,
|
||||||
// probably be possible to implement the file system label stuff ourselves here.
|
// probably be possible to implement the file system label stuff ourselves here.
|
||||||
|
|
||||||
m_Create = findExternal("mkfs.msdos") ? SupportExternal : SupportNone;
|
m_Create = findExternal("mkfs.msdos") ? SupportExternal : SupportNone;
|
||||||
m_GetUsed = m_Check = findExternal("fsck.msdos", QStringList(), 2) ? SupportExternal : SupportNone;
|
m_GetUsed = m_Check = findExternal("fsck.msdos", QStringList(), 2) ? SupportExternal : SupportNone;
|
||||||
|
m_GetLabel = findExternal("vol_id") ? SupportExternal : SupportNone;
|
||||||
m_Grow = SupportLibParted;
|
m_Grow = SupportLibParted;
|
||||||
m_Shrink = SupportLibParted;
|
m_Shrink = SupportLibParted;
|
||||||
m_Move = SupportInternal;
|
m_Move = SupportInternal;
|
||||||
|
@ -72,7 +76,7 @@ namespace FS
|
||||||
{
|
{
|
||||||
return 4 * Capacity::unitFactor(Capacity::Byte, Capacity::GiB);
|
return 4 * Capacity::unitFactor(Capacity::Byte, Capacity::GiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 fat16::readUsedCapacity(const QString& deviceNode) const
|
qint64 fat16::readUsedCapacity(const QString& deviceNode) const
|
||||||
{
|
{
|
||||||
ExternalCommand cmd("fsck.msdos", QStringList() << "-v" << deviceNode);
|
ExternalCommand cmd("fsck.msdos", QStringList() << "-v" << deviceNode);
|
||||||
|
@ -118,7 +122,7 @@ namespace FS
|
||||||
char uuid[4];
|
char uuid[4];
|
||||||
for (quint32 i = 0; i < sizeof(uuid); i++, t >>= 8)
|
for (quint32 i = 0; i < sizeof(uuid); i++, t >>= 8)
|
||||||
uuid[i] = t & 0xff;
|
uuid[i] = t & 0xff;
|
||||||
|
|
||||||
ExternalCommand cmd(report, "dd", QStringList() << "of=" + deviceNode << "bs=1" << "count=4" << "seek=39");
|
ExternalCommand cmd(report, "dd", QStringList() << "of=" + deviceNode << "bs=1" << "count=4" << "seek=39");
|
||||||
|
|
||||||
if (!cmd.start())
|
if (!cmd.start())
|
||||||
|
@ -126,7 +130,22 @@ namespace FS
|
||||||
|
|
||||||
if (cmd.write(uuid, sizeof(uuid)) != sizeof(uuid))
|
if (cmd.write(uuid, sizeof(uuid)) != sizeof(uuid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return cmd.waitFor(-1);
|
return cmd.waitFor(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString fat16::readLabel(const QString& deviceNode) const
|
||||||
|
{
|
||||||
|
ExternalCommand cmd("vol_id", QStringList() << deviceNode);
|
||||||
|
|
||||||
|
if (cmd.run())
|
||||||
|
{
|
||||||
|
QRegExp rxLabel("ID_FS_LABEL=(\\w+)");
|
||||||
|
|
||||||
|
if (rxLabel.indexIn(cmd.output()) != -1)
|
||||||
|
return rxLabel.cap(1).simplified();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,13 @@ namespace FS
|
||||||
static void init();
|
static void init();
|
||||||
|
|
||||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||||
|
virtual QString readLabel(const QString& deviceNode) const;
|
||||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||||
|
|
||||||
virtual SupportType supportGetUsed() const { return m_GetUsed; }
|
virtual SupportType supportGetUsed() const { return m_GetUsed; }
|
||||||
|
virtual SupportType supportGetLabel() const { return m_GetLabel; }
|
||||||
virtual SupportType supportCreate() const { return m_Create; }
|
virtual SupportType supportCreate() const { return m_Create; }
|
||||||
virtual SupportType supportGrow() const { return m_Grow; }
|
virtual SupportType supportGrow() const { return m_Grow; }
|
||||||
virtual SupportType supportShrink() const { return m_Shrink; }
|
virtual SupportType supportShrink() const { return m_Shrink; }
|
||||||
|
@ -56,12 +58,13 @@ namespace FS
|
||||||
virtual SupportType supportCopy() const { return m_Copy; }
|
virtual SupportType supportCopy() const { return m_Copy; }
|
||||||
virtual SupportType supportBackup() const { return m_Backup; }
|
virtual SupportType supportBackup() const { return m_Backup; }
|
||||||
virtual SupportType supportUpdateUUID() const { return m_UpdateUUID; }
|
virtual SupportType supportUpdateUUID() const { return m_UpdateUUID; }
|
||||||
|
|
||||||
virtual qint64 minCapacity() const;
|
virtual qint64 minCapacity() const;
|
||||||
virtual qint64 maxCapacity() const;
|
virtual qint64 maxCapacity() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static SupportType m_GetUsed;
|
static SupportType m_GetUsed;
|
||||||
|
static SupportType m_GetLabel;
|
||||||
static SupportType m_Create;
|
static SupportType m_Create;
|
||||||
static SupportType m_Grow;
|
static SupportType m_Grow;
|
||||||
static SupportType m_Shrink;
|
static SupportType m_Shrink;
|
||||||
|
|
Loading…
Reference in New Issue