File indexing completed on 2024-05-05 05:48:43
0001 /* 0002 SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2012-2018 Andrius Štikonas <andrius@stikonas.eu> 0004 SPDX-FileCopyrightText: 2020 Arnaud Ferraris <arnaud.ferraris@collabora.com> 0005 SPDX-FileCopyrightText: 2020 Gaël PORTAY <gael.portay@collabora.com> 0006 0007 SPDX-License-Identifier: GPL-3.0-or-later 0008 */ 0009 0010 #include "fs/ext3.h" 0011 0012 #include "util/externalcommand.h" 0013 #include "util/capacity.h" 0014 0015 #include <QStringList> 0016 0017 namespace FS 0018 { 0019 ext3::ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) : 0020 ext2(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Ext3) 0021 { 0022 } 0023 0024 qint64 ext3::maxCapacity() const 0025 { 0026 return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); 0027 } 0028 0029 bool ext3::create(Report& report, const QString& deviceNode) 0030 { 0031 QStringList args = QStringList(); 0032 0033 if (!this->features().isEmpty()) { 0034 QStringList feature_list = QStringList(); 0035 for (const auto& k : this->features().keys()) { 0036 const auto& v = this->features().value(k); 0037 if (v.type() == QVariant::Type::Bool) { 0038 if (v.toBool()) 0039 feature_list << k; 0040 else 0041 feature_list << (QStringLiteral("^") + k); 0042 } else { 0043 qWarning() << "Ignoring feature" << k << "of type" << v.type() << "; requires type QVariant::bool."; 0044 } 0045 } 0046 args << QStringLiteral("-O") << feature_list.join(QStringLiteral(",")); 0047 } 0048 args << QStringLiteral("-qF") << deviceNode; 0049 0050 ExternalCommand cmd(report, QStringLiteral("mkfs.ext3"), args); 0051 return cmd.run(-1) && cmd.exitCode() == 0; 0052 } 0053 0054 bool ext3::resizeOnline(Report& report, const QString& deviceNode, const QString&, qint64 length) const 0055 { 0056 return resize(report, deviceNode, length); 0057 } 0058 }