add copy() and updateUUID() methods to linuxswap

actually make use of the length param in linuxswap::resize()

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1128926
This commit is contained in:
Volker Lanz 2010-05-20 17:27:19 +00:00
parent c2f0ff7528
commit 7196b3a37e
2 changed files with 41 additions and 5 deletions

View File

@ -33,6 +33,7 @@ namespace FS
FileSystem::CommandSupportType linuxswap::m_GetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType linuxswap::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType linuxswap::m_GetUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType linuxswap::m_UpdateUUID = FileSystem::cmdSupportNone;
linuxswap::linuxswap(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::LinuxSwap)
@ -41,9 +42,9 @@ namespace FS
void linuxswap::init()
{
m_SetLabel = m_Shrink = m_Grow = m_Create = (findExternal("mkswap")) ? cmdSupportFileSystem : cmdSupportNone;
m_SetLabel = m_Shrink = m_Grow = m_Create = m_UpdateUUID = (findExternal("mkswap")) ? cmdSupportFileSystem : cmdSupportNone;
m_GetLabel = cmdSupportCore;
m_Copy = cmdSupportCore;
m_Copy = cmdSupportFileSystem;
m_Move = cmdSupportCore;
m_GetUUID = cmdSupportCore;
}
@ -56,7 +57,7 @@ namespace FS
m_SetLabel != cmdSupportNone &&
m_Create != cmdSupportNone &&
// m_Check != cmdSupportNone &&
// m_UpdateUUID != cmdSupportNone &&
m_UpdateUUID != cmdSupportNone &&
m_Grow != cmdSupportNone &&
m_Shrink != cmdSupportNone &&
m_Copy != cmdSupportNone &&
@ -76,7 +77,7 @@ namespace FS
return cmd.run(-1) && cmd.exitCode() == 0;
}
bool linuxswap::resize(Report& report, const QString& deviceNode, qint64) const
bool linuxswap::resize(Report& report, const QString& deviceNode, qint64 length) const
{
const QString label = readLabel(deviceNode);
const QString uuid = readUUID(deviceNode);
@ -87,7 +88,24 @@ namespace FS
if (!uuid.isEmpty())
args << "-U" << uuid;
args << deviceNode;
args << deviceNode << QString::number(length / 1024);
ExternalCommand cmd(report, "mkswap", args);
return cmd.run(-1) && cmd.exitCode() == 0;
}
bool linuxswap::copy(Report& report, const QString& targetDeviceNode, const QString& sourceDeviceNode) const
{
const QString label = readLabel(sourceDeviceNode);
const QString uuid = readUUID(sourceDeviceNode);
QStringList args;
if (!label.isEmpty())
args << "-L" << label;
if (!uuid.isEmpty())
args << "-U" << uuid;
args << targetDeviceNode;
ExternalCommand cmd(report, "mkswap", args);
return cmd.run(-1) && cmd.exitCode() == 0;
@ -120,4 +138,18 @@ namespace FS
ExternalCommand cmd("swapoff", QStringList() << deviceNode);
return cmd.run(-1) && cmd.exitCode() == 0;
}
bool linuxswap::updateUUID(Report& report, const QString& deviceNode) const
{
const QString label = readLabel(deviceNode);
QStringList args;
if (!label.isEmpty())
args << "-L" << label;
args << deviceNode;
ExternalCommand cmd(report, "mkswap", args);
return cmd.run(-1) && cmd.exitCode() == 0;
}
}

View File

@ -47,6 +47,8 @@ namespace FS
virtual bool create(Report& report, const QString& deviceNode) const;
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
virtual bool copy(Report& report, const QString& targetDeviceNode, const QString& sourceDeviceNode) const;
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
virtual bool canMount(const QString&) const { return true; }
virtual bool canUnmount(const QString&) const { return true; }
@ -64,6 +66,7 @@ namespace FS
virtual CommandSupportType supportCopy() const { return m_Copy; }
virtual CommandSupportType supportGetLabel() const { return m_GetLabel; }
virtual CommandSupportType supportSetLabel() const { return m_SetLabel; }
virtual CommandSupportType supportUpdateUUID() const { return m_UpdateUUID; }
virtual CommandSupportType supportGetUUID() const { return m_GetUUID; }
virtual SupportTool supportToolName() const;
@ -77,6 +80,7 @@ namespace FS
static CommandSupportType m_Copy;
static CommandSupportType m_SetLabel;
static CommandSupportType m_GetLabel;
static CommandSupportType m_UpdateUUID;
static CommandSupportType m_GetUUID;
};
}