kpmcore/src/fs/fat32.cpp

57 lines
1.6 KiB
C++
Raw Permalink Normal View History

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
*/
#include "fs/fat32.h"
#include "util/externalcommand.h"
#include "util/capacity.h"
#include <QStringList>
#include <ctime>
namespace FS
{
fat32::fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
fat16(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Fat32)
2015-07-13 15:16:36 +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-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
}
2016-09-05 12:10:56 +01:00
bool fat32::create(Report& report, const QString& deviceNode)
2015-07-13 15:16:36 +01:00
{
return createWithFatSize(report, deviceNode, 32);
2015-07-13 15:16:36 +01:00
}
2015-07-13 15:16:36 +01:00
bool fat32::updateUUID(Report& report, const QString& deviceNode) const
{
// HACK: replace this hack with fatlabel "-i" (dosfstools 4.2)
long int t = time(nullptr);
2015-07-13 15:16:36 +01:00
char uuid[4];
for (auto &u : uuid) {
u = static_cast<char>(t & 0xff);
t >>= 8;
}
ExternalCommand cmd;
return cmd.writeData(report, QByteArray(uuid, sizeof(uuid)), deviceNode, 67);
2015-07-13 15:16:36 +01:00
}
}