2020-09-28 00:45:21 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2008-2011 Volker Lanz <vl@fidra.de>
|
|
|
|
SPDX-FileCopyrightText: 2013-2018 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2020 Arnaud Ferraris <arnaud.ferraris@collabora.com>
|
|
|
|
SPDX-FileCopyrightText: 2020 Gaël PORTAY <gael.portay@collabora.com>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2018-11-25 20:50:22 +00:00
|
|
|
|
2015-06-04 01:29:22 +01:00
|
|
|
#include "fs/fat32.h"
|
|
|
|
|
|
|
|
#include "util/externalcommand.h"
|
|
|
|
#include "util/capacity.h"
|
|
|
|
|
2019-06-12 17:41:11 +01:00
|
|
|
#include <QStringList>
|
|
|
|
|
2015-06-04 01:29:22 +01:00
|
|
|
#include <ctime>
|
|
|
|
|
|
|
|
namespace FS
|
|
|
|
{
|
2020-03-21 13:18:13 +00:00
|
|
|
fat32::fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
2020-01-12 11:54:14 +00:00
|
|
|
fat16(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Fat32)
|
2015-07-13 15:16:36 +01:00
|
|
|
{
|
|
|
|
}
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
qint64 fat32::minCapacity() const
|
|
|
|
{
|
2018-04-09 15:14:34 +01:00
|
|
|
return 32 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
2015-07-13 15:16:36 +01:00
|
|
|
}
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
qint64 fat32::maxCapacity() const
|
|
|
|
{
|
2018-04-09 15:14:34 +01:00
|
|
|
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
2015-07-13 15:16:36 +01:00
|
|
|
}
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2016-09-05 12:10:56 +01:00
|
|
|
bool fat32::create(Report& report, const QString& deviceNode)
|
2015-07-13 15:16:36 +01:00
|
|
|
{
|
2020-01-12 11:54:14 +00:00
|
|
|
return createWithFatSize(report, deviceNode, 32);
|
2015-07-13 15:16:36 +01:00
|
|
|
}
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
bool fat32::updateUUID(Report& report, const QString& deviceNode) const
|
|
|
|
{
|
2018-11-25 20:50:22 +00:00
|
|
|
// HACK: replace this hack with fatlabel "-i" (dosfstools 4.2)
|
|
|
|
long int t = time(nullptr);
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
char uuid[4];
|
2016-08-11 18:57:40 +01:00
|
|
|
for (auto &u : uuid) {
|
2017-09-11 13:41:03 +01:00
|
|
|
u = static_cast<char>(t & 0xff);
|
2016-08-11 18:57:40 +01:00
|
|
|
t >>= 8;
|
|
|
|
}
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2018-11-25 20:50:22 +00:00
|
|
|
ExternalCommand cmd;
|
|
|
|
return cmd.writeData(report, QByteArray(uuid, sizeof(uuid)), deviceNode, 67);
|
2015-07-13 15:16:36 +01:00
|
|
|
}
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|