File indexing completed on 2024-05-05 05:48:46
0001 /* 0002 SPDX-FileCopyrightText: 2019 Shubham Jangra <aryan100jangid@gmail.com> 0003 SPDX-FileCopyrightText: 2020 Arnaud Ferraris <arnaud.ferraris@collabora.com> 0004 SPDX-FileCopyrightText: 2020 Gaƫl PORTAY <gael.portay@collabora.com> 0005 0006 SPDX-License-Identifier: GPL-3.0-or-later 0007 */ 0008 0009 #include "fs/minix.h" 0010 0011 #include "util/capacity.h" 0012 #include "util/externalcommand.h" 0013 0014 #include <QString> 0015 0016 namespace FS 0017 { 0018 FileSystem::CommandSupportType minix::m_GetLabel = FileSystem::cmdSupportNone; 0019 FileSystem::CommandSupportType minix::m_GetUsed = FileSystem::cmdSupportNone; 0020 FileSystem::CommandSupportType minix::m_Shrink = FileSystem::cmdSupportNone; 0021 FileSystem::CommandSupportType minix::m_Move = FileSystem::cmdSupportNone; 0022 FileSystem::CommandSupportType minix::m_Check = FileSystem::cmdSupportNone; 0023 FileSystem::CommandSupportType minix::m_Create = FileSystem::cmdSupportNone; 0024 FileSystem::CommandSupportType minix::m_Copy = FileSystem::cmdSupportNone; 0025 FileSystem::CommandSupportType minix::m_Backup = FileSystem::cmdSupportNone; 0026 0027 minix::minix(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) : 0028 FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Minix) 0029 { 0030 } 0031 0032 void minix::init() 0033 { 0034 m_Check = findExternal(QStringLiteral("fsck.minix"), {}, 16) ? cmdSupportFileSystem : cmdSupportNone; 0035 m_Create = findExternal(QStringLiteral("mkfs.minix"), {}, 16) ? cmdSupportFileSystem : cmdSupportNone; 0036 m_Copy = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone; 0037 m_Move = (m_Check != cmdSupportNone) ? cmdSupportCore : cmdSupportNone; 0038 m_Backup = cmdSupportCore; 0039 m_GetLabel = cmdSupportCore; 0040 } 0041 0042 bool minix::supportToolFound() const 0043 { 0044 return m_GetLabel != cmdSupportNone && 0045 m_Create != cmdSupportNone && 0046 m_Check != cmdSupportNone && 0047 m_Copy != cmdSupportNone && 0048 m_Move != cmdSupportNone && 0049 m_Backup != cmdSupportNone; 0050 } 0051 0052 FileSystem::SupportTool minix::supportToolName() const 0053 { 0054 return SupportTool(QStringLiteral("util-linux"), QUrl(QStringLiteral("https://www.kernel.org/pub/linux/utils/util-linux/"))); 0055 } 0056 0057 qint64 minix::maxCapacity() const 0058 { 0059 return 4 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::GiB); 0060 } 0061 0062 int minix::maxLabelLength() const 0063 { 0064 return 63; 0065 } 0066 0067 bool minix::check(Report& report, const QString& deviceNode) const 0068 { 0069 ExternalCommand cmd(report, QStringLiteral("fsck.minix"), { deviceNode }); 0070 return cmd.run(-1) && cmd.exitCode() == 0; 0071 } 0072 0073 bool minix::create(Report& report, const QString& deviceNode) 0074 { 0075 ExternalCommand cmd(report, QStringLiteral("mkfs.minix"), { QStringLiteral("-3"), deviceNode }); 0076 return cmd.run(-1) && cmd.exitCode() == 0; 0077 } 0078 0079 }