make sure we use blkid as an alternative if vol_id is not available: a
certain distro now ships blkid exclusively. svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1056190
This commit is contained in:
parent
5f521cfdc3
commit
02e231a651
|
@ -57,7 +57,7 @@ namespace FS
|
|||
m_Copy = (m_Check != SupportNone) ? SupportInternal : SupportNone;
|
||||
m_Move = (m_Check != SupportNone) ? SupportInternal : SupportNone;
|
||||
m_Backup = SupportInternal;
|
||||
m_GetUUID = findExternal("vol_id") ? SupportExternal : SupportNone;
|
||||
m_GetUUID = findIdUtil() ? SupportExternal : SupportNone;
|
||||
}
|
||||
|
||||
qint64 ext2::maxCapacity() const
|
||||
|
|
|
@ -58,14 +58,14 @@ namespace FS
|
|||
|
||||
m_Create = findExternal("mkfs.msdos") ? SupportExternal : SupportNone;
|
||||
m_GetUsed = m_Check = findExternal("fsck.msdos", QStringList(), 2) ? SupportExternal : SupportNone;
|
||||
m_GetLabel = findExternal("vol_id") ? SupportExternal : SupportNone;
|
||||
m_GetLabel = findIdUtil() ? SupportExternal : SupportNone;
|
||||
m_Grow = SupportLibParted;
|
||||
m_Shrink = SupportLibParted;
|
||||
m_Move = SupportInternal;
|
||||
m_Copy = SupportInternal;
|
||||
m_Backup = SupportInternal;
|
||||
m_UpdateUUID = findExternal("dd") ? SupportExternal : SupportNone;
|
||||
m_GetUUID = findExternal("vol_id") ? SupportExternal : SupportNone;
|
||||
m_GetUUID = findIdUtil() ? SupportExternal : SupportNone;
|
||||
}
|
||||
|
||||
qint64 fat16::minCapacity() const
|
||||
|
@ -134,19 +134,4 @@ namespace FS
|
|||
|
||||
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,7 +43,6 @@ namespace FS
|
|||
static void init();
|
||||
|
||||
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 create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
|
|
|
@ -53,15 +53,33 @@ qint64 FileSystem::readUsedCapacity(const QString& deviceNode) const
|
|||
return -1;
|
||||
}
|
||||
|
||||
static QString invokeIdUtil(const QString& util, const QString& deviceNode, const QString& rx)
|
||||
{
|
||||
ExternalCommand cmd(util, QStringList() << deviceNode);
|
||||
|
||||
if (cmd.run())
|
||||
{
|
||||
QRegExp rxLabel(rx);
|
||||
|
||||
if (rxLabel.indexIn(cmd.output()) != -1)
|
||||
return rxLabel.cap(1).simplified();
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
/** Reads the label for this FileSystem
|
||||
@param deviceNode the device node for the Partition the FileSystem is on
|
||||
@return the FileSystem label or an empty string in case of error
|
||||
*/
|
||||
QString FileSystem::readLabel(const QString& deviceNode) const
|
||||
{
|
||||
Q_UNUSED(deviceNode);
|
||||
QString rval = invokeIdUtil("vol_id", deviceNode, "ID_FS_LABEL=(\\w+)");
|
||||
|
||||
return QString();
|
||||
if (rval.isEmpty())
|
||||
rval = invokeIdUtil("blkid", deviceNode, "LABEL=\"(\\w+)\"");
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/** Creates a new FileSystem
|
||||
|
@ -171,18 +189,12 @@ bool FileSystem::updateUUID(Report& report, const QString& deviceNode) const
|
|||
*/
|
||||
QString FileSystem::readUUID(const QString& deviceNode) const
|
||||
{
|
||||
ExternalCommand cmd("vol_id", QStringList() << deviceNode);
|
||||
QString rval = invokeIdUtil("vol_id", deviceNode, "ID_FS_UUID=([^\\s]+)");
|
||||
|
||||
if (cmd.run())
|
||||
{
|
||||
QRegExp rxUuid("ID_FS_UUID=([^\\s]+)");
|
||||
|
||||
if (rxUuid.indexIn(cmd.output()) != -1)
|
||||
return rxUuid.cap(1).simplified();
|
||||
}
|
||||
|
||||
return QString();
|
||||
if (rval.isEmpty())
|
||||
rval = invokeIdUtil("blkid", deviceNode, "UUID=\"([^\"]+)\"");
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/** Give implementations of FileSystem a chance to update the boot sector after the
|
||||
|
@ -335,3 +347,9 @@ bool FileSystem::findExternal(const QString& cmdName, const QStringList& args, i
|
|||
|
||||
return cmd.exitCode() == 0 || cmd.exitCode() == expectedCode;
|
||||
}
|
||||
|
||||
bool FileSystem::findIdUtil()
|
||||
{
|
||||
return findExternal("vol_id") || findExternal("blkid");
|
||||
}
|
||||
|
||||
|
|
|
@ -147,6 +147,7 @@ class FileSystem
|
|||
|
||||
protected:
|
||||
static bool findExternal(const QString& cmdName, const QStringList& args = QStringList(), int exptectedCode = 1);
|
||||
static bool findIdUtil();
|
||||
|
||||
protected:
|
||||
FileSystem::Type m_Type;
|
||||
|
|
|
@ -42,10 +42,10 @@ namespace FS
|
|||
void linuxswap::init()
|
||||
{
|
||||
m_SetLabel = m_Shrink = m_Grow = m_Create = (findExternal("mkswap")) ? SupportExternal : SupportNone;
|
||||
m_GetLabel = findExternal("vol_id") ? SupportExternal : SupportNone;
|
||||
m_GetLabel = findIdUtil() ? SupportExternal : SupportNone;
|
||||
m_Copy = SupportInternal;
|
||||
m_Move = SupportInternal;
|
||||
m_GetUUID = findExternal("vol_id") ? SupportExternal : SupportNone;
|
||||
m_GetUUID = findIdUtil() ? SupportExternal : SupportNone;
|
||||
}
|
||||
|
||||
bool linuxswap::create(Report& report, const QString& deviceNode) const
|
||||
|
@ -65,21 +65,6 @@ namespace FS
|
|||
return ExternalCommand(report, "mkswap", args).run(-1);
|
||||
}
|
||||
|
||||
QString linuxswap::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();
|
||||
}
|
||||
|
||||
bool linuxswap::writeLabel(Report& report, const QString& deviceNode, const QString& newLabel)
|
||||
{
|
||||
return ExternalCommand(report, "mkswap", QStringList() << "-L" << newLabel << deviceNode).run(-1);
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace FS
|
|||
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
virtual QString readLabel(const QString& deviceNode) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
|
||||
virtual bool canMount(const QString&) const { return true; }
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace FS
|
|||
m_Backup = SupportInternal;
|
||||
m_UpdateUUID = findExternal("dd") ? SupportExternal : SupportNone;
|
||||
m_Move = (m_Check != SupportNone) ? SupportInternal : SupportNone;
|
||||
m_GetUUID = findExternal("vol_id") ? SupportExternal : SupportNone;
|
||||
m_GetUUID = findIdUtil() ? SupportExternal : SupportNone;
|
||||
}
|
||||
|
||||
qint64 ntfs::maxCapacity() const
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace FS
|
|||
m_Shrink = (m_GetUsed != SupportNone && m_Grow != SupportNone) ? SupportExternal : SupportNone;
|
||||
m_Backup = SupportInternal;
|
||||
m_UpdateUUID = findExternal("reiserfstune") ? SupportExternal : SupportNone;
|
||||
m_GetUUID = findExternal("vol_id") ? SupportExternal : SupportNone;
|
||||
m_GetUUID = findIdUtil() ? SupportExternal : SupportNone;
|
||||
}
|
||||
|
||||
qint64 reiserfs::minCapacity() const
|
||||
|
|
Loading…
Reference in New Issue