File indexing completed on 2024-05-05 05:48:44
0001 /* 0002 SPDX-FileCopyrightText: 2008-2011 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2013-2018 Andrius Štikonas <andrius@stikonas.eu> 0004 SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org> 0005 SPDX-FileCopyrightText: 2020 Arnaud Ferraris <arnaud.ferraris@collabora.com> 0006 SPDX-FileCopyrightText: 2020 Gaël PORTAY <gael.portay@collabora.com> 0007 0008 SPDX-License-Identifier: GPL-3.0-or-later 0009 */ 0010 0011 #include "fs/fat32.h" 0012 0013 #include "util/externalcommand.h" 0014 #include "util/capacity.h" 0015 0016 #include <QStringList> 0017 0018 #include <ctime> 0019 0020 namespace FS 0021 { 0022 fat32::fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) : 0023 fat16(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Fat32) 0024 { 0025 } 0026 0027 qint64 fat32::minCapacity() const 0028 { 0029 return 32 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); 0030 } 0031 0032 qint64 fat32::maxCapacity() const 0033 { 0034 return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); 0035 } 0036 0037 bool fat32::create(Report& report, const QString& deviceNode) 0038 { 0039 return createWithFatSize(report, deviceNode, 32); 0040 } 0041 0042 bool fat32::updateUUID(Report& report, const QString& deviceNode) const 0043 { 0044 // HACK: replace this hack with fatlabel "-i" (dosfstools 4.2) 0045 long int t = time(nullptr); 0046 0047 char uuid[4]; 0048 for (auto &u : uuid) { 0049 u = static_cast<char>(t & 0xff); 0050 t >>= 8; 0051 } 0052 0053 ExternalCommand cmd; 0054 return cmd.writeData(report, QByteArray(uuid, sizeof(uuid)), deviceNode, 67); 0055 } 0056 }