add filesystem support for zfs, hpfs, ocfs2, luks and btrfs

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1127754
This commit is contained in:
Volker Lanz 2010-05-17 14:36:18 +00:00
parent bff6424cf6
commit 319a44ae64
16 changed files with 1099 additions and 117 deletions

View File

@ -60,24 +60,30 @@
</entry>
<entry key="fileSystemColorCode$(colorNumber)" type="Color">
<label context="@label">File system colors</label>
<parameter name="colorNumber" type="UInt" max="16"/>
<default param="0">252,242,220</default>
<default param="1">187,249,207</default>
<default param="2">122,145,180</default>
<default param="3">143,169,210</default>
<default param="4">173,205,255</default>
<default param="5">155,155,130</default>
<default param="6">204,179,215</default>
<default param="7">229,201,240</default>
<default param="8">244,214,255</default>
<default param="9">216,220,135</default>
<default param="10">251,255,157</default>
<default param="11">200,255,254</default>
<default param="12">137,200,198</default>
<default param="13">210,136,142</default>
<default param="14">240,165,171</default>
<default param="15">151,220,134</default>
<default param="16">252,242,222</default>
<parameter name="colorNumber" type="UInt" max="21"/>
<!-- numbers correspond to the enum in fs/filesystem.h -->
<default param="0">252,242,220</default> <!-- unknown -->
<default param="1">187,249,207</default> <!-- extended -->
<default param="2">102,121,150</default> <!-- ext2 -->
<default param="3">122,145,180</default> <!-- ext3 -->
<default param="4">143,170,210</default> <!-- ext4 -->
<default param="5">155,155,130</default> <!-- swap -->
<default param="6">204,179,215</default> <!-- fat16 -->
<default param="7">229,201,240</default> <!-- fat32 -->
<default param="8">244,214,255</default> <!-- ntfs -->
<default param="9">216,220,135</default> <!-- reiser-->
<default param="10">251,255,157</default> <!-- reiser4 -->
<default param="11">200,255,254</default> <!-- xfs -->
<default param="12">137,200,198</default> <!-- jfs -->
<default param="13">210,136,142</default> <!-- hfs -->
<default param="14">240,165,171</default> <!-- hfs+ -->
<default param="15">151,220,134</default> <!-- ufs -->
<default param="16">252,242,222</default> <!-- unformatted -->
<default param="17">173,205,255</default> <!-- btrfs -->
<default param="18">176,155,185</default> <!-- hpfs -->
<default param="19">170,30,77</default> <!-- luks -->
<default param="20">96,140,85</default> <!-- ocfs2 -->
<default param="21">33,137,108</default> <!-- zfs -->
</entry>
<entry key="availableSpaceColorCode" type="Color">
<label context="@label">Color for available space</label>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>509</width>
<height>504</height>
<width>449</width>
<height>457</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@ -98,9 +98,9 @@
<widget class="KColorButton" name="kcfg_fileSystemColorCode4"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="textLabel_4">
<widget class="QLabel" name="textLabel_21">
<property name="text">
<string>linuxswap:</string>
<string>btrfs:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
@ -111,9 +111,38 @@
</widget>
</item>
<item row="1" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode5"/>
<widget class="KColorButton" name="kcfg_fileSystemColorCode17"/>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_15">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>37</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QLabel" name="textLabel_20">
<property name="text">
<string>luks:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode19"/>
</item>
<item row="1" column="5">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -126,7 +155,23 @@
</property>
</spacer>
</item>
<item row="1" column="3">
<item row="1" column="6">
<widget class="QLabel" name="textLabel_4">
<property name="text">
<string>linuxswap:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode5"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="textLabel_6">
<property name="text">
<string>fat16:</string>
@ -139,10 +184,10 @@
</property>
</widget>
</item>
<item row="1" column="4">
<item row="2" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode6"/>
</item>
<item row="1" column="5">
<item row="2" column="2">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -155,7 +200,7 @@
</property>
</spacer>
</item>
<item row="1" column="6">
<item row="2" column="3">
<widget class="QLabel" name="textLabel_5">
<property name="text">
<string>fat32:</string>
@ -168,10 +213,23 @@
</property>
</widget>
</item>
<item row="1" column="7">
<item row="2" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode7"/>
</item>
<item row="2" column="0">
<item row="2" column="5">
<spacer name="horizontalSpacer_16">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>28</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="6">
<widget class="QLabel" name="textLabel_9">
<property name="text">
<string>ntfs:</string>
@ -184,23 +242,10 @@
</property>
</widget>
</item>
<item row="2" column="1">
<item row="2" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode8"/>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>28</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="3">
<item row="3" column="3">
<widget class="QLabel" name="textLabel_7">
<property name="text">
<string>reiserfs:</string>
@ -213,10 +258,10 @@
</property>
</widget>
</item>
<item row="2" column="4">
<item row="3" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode9"/>
</item>
<item row="2" column="5">
<item row="3" column="5">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -229,7 +274,7 @@
</property>
</spacer>
</item>
<item row="2" column="6">
<item row="3" column="6">
<widget class="QLabel" name="textLabel_8">
<property name="text">
<string>reiser4:</string>
@ -242,27 +287,11 @@
</property>
</widget>
</item>
<item row="2" column="7">
<item row="3" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode10"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="textLabel_10">
<property name="text">
<string>xfs:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode11"/>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_7">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -274,7 +303,23 @@
</property>
</spacer>
</item>
<item row="3" column="3">
<item row="3" column="0">
<widget class="QLabel" name="textLabel_10">
<property name="text">
<string>hpfs:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode18"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="textLabel_11">
<property name="text">
<string>jfs</string>
@ -287,10 +332,10 @@
</property>
</widget>
</item>
<item row="3" column="4">
<item row="4" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode12"/>
</item>
<item row="3" column="5">
<item row="4" column="2">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -303,7 +348,7 @@
</property>
</spacer>
</item>
<item row="3" column="6">
<item row="4" column="3">
<widget class="QLabel" name="textLabel_12">
<property name="text">
<string>hfs:</string>
@ -316,10 +361,23 @@
</property>
</widget>
</item>
<item row="3" column="7">
<item row="4" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode13"/>
</item>
<item row="4" column="0">
<item row="4" column="5">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>28</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="6">
<widget class="QLabel" name="textLabel_14">
<property name="text">
<string>hfsplus:</string>
@ -332,23 +390,10 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="4" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode14"/>
</item>
<item row="4" column="2">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>28</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="3">
<item row="5" column="0">
<widget class="QLabel" name="textLabel_15">
<property name="text">
<string>ufs:</string>
@ -361,10 +406,10 @@
</property>
</widget>
</item>
<item row="4" column="4">
<item row="5" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode15"/>
</item>
<item row="4" column="5">
<item row="5" column="2">
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -377,7 +422,81 @@
</property>
</spacer>
</item>
<item row="4" column="6">
<item row="5" column="3">
<widget class="QLabel" name="textLabel_22">
<property name="text">
<string>xfs:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode11"/>
</item>
<item row="5" column="5">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>28</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="6">
<widget class="QLabel" name="textLabel_24">
<property name="text">
<string>ocfs2:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode20"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="textLabel_25">
<property name="text">
<string>zfs:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode21"/>
</item>
<item row="6" column="2" colspan="6">
<spacer name="horizontalSpacer_17">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>173</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="0">
<widget class="QLabel" name="textLabel_13">
<property name="text">
<string>extended:</string>
@ -390,26 +509,10 @@
</property>
</widget>
</item>
<item row="4" column="7">
<item row="8" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode1"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="textLabel_16">
<property name="text">
<string>unknown:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="KColorButton" name="kcfg_fileSystemColorCode0"/>
</item>
<item row="5" column="2">
<item row="8" column="2">
<spacer name="horizontalSpacer_12">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -422,7 +525,7 @@
</property>
</spacer>
</item>
<item row="5" column="3">
<item row="8" column="3">
<widget class="QLabel" name="textLabel_17">
<property name="text">
<string>unformatted:</string>
@ -435,22 +538,45 @@
</property>
</widget>
</item>
<item row="5" column="4">
<item row="8" column="4">
<widget class="KColorButton" name="kcfg_fileSystemColorCode16"/>
</item>
<item row="5" column="5" colspan="3">
<item row="8" column="5">
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>176</width>
<width>21</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="6">
<widget class="QLabel" name="textLabel_16">
<property name="text">
<string>unknown:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="8" column="7">
<widget class="KColorButton" name="kcfg_fileSystemColorCode0"/>
</item>
<item row="7" column="0" colspan="8">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -518,7 +644,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>167</width>
<width>23</width>
<height>21</height>
</size>
</property>

122
src/fs/btrfs.cpp Normal file
View File

@ -0,0 +1,122 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "fs/btrfs.h"
#include "util/externalcommand.h"
#include "util/capacity.h"
#include <QString>
#include <QRegExp>
namespace FS
{
FileSystem::CommandSupportType btrfs::m_GetUsed = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_GetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_Create = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_Grow = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_Shrink = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_Move = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_Check = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_Copy = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_Backup = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType btrfs::m_GetUUID = FileSystem::cmdSupportNone;
btrfs::btrfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Btrfs)
{
}
void btrfs::init()
{
m_Create = findExternal("mkfs.btrfs") ? cmdSupportFileSystem : cmdSupportNone;
m_Check = findExternal("fsck.btrfs", QStringList(), 1) ? cmdSupportFileSystem : cmdSupportNone;
m_Grow = (m_Check != cmdSupportNone && findExternal("btrfsctl")) ? cmdSupportFileSystem : cmdSupportNone;
m_Shrink = (m_Grow != cmdSupportNone && m_GetUsed != cmdSupportNone) ? cmdSupportFileSystem : cmdSupportNone;
m_GetUsed = findExternal("btrfs-debug-tree") ? cmdSupportFileSystem : cmdSupportNone;
// TODO: are those not possible with btrfs (yet)?
m_SetLabel = cmdSupportNone;
m_UpdateUUID = cmdSupportNone;
m_Copy = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone;
m_Move = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone;
m_GetLabel = cmdSupportCore;
m_Backup = cmdSupportCore;
m_GetUUID = cmdSupportCore;
}
qint64 btrfs::maxCapacity() const
{
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
}
qint64 btrfs::readUsedCapacity(const QString& deviceNode) const
{
ExternalCommand cmd("btrfs-debug-tree", QStringList() << deviceNode);
if (cmd.run())
{
QRegExp rxBytesUsed("\nbytes used (\\d+)");
if (rxBytesUsed.indexIn(cmd.output()) != -1)
return rxBytesUsed.cap(1).toLongLong();
}
return -1;
}
bool btrfs::check(Report& report, const QString& deviceNode) const
{
ExternalCommand cmd(report, "btrfsck", QStringList() << deviceNode);
return cmd.run(-1) && cmd.exitCode() == 0;
}
bool btrfs::create(Report& report, const QString& deviceNode) const
{
ExternalCommand cmd(report, "mkfs.btrfs", QStringList() << deviceNode);
return cmd.run(-1) && cmd.exitCode() == 0;
}
bool btrfs::resize(Report& report, const QString& deviceNode, qint64 length) const
{
ExternalCommand cmd(report, "btrfsctl", QStringList() << deviceNode << "-r" << QString::number(length));
return cmd.run(-1) && cmd.exitCode() == 0;
}
bool btrfs::writeLabel(Report& report, const QString& deviceNode, const QString& newLabel)
{
Q_UNUSED(report);
Q_UNUSED(deviceNode);
Q_UNUSED(newLabel);
return false;
}
bool btrfs::updateUUID(Report& report, const QString& deviceNode) const
{
Q_UNUSED(report);
Q_UNUSED(deviceNode);
return false;
}
}

85
src/fs/btrfs.h Normal file
View File

@ -0,0 +1,85 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#if !defined(BTRFS__H)
#define BTRFS__H
#include "util/libpartitionmanagerexport.h"
#include "fs/filesystem.h"
#include <qglobal.h>
class Report;
class QString;
namespace FS
{
/** @brief A btrfs file system.
@author vl@fidra.de
*/
class LIBPARTITIONMANAGERPRIVATE_EXPORT btrfs : public FileSystem
{
public:
btrfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
public:
static void init();
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
virtual bool check(Report& report, const QString& deviceNode) const;
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 updateUUID(Report& report, const QString& deviceNode) const;
virtual CommandSupportType supportGetUsed() const { return m_GetUsed; }
virtual CommandSupportType supportGetLabel() const { return m_GetLabel; }
virtual CommandSupportType supportCreate() const { return m_Create; }
virtual CommandSupportType supportGrow() const { return m_Grow; }
virtual CommandSupportType supportShrink() const { return m_Shrink; }
virtual CommandSupportType supportMove() const { return m_Move; }
virtual CommandSupportType supportCheck() const { return m_Check; }
virtual CommandSupportType supportCopy() const { return m_Copy; }
virtual CommandSupportType supportBackup() const { return m_Backup; }
virtual CommandSupportType supportSetLabel() const { return m_SetLabel; }
virtual CommandSupportType supportUpdateUUID() const { return m_UpdateUUID; }
virtual CommandSupportType supportGetUUID() const { return m_GetUUID; }
virtual qint64 maxCapacity() const;
public:
static CommandSupportType m_GetUsed;
static CommandSupportType m_GetLabel;
static CommandSupportType m_Create;
static CommandSupportType m_Grow;
static CommandSupportType m_Shrink;
static CommandSupportType m_Move;
static CommandSupportType m_Check;
static CommandSupportType m_Copy;
static CommandSupportType m_Backup;
static CommandSupportType m_SetLabel;
static CommandSupportType m_UpdateUUID;
static CommandSupportType m_GetUUID;
};
}
#endif

View File

@ -233,9 +233,6 @@ QString FileSystem::name() const
/** @return a pointer to a QString C array with all FileSystem names */
static const QString* typeNames()
{
// The KDE localization framework doesn't like this array if it's
// just declared static outside any function. If we do it here,
// it seems to work fine. That's why this is done so strangely here.
static const QString s[] =
{
i18nc("@item/plain filesystem name", "unknown"),
@ -255,7 +252,12 @@ static const QString* typeNames()
i18nc("@item/plain filesystem name", "hfs"),
i18nc("@item/plain filesystem name", "hfsplus"),
i18nc("@item/plain filesystem name", "ufs"),
i18nc("@item/plain filesystem name", "unformatted")
i18nc("@item/plain filesystem name", "unformatted"),
i18nc("@item/plain filesystem name", "btrfs"),
i18nc("@item/plain filesystem name", "hpfs"),
i18nc("@item/plain filesystem name", "luks"),
i18nc("@item/plain filesystem name", "ocfs2"),
i18nc("@item/plain filesystem name", "zfs"),
};
return s;

View File

@ -62,8 +62,13 @@ class FileSystem
HfsPlus = 14,
Ufs = 15,
Unformatted = 16,
Btrfs = 17,
Hpfs = 18,
Luks = 19,
Ocfs2 = 20,
Zfs = 21,
__lastType = 17
__lastType = 22
};
/** The type of support for a given FileSystem action */

View File

@ -20,6 +20,7 @@
#include "fs/filesystemfactory.h"
#include "fs/filesystem.h"
#include "fs/btrfs.h"
#include "fs/ext2.h"
#include "fs/ext3.h"
#include "fs/ext4.h"
@ -28,15 +29,19 @@
#include "fs/fat32.h"
#include "fs/hfs.h"
#include "fs/hfsplus.h"
#include "fs/hpfs.h"
#include "fs/jfs.h"
#include "fs/linuxswap.h"
#include "fs/luks.h"
#include "fs/ntfs.h"
#include "fs/ocfs2.h"
#include "fs/reiser4.h"
#include "fs/reiserfs.h"
#include "fs/ufs.h"
#include "fs/unformatted.h"
#include "fs/unknown.h"
#include "fs/xfs.h"
#include "fs/zfs.h"
#include "backend/corebackendmanager.h"
#include "backend/corebackend.h"
@ -49,6 +54,7 @@ void FileSystemFactory::init()
qDeleteAll(m_FileSystems);
m_FileSystems.clear();
m_FileSystems.insert(FileSystem::Btrfs, new FS::btrfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Ext2, new FS::ext2(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Ext3, new FS::ext3(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Ext4, new FS::ext4(-1, -1, -1, QString()));
@ -57,16 +63,21 @@ void FileSystemFactory::init()
m_FileSystems.insert(FileSystem::Fat32, new FS::fat32(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Hfs, new FS::hfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::HfsPlus, new FS::hfsplus(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Hpfs, new FS::hpfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Jfs, new FS::jfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::LinuxSwap, new FS::linuxswap(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Luks, new FS::luks(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Ntfs, new FS::ntfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Ocfs2, new FS::ocfs2(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::ReiserFS, new FS::reiserfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Reiser4, new FS::reiser4(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Ufs, new FS::ufs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Unformatted, new FS::unformatted(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Unknown, new FS::unknown(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Xfs, new FS::xfs(-1, -1, -1, QString()));
m_FileSystems.insert(FileSystem::Zfs, new FS::zfs(-1, -1, -1, QString()));
FS::btrfs::init();
FS::ext2::init();
FS::ext3::init();
FS::ext4::init();
@ -75,15 +86,19 @@ void FileSystemFactory::init()
FS::fat32::init();
FS::hfs::init();
FS::hfsplus::init();
FS::hpfs::init();
FS::jfs::init();
FS::linuxswap::init();
FS::luks::init();
FS::ntfs::init();
FS::ocfs2::init();
FS::reiserfs::init();
FS::reiser4::init();
FS::ufs::init();
FS::unformatted::init();
FS::unknown::init();
FS::xfs::init();
FS::zfs::init();
CoreBackendManager::self()->backend()->initFSSupport();
}
@ -102,6 +117,7 @@ FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qi
switch(t)
{
case FileSystem::Btrfs: fs = new FS::btrfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Ext2: fs = new FS::ext2(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Ext3: fs = new FS::ext3(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Ext4: fs = new FS::ext4(firstsector, lastsector, sectorsused, label); break;
@ -110,15 +126,19 @@ FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qi
case FileSystem::Fat32: fs = new FS::fat32(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Hfs: fs = new FS::hfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::HfsPlus: fs = new FS::hfsplus(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Hpfs: fs = new FS::hpfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Jfs: fs = new FS::jfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::LinuxSwap: fs = new FS::linuxswap(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Luks: fs = new FS::luks(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Ntfs: fs = new FS::ntfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Ocfs2: fs = new FS::ocfs2(firstsector, lastsector, sectorsused, label); break;
case FileSystem::ReiserFS: fs = new FS::reiserfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Reiser4: fs = new FS::reiser4(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Ufs: fs = new FS::ufs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Unformatted: fs = new FS::unformatted(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Unknown: fs = new FS::unknown(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Xfs: fs = new FS::xfs(firstsector, lastsector, sectorsused, label); break;
case FileSystem::Zfs: fs = new FS::zfs(firstsector, lastsector, sectorsused, label); break;
default: break;
}

54
src/fs/hpfs.cpp Normal file
View File

@ -0,0 +1,54 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "fs/hpfs.h"
#include "util/capacity.h"
#include <QString>
namespace FS
{
FileSystem::CommandSupportType hpfs::m_GetUsed = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_GetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_Create = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_Grow = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_Shrink = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_Move = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_Check = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_Copy = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_Backup = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType hpfs::m_GetUUID = FileSystem::cmdSupportNone;
hpfs::hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Hpfs)
{
}
void hpfs::init()
{
}
qint64 hpfs::maxCapacity() const
{
return 2 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
}
}

78
src/fs/hpfs.h Normal file
View File

@ -0,0 +1,78 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#if !defined(HPFS__H)
#define HPFS__H
#include "util/libpartitionmanagerexport.h"
#include "fs/filesystem.h"
#include <qglobal.h>
class Report;
class QString;
namespace FS
{
/** @brief A hpfs file system.
@author vl@fidra.de
*/
class LIBPARTITIONMANAGERPRIVATE_EXPORT hpfs : public FileSystem
{
public:
hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
public:
static void init();
virtual CommandSupportType supportGetUsed() const { return m_GetUsed; }
virtual CommandSupportType supportGetLabel() const { return m_GetLabel; }
virtual CommandSupportType supportCreate() const { return m_Create; }
virtual CommandSupportType supportGrow() const { return m_Grow; }
virtual CommandSupportType supportShrink() const { return m_Shrink; }
virtual CommandSupportType supportMove() const { return m_Move; }
virtual CommandSupportType supportCheck() const { return m_Check; }
virtual CommandSupportType supportCopy() const { return m_Copy; }
virtual CommandSupportType supportBackup() const { return m_Backup; }
virtual CommandSupportType supportSetLabel() const { return m_SetLabel; }
virtual CommandSupportType supportUpdateUUID() const { return m_UpdateUUID; }
virtual CommandSupportType supportGetUUID() const { return m_GetUUID; }
virtual qint64 maxCapacity() const;
public:
static CommandSupportType m_GetUsed;
static CommandSupportType m_GetLabel;
static CommandSupportType m_Create;
static CommandSupportType m_Grow;
static CommandSupportType m_Shrink;
static CommandSupportType m_Move;
static CommandSupportType m_Check;
static CommandSupportType m_Copy;
static CommandSupportType m_Backup;
static CommandSupportType m_SetLabel;
static CommandSupportType m_UpdateUUID;
static CommandSupportType m_GetUUID;
};
}
#endif

54
src/fs/luks.cpp Normal file
View File

@ -0,0 +1,54 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "fs/luks.h"
#include "util/capacity.h"
#include <QString>
namespace FS
{
FileSystem::CommandSupportType luks::m_GetUsed = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType luks::m_GetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType luks::m_Create = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType luks::m_Grow = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType luks::m_Shrink = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType luks::m_Move = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType luks::m_Check = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType luks::m_Copy = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType luks::m_Backup = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType luks::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType luks::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType luks::m_GetUUID = FileSystem::cmdSupportNone;
luks::luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Luks)
{
}
void luks::init()
{
}
qint64 luks::maxCapacity() const
{
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
}
}

78
src/fs/luks.h Normal file
View File

@ -0,0 +1,78 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#if !defined(LUKS__H)
#define LUKS__H
#include "util/libpartitionmanagerexport.h"
#include "fs/filesystem.h"
#include <qglobal.h>
class Report;
class QString;
namespace FS
{
/** @brief A LUKS crypto file system.
@author vl@fidra.de
*/
class LIBPARTITIONMANAGERPRIVATE_EXPORT luks : public FileSystem
{
public:
luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
public:
static void init();
virtual CommandSupportType supportGetUsed() const { return m_GetUsed; }
virtual CommandSupportType supportGetLabel() const { return m_GetLabel; }
virtual CommandSupportType supportCreate() const { return m_Create; }
virtual CommandSupportType supportGrow() const { return m_Grow; }
virtual CommandSupportType supportShrink() const { return m_Shrink; }
virtual CommandSupportType supportMove() const { return m_Move; }
virtual CommandSupportType supportCheck() const { return m_Check; }
virtual CommandSupportType supportCopy() const { return m_Copy; }
virtual CommandSupportType supportBackup() const { return m_Backup; }
virtual CommandSupportType supportSetLabel() const { return m_SetLabel; }
virtual CommandSupportType supportUpdateUUID() const { return m_UpdateUUID; }
virtual CommandSupportType supportGetUUID() const { return m_GetUUID; }
virtual qint64 maxCapacity() const;
public:
static CommandSupportType m_GetUsed;
static CommandSupportType m_GetLabel;
static CommandSupportType m_Create;
static CommandSupportType m_Grow;
static CommandSupportType m_Shrink;
static CommandSupportType m_Move;
static CommandSupportType m_Check;
static CommandSupportType m_Copy;
static CommandSupportType m_Backup;
static CommandSupportType m_SetLabel;
static CommandSupportType m_UpdateUUID;
static CommandSupportType m_GetUUID;
};
}
#endif

130
src/fs/ocfs2.cpp Normal file
View File

@ -0,0 +1,130 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "fs/ocfs2.h"
#include "util/externalcommand.h"
#include "util/capacity.h"
#include <QString>
#include <QRegExp>
#include <kdebug.h>
namespace FS
{
FileSystem::CommandSupportType ocfs2::m_GetUsed = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_GetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_Create = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_Grow = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_Shrink = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_Move = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_Check = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_Copy = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_Backup = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType ocfs2::m_GetUUID = FileSystem::cmdSupportNone;
ocfs2::ocfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Ocfs2)
{
}
void ocfs2::init()
{
m_Create = findExternal("mkfs.ocfs2", QStringList() << "-V") ? cmdSupportFileSystem : cmdSupportNone;
m_Check = findExternal("fsck.ocfs2", QStringList(), 16) ? cmdSupportFileSystem : cmdSupportNone;
m_Grow = (m_Check != cmdSupportNone && findExternal("tunefs.ocfs2", QStringList() << "-V") && findExternal("debugfs.ocfs2", QStringList() << "-V")) ? cmdSupportFileSystem : cmdSupportNone;
m_Shrink = cmdSupportNone;
// TODO: it seems there's no way to get the FS usage with ocfs2
m_GetUsed = cmdSupportNone;
m_SetLabel = findExternal("tunefs.ocfs2", QStringList() << "-V") ? cmdSupportFileSystem : cmdSupportNone;
m_UpdateUUID = findExternal("tunefs.ocfs2", QStringList() << "-V") ? cmdSupportFileSystem : cmdSupportNone;
m_Copy = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone;
m_Move = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone;
m_GetLabel = cmdSupportCore;
m_Backup = cmdSupportCore;
m_GetUUID = cmdSupportCore;
}
qint64 ocfs2::maxCapacity() const
{
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
}
qint64 ocfs2::readUsedCapacity(const QString& deviceNode) const
{
Q_UNUSED(deviceNode);
return -1;
}
bool ocfs2::check(Report& report, const QString& deviceNode) const
{
ExternalCommand cmd(report, "fsck.ocfs2", QStringList() << "-f" << "-y" << deviceNode);
return cmd.run(-1) && (cmd.exitCode() == 0 || cmd.exitCode() == 1 || cmd.exitCode() == 2);
}
bool ocfs2::create(Report& report, const QString& deviceNode) const
{
ExternalCommand cmd(report, "mkfs.ocfs2", QStringList() << deviceNode);
cmd.start();
cmd.write("y\n");
cmd.waitFor(-1);
return cmd.exitCode() == 0;
}
bool ocfs2::resize(Report& report, const QString& deviceNode, qint64 length) const
{
ExternalCommand cmdBlockSize("debugfs.ocfs2", QStringList() << "-R" << "stats" << deviceNode);
qint32 blockSize = -1;
if (cmdBlockSize.run())
{
QRegExp rxBlockSizeBits("Block Size Bits: (\\d+)");
if (rxBlockSizeBits.indexIn(cmdBlockSize.output()) != -1)
blockSize = 1 << rxBlockSizeBits.cap(1).toInt();
}
if (blockSize == -1)
return false;
ExternalCommand cmd(report, "tunefs.ocfs2", QStringList() << "-y" << "-S" << deviceNode << QString::number(length / blockSize));
return cmd.run(-1) && cmd.exitCode() == 0;
}
bool ocfs2::writeLabel(Report& report, const QString& deviceNode, const QString& newLabel)
{
ExternalCommand cmd(report, "tunefs.ocfs2", QStringList() << "-L" << newLabel << deviceNode);
return cmd.run(-1) && cmd.exitCode() == 0;
}
bool ocfs2::updateUUID(Report& report, const QString& deviceNode) const
{
ExternalCommand cmd(report, "tunefs.ocfs2", QStringList() << "-U" << deviceNode);
return cmd.run(-1) && cmd.exitCode() == 0;
}
}

85
src/fs/ocfs2.h Normal file
View File

@ -0,0 +1,85 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#if !defined(OCFS2__H)
#define OCFS2__H
#include "util/libpartitionmanagerexport.h"
#include "fs/filesystem.h"
#include <qglobal.h>
class Report;
class QString;
namespace FS
{
/** @brief A ocfs2 file system.
@author vl@fidra.de
*/
class LIBPARTITIONMANAGERPRIVATE_EXPORT ocfs2 : public FileSystem
{
public:
ocfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
public:
static void init();
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
virtual bool check(Report& report, const QString& deviceNode) const;
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 updateUUID(Report& report, const QString& deviceNode) const;
virtual CommandSupportType supportGetUsed() const { return m_GetUsed; }
virtual CommandSupportType supportGetLabel() const { return m_GetLabel; }
virtual CommandSupportType supportCreate() const { return m_Create; }
virtual CommandSupportType supportGrow() const { return m_Grow; }
virtual CommandSupportType supportShrink() const { return m_Shrink; }
virtual CommandSupportType supportMove() const { return m_Move; }
virtual CommandSupportType supportCheck() const { return m_Check; }
virtual CommandSupportType supportCopy() const { return m_Copy; }
virtual CommandSupportType supportBackup() const { return m_Backup; }
virtual CommandSupportType supportSetLabel() const { return m_SetLabel; }
virtual CommandSupportType supportUpdateUUID() const { return m_UpdateUUID; }
virtual CommandSupportType supportGetUUID() const { return m_GetUUID; }
virtual qint64 maxCapacity() const;
public:
static CommandSupportType m_GetUsed;
static CommandSupportType m_GetLabel;
static CommandSupportType m_Create;
static CommandSupportType m_Grow;
static CommandSupportType m_Shrink;
static CommandSupportType m_Move;
static CommandSupportType m_Check;
static CommandSupportType m_Copy;
static CommandSupportType m_Backup;
static CommandSupportType m_SetLabel;
static CommandSupportType m_UpdateUUID;
static CommandSupportType m_GetUUID;
};
}
#endif

54
src/fs/zfs.cpp Normal file
View File

@ -0,0 +1,54 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "fs/zfs.h"
#include "util/capacity.h"
#include <QString>
namespace FS
{
FileSystem::CommandSupportType zfs::m_GetUsed = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_GetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_Create = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_Grow = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_Shrink = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_Move = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_Check = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_Copy = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_Backup = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_SetLabel = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_UpdateUUID = FileSystem::cmdSupportNone;
FileSystem::CommandSupportType zfs::m_GetUUID = FileSystem::cmdSupportNone;
zfs::zfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Zfs)
{
}
void zfs::init()
{
}
qint64 zfs::maxCapacity() const
{
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
}
}

78
src/fs/zfs.h Normal file
View File

@ -0,0 +1,78 @@
/***************************************************************************
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#if !defined(ZFS__H)
#define ZFS__H
#include "util/libpartitionmanagerexport.h"
#include "fs/filesystem.h"
#include <qglobal.h>
class Report;
class QString;
namespace FS
{
/** @brief A zfs file system.
@author vl@fidra.de
*/
class LIBPARTITIONMANAGERPRIVATE_EXPORT zfs : public FileSystem
{
public:
zfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
public:
static void init();
virtual CommandSupportType supportGetUsed() const { return m_GetUsed; }
virtual CommandSupportType supportGetLabel() const { return m_GetLabel; }
virtual CommandSupportType supportCreate() const { return m_Create; }
virtual CommandSupportType supportGrow() const { return m_Grow; }
virtual CommandSupportType supportShrink() const { return m_Shrink; }
virtual CommandSupportType supportMove() const { return m_Move; }
virtual CommandSupportType supportCheck() const { return m_Check; }
virtual CommandSupportType supportCopy() const { return m_Copy; }
virtual CommandSupportType supportBackup() const { return m_Backup; }
virtual CommandSupportType supportSetLabel() const { return m_SetLabel; }
virtual CommandSupportType supportUpdateUUID() const { return m_UpdateUUID; }
virtual CommandSupportType supportGetUUID() const { return m_GetUUID; }
virtual qint64 maxCapacity() const;
public:
static CommandSupportType m_GetUsed;
static CommandSupportType m_GetLabel;
static CommandSupportType m_Create;
static CommandSupportType m_Grow;
static CommandSupportType m_Shrink;
static CommandSupportType m_Move;
static CommandSupportType m_Check;
static CommandSupportType m_Copy;
static CommandSupportType m_Backup;
static CommandSupportType m_SetLabel;
static CommandSupportType m_UpdateUUID;
static CommandSupportType m_GetUUID;
};
}
#endif

View File

@ -526,6 +526,11 @@ FileSystem::Type LibPartedBackend::detectFileSystem(PedPartition* pedPartition)
else if (strcmp(pedPartition->fs_type->name, "fat32") == 0)
rval = FileSystem::Fat32;
}
else if (s == "btrfs") rval = FileSystem::Btrfs;
else if (s == "ocfs2") rval = FileSystem::Ocfs2;
else if (s == "zfs") rval = FileSystem::Zfs;
else if (s == "hpfs") rval = FileSystem::Hpfs;
else if (s == "crypto_LUKS") rval = FileSystem::Luks;
else
kWarning() << "blkid: unknown file system type " << s << " on " << pedPath;
}