diff --git a/src/core/lvmdevice.cpp b/src/core/lvmdevice.cpp index e95b2a5..0799c54 100644 --- a/src/core/lvmdevice.cpp +++ b/src/core/lvmdevice.cpp @@ -129,7 +129,7 @@ Partition* LvmDevice::scanPartition(const QString& lvPath, PartitionTable* pTabl bool mounted; // Handle LUKS partition - if (fs->type() == FileSystem::Luks) { + if (fs->type() == FileSystem::Type::Luks) { r |= PartitionRole::Luks; FS::luks* luksFs = static_cast(fs); luksFs->initLUKS(); @@ -141,9 +141,9 @@ Partition* LvmDevice::scanPartition(const QString& lvPath, PartitionTable* pTabl mountPoint = FileSystem::detectMountPoint(fs, lvPath); mounted = FileSystem::detectMountStatus(fs, lvPath); - if (mountPoint != QString() && fs->type() != FileSystem::LinuxSwap) { + if (mountPoint != QString() && fs->type() != FileSystem::Type::LinuxSwap) { const QStorageInfo storage = QStorageInfo(mountPoint); - if (logicalSize() > 0 && fs->type() != FileSystem::Luks && mounted && storage.isValid()) + if (logicalSize() > 0 && fs->type() != FileSystem::Type::Luks && mounted && storage.isValid()) fs->setSectorsUsed( (storage.bytesTotal() - storage.bytesFree()) / logicalSize() ); } else if (fs->supportGetUsed() == FileSystem::cmdSupportFileSystem) diff --git a/src/core/partitiontable.cpp b/src/core/partitiontable.cpp index 98c1d06..aca5149 100644 --- a/src/core/partitiontable.cpp +++ b/src/core/partitiontable.cpp @@ -325,7 +325,7 @@ Partition* createUnallocated(const Device& device, PartitionNode& parent, qint64 if (!PartitionTable::getUnallocatedRange(device, parent, start, end)) return nullptr; - return new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Unknown, start, end, device.logicalSize()), start, end, QString()); + return new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Type::Unknown, start, end, device.logicalSize()), start, end, QString()); } /** Removes all unallocated children from a PartitionNode diff --git a/src/fs/exfat.cpp b/src/fs/exfat.cpp index 00bfe51..46753e8 100644 --- a/src/fs/exfat.cpp +++ b/src/fs/exfat.cpp @@ -39,7 +39,7 @@ FileSystem::CommandSupportType exfat::m_UpdateUUID = FileSystem::cmdSupportNone; FileSystem::CommandSupportType exfat::m_GetUUID = FileSystem::cmdSupportNone; exfat::exfat(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Exfat) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Exfat) { } diff --git a/src/fs/ext2.h b/src/fs/ext2.h index a31265d..ec2ca59 100644 --- a/src/fs/ext2.h +++ b/src/fs/ext2.h @@ -37,7 +37,7 @@ namespace FS class LIBKPMCORE_EXPORT ext2 : public FileSystem { public: - ext2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Ext2); + ext2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Type::Ext2); public: void init() override; diff --git a/src/fs/ext3.cpp b/src/fs/ext3.cpp index 28d3710..a33f236 100644 --- a/src/fs/ext3.cpp +++ b/src/fs/ext3.cpp @@ -25,7 +25,7 @@ namespace FS { ext3::ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - ext2(firstsector, lastsector, sectorsused, label, FileSystem::Ext3) + ext2(firstsector, lastsector, sectorsused, label, FileSystem::Type::Ext3) { } diff --git a/src/fs/ext4.cpp b/src/fs/ext4.cpp index 4a12831..30d38dc 100644 --- a/src/fs/ext4.cpp +++ b/src/fs/ext4.cpp @@ -25,7 +25,7 @@ namespace FS { ext4::ext4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - ext2(firstsector, lastsector, sectorsused, label, FileSystem::Ext4) + ext2(firstsector, lastsector, sectorsused, label, FileSystem::Type::Ext4) { } diff --git a/src/fs/extended.cpp b/src/fs/extended.cpp index 86e8420..49ab801 100644 --- a/src/fs/extended.cpp +++ b/src/fs/extended.cpp @@ -25,7 +25,7 @@ FileSystem::CommandSupportType extended::m_Shrink = FileSystem::cmdSupportCore; FileSystem::CommandSupportType extended::m_Move = FileSystem::cmdSupportCore; extended::extended(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Extended) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Extended) { } diff --git a/src/fs/f2fs.cpp b/src/fs/f2fs.cpp index 3bf3d73..d112dac 100644 --- a/src/fs/f2fs.cpp +++ b/src/fs/f2fs.cpp @@ -46,7 +46,7 @@ FileSystem::CommandSupportType f2fs::m_GetUUID = FileSystem::cmdSupportNone; bool f2fs::oldVersion = false; // 1.8.x or older f2fs::f2fs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::F2fs) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::F2fs) { } diff --git a/src/fs/fat12.h b/src/fs/fat12.h index a05dd67..ef8818f 100644 --- a/src/fs/fat12.h +++ b/src/fs/fat12.h @@ -38,7 +38,7 @@ namespace FS class LIBKPMCORE_EXPORT fat12 : public FileSystem { public: - fat12(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Fat12); + fat12(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Type::Fat12); public: void init() override; diff --git a/src/fs/fat16.cpp b/src/fs/fat16.cpp index a287385..1b6b3fe 100644 --- a/src/fs/fat16.cpp +++ b/src/fs/fat16.cpp @@ -33,7 +33,7 @@ namespace FS { fat16::fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - fat12(firstsector, lastsector, sectorsused, label, FileSystem::Fat16) + fat12(firstsector, lastsector, sectorsused, label, FileSystem::Type::Fat16) { } diff --git a/src/fs/fat32.cpp b/src/fs/fat32.cpp index 05e30c8..7f6151e 100644 --- a/src/fs/fat32.cpp +++ b/src/fs/fat32.cpp @@ -26,7 +26,7 @@ namespace FS { fat32::fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - fat16(firstsector, lastsector, sectorsused, label, FileSystem::Fat32) + fat16(firstsector, lastsector, sectorsused, label, FileSystem::Type::Fat32) { } diff --git a/src/fs/filesystem.cpp b/src/fs/filesystem.cpp index 0dea891..9dc6c77 100644 --- a/src/fs/filesystem.cpp +++ b/src/fs/filesystem.cpp @@ -108,7 +108,7 @@ FileSystem::Type FileSystem::detectFileSystem(const QString& partitionPath) QString FileSystem::detectMountPoint(FileSystem* fs, const QString& partitionPath) { - if (fs->type() == FileSystem::Lvm2_PV) + if (fs->type() == FileSystem::Type::Lvm2_PV) return FS::lvm2_pv::getVGName(partitionPath); if (partitionPath.isEmpty()) // Happens when during initial scan LUKS is closed @@ -133,7 +133,7 @@ bool FileSystem::detectMountStatus(FileSystem* fs, const QString& partitionPath) { bool mounted = false; - if (fs->type() == FileSystem::Lvm2_PV) { + if (fs->type() == FileSystem::Type::Lvm2_PV) { mounted = FS::lvm2_pv::getVGName(partitionPath) != QString(); } else { mounted = isMounted(partitionPath); @@ -437,10 +437,9 @@ static const KLocalizedString* typeNames() */ QString FileSystem::nameForType(FileSystem::Type t, const QStringList& languages) { - Q_ASSERT(t >= 0); - Q_ASSERT(t < __lastType); + Q_ASSERT(t < Type::__lastType); - return typeNames()[t].toString(languages); + return typeNames()[static_cast(t)].toString(languages); } /** @param s the name to get the type for @@ -448,11 +447,11 @@ QString FileSystem::nameForType(FileSystem::Type t, const QStringList& languages */ FileSystem::Type FileSystem::typeForName(const QString& s, const QStringList& languages ) { - for (quint32 i = 0; i < __lastType; i++) + for (quint32 i = 0; i < static_cast(Type::__lastType); i++) if (typeNames()[i].toString(languages) == s) return static_cast(i); - return Unknown; + return Type::Unknown; } /** @return a QList of all known types */ @@ -460,8 +459,8 @@ QList FileSystem::types() { QList result; - int i = Ext2; // first "real" filesystem - while (i != __lastType) + int i = static_cast(Type::Ext2); // first "real" filesystem + while (i != static_cast(Type::__lastType)) result.append(static_cast(i++)); return result; diff --git a/src/fs/filesystem.h b/src/fs/filesystem.h index fb5816f..fc63463 100644 --- a/src/fs/filesystem.h +++ b/src/fs/filesystem.h @@ -1,7 +1,7 @@ /************************************************************************* * Copyright (C) 2012 by Volker Lanz * * Copyright (C) 2015 by Teo Mrnjavac * - * Copyright (C) 2016 by Andrius Štikonas * + * Copyright (C) 2016-2018 by Andrius Štikonas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -17,7 +17,7 @@ * along with this program. If not, see .* *************************************************************************/ -#if !defined(KPMCORE_FILESYSTEM_H) +#ifndef KPMCORE_FILESYSTEM_H #define KPMCORE_FILESYSTEM_H #include "util/libpartitionmanagerexport.h" @@ -58,39 +58,39 @@ public: /** Supported FileSystem types */ enum Type : int { - Unknown = 0, - Extended = 1, + Unknown, + Extended, - Ext2 = 2, - Ext3 = 3, - Ext4 = 4, - LinuxSwap = 5, - Fat16 = 6, - Fat32 = 7, - Ntfs = 8, - ReiserFS = 9, - Reiser4 = 10, - Xfs = 11, - Jfs = 12, - Hfs = 13, - HfsPlus = 14, - Ufs = 15, - Unformatted = 16, - Btrfs = 17, - Hpfs = 18, - Luks = 19, - Ocfs2 = 20, - Zfs = 21, - Exfat = 22, - Nilfs2 = 23, - Lvm2_PV = 24, - F2fs = 25, - Udf = 26, - Iso9660 = 27, - Luks2 = 28, - Fat12 = 29, + Ext2, + Ext3, + Ext4, + LinuxSwap, + Fat16, + Fat32, + Ntfs, + ReiserFS, + Reiser4, + Xfs, + Jfs, + Hfs, + HfsPlus, + Ufs, + Unformatted, + Btrfs, + Hpfs, + Luks, + Ocfs2, + Zfs, + Exfat, + Nilfs2, + Lvm2_PV, + F2fs, + Udf, + Iso9660, + Luks2, + Fat12, - __lastType = 30 + __lastType }; /** The type of support for a given FileSystem action */ diff --git a/src/fs/filesystemfactory.cpp b/src/fs/filesystemfactory.cpp index b17998f..fa6b120 100644 --- a/src/fs/filesystemfactory.cpp +++ b/src/fs/filesystemfactory.cpp @@ -61,36 +61,36 @@ void FileSystemFactory::init() qDeleteAll(m_FileSystems); m_FileSystems.clear(); - m_FileSystems.insert(FileSystem::Btrfs, new FS::btrfs(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Exfat, new FS::exfat(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Ext2, new FS::ext2(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Ext3, new FS::ext3(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Ext4, new FS::ext4(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Extended, new FS::extended(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::F2fs, new FS::f2fs(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Fat12, new FS::fat12(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Fat16, new FS::fat16(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Fat32, new FS::fat32(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Hfs, new FS::hfs(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::HfsPlus, new FS::hfsplus(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Hpfs, new FS::hpfs(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Iso9660, new FS::iso9660(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Jfs, new FS::jfs(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::LinuxSwap, new FS::linuxswap(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Luks, new FS::luks(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Luks2, new FS::luks2(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Lvm2_PV, new FS::lvm2_pv(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Nilfs2, new FS::nilfs2(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Ntfs, new FS::ntfs(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Ocfs2, new FS::ocfs2(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::ReiserFS, new FS::reiserfs(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Reiser4, new FS::reiser4(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Udf, new FS::udf(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Ufs, new FS::ufs(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Unformatted, new FS::unformatted(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Unknown, new FS::unknown(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Xfs, new FS::xfs(-1, -1, -1, QString())); - m_FileSystems.insert(FileSystem::Zfs, new FS::zfs(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Btrfs, new FS::btrfs(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Exfat, new FS::exfat(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Ext2, new FS::ext2(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Ext3, new FS::ext3(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Ext4, new FS::ext4(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Extended, new FS::extended(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::F2fs, new FS::f2fs(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Fat12, new FS::fat12(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Fat16, new FS::fat16(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Fat32, new FS::fat32(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Hfs, new FS::hfs(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::HfsPlus, new FS::hfsplus(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Hpfs, new FS::hpfs(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Iso9660, new FS::iso9660(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Jfs, new FS::jfs(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::LinuxSwap, new FS::linuxswap(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Luks, new FS::luks(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Luks2, new FS::luks2(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Lvm2_PV, new FS::lvm2_pv(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Nilfs2, new FS::nilfs2(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Ntfs, new FS::ntfs(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Ocfs2, new FS::ocfs2(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::ReiserFS, new FS::reiserfs(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Reiser4, new FS::reiser4(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Udf, new FS::udf(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Ufs, new FS::ufs(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Unformatted, new FS::unformatted(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Unknown, new FS::unknown(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Xfs, new FS::xfs(-1, -1, -1, QString())); + m_FileSystems.insert(FileSystem::Type::Zfs, new FS::zfs(-1, -1, -1, QString())); for (const auto &fs : FileSystemFactory::map()) fs->init(); @@ -111,36 +111,36 @@ FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qi FileSystem* fs = nullptr; switch (t) { - case FileSystem::Btrfs: fs = new FS::btrfs(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Exfat: fs = new FS::exfat(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Ext2: fs = new FS::ext2(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Ext3: fs = new FS::ext3(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Ext4: fs = new FS::ext4(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Extended: fs = new FS::extended(firstsector, lastsector, sectorsused, label); break; - case FileSystem::F2fs: fs = new FS::f2fs(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Fat12: fs = new FS::fat12(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Fat16: fs = new FS::fat16(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Fat32: fs = new FS::fat32(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Hfs: fs = new FS::hfs(firstsector, lastsector, sectorsused, label); break; - case FileSystem::HfsPlus: fs = new FS::hfsplus(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Hpfs: fs = new FS::hpfs(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Iso9660: fs = new FS::iso9660(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Jfs: fs = new FS::jfs(firstsector, lastsector, sectorsused, label); break; - case FileSystem::LinuxSwap: fs = new FS::linuxswap(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Luks: fs = new FS::luks(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Luks2: fs = new FS::luks2(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Lvm2_PV: fs = new FS::lvm2_pv(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Nilfs2: fs = new FS::nilfs2(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Ntfs: fs = new FS::ntfs(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Ocfs2: fs = new FS::ocfs2(firstsector, lastsector, sectorsused, label); break; - case FileSystem::ReiserFS: fs = new FS::reiserfs(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Reiser4: fs = new FS::reiser4(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Udf: fs = new FS::udf(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Ufs: fs = new FS::ufs(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Unformatted: fs = new FS::unformatted(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Unknown: fs = new FS::unknown(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Xfs: fs = new FS::xfs(firstsector, lastsector, sectorsused, label); break; - case FileSystem::Zfs: fs = new FS::zfs(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Btrfs: fs = new FS::btrfs(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Exfat: fs = new FS::exfat(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Ext2: fs = new FS::ext2(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Ext3: fs = new FS::ext3(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Ext4: fs = new FS::ext4(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Extended: fs = new FS::extended(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::F2fs: fs = new FS::f2fs(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Fat12: fs = new FS::fat12(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Fat16: fs = new FS::fat16(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Fat32: fs = new FS::fat32(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Hfs: fs = new FS::hfs(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::HfsPlus: fs = new FS::hfsplus(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Hpfs: fs = new FS::hpfs(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Iso9660: fs = new FS::iso9660(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Jfs: fs = new FS::jfs(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::LinuxSwap: fs = new FS::linuxswap(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Luks: fs = new FS::luks(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Luks2: fs = new FS::luks2(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Lvm2_PV: fs = new FS::lvm2_pv(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Nilfs2: fs = new FS::nilfs2(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Ntfs: fs = new FS::ntfs(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Ocfs2: fs = new FS::ocfs2(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::ReiserFS: fs = new FS::reiserfs(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Reiser4: fs = new FS::reiser4(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Udf: fs = new FS::udf(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Ufs: fs = new FS::ufs(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Unformatted: fs = new FS::unformatted(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Unknown: fs = new FS::unknown(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Xfs: fs = new FS::xfs(firstsector, lastsector, sectorsused, label); break; + case FileSystem::Type::Zfs: fs = new FS::zfs(firstsector, lastsector, sectorsused, label); break; default: break; } diff --git a/src/fs/filesystemfactory.h b/src/fs/filesystemfactory.h index 185bc57..6679bbc 100644 --- a/src/fs/filesystemfactory.h +++ b/src/fs/filesystemfactory.h @@ -15,8 +15,7 @@ * along with this program. If not, see .* *************************************************************************/ -#if !defined(KPMCORE_FILESYSTEMFACTORY_H) - +#ifndef KPMCORE_FILESYSTEMFACTORY_H #define KPMCORE_FILESYSTEMFACTORY_H #include "fs/filesystem.h" diff --git a/src/fs/hfs.cpp b/src/fs/hfs.cpp index 404a4d9..98a2d15 100644 --- a/src/fs/hfs.cpp +++ b/src/fs/hfs.cpp @@ -35,7 +35,7 @@ FileSystem::CommandSupportType hfs::m_Copy = FileSystem::cmdSupportNone; FileSystem::CommandSupportType hfs::m_Backup = FileSystem::cmdSupportNone; hfs::hfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Hfs) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Hfs) { } diff --git a/src/fs/hfsplus.cpp b/src/fs/hfsplus.cpp index 328d356..f417ea0 100644 --- a/src/fs/hfsplus.cpp +++ b/src/fs/hfsplus.cpp @@ -35,7 +35,7 @@ FileSystem::CommandSupportType hfsplus::m_Copy = FileSystem::cmdSupportNone; FileSystem::CommandSupportType hfsplus::m_Backup = FileSystem::cmdSupportNone; hfsplus::hfsplus(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::HfsPlus) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::HfsPlus) { } diff --git a/src/fs/hpfs.cpp b/src/fs/hpfs.cpp index cfb2386..aa1941e 100644 --- a/src/fs/hpfs.cpp +++ b/src/fs/hpfs.cpp @@ -37,7 +37,7 @@ FileSystem::CommandSupportType hpfs::m_UpdateUUID = FileSystem::cmdSupportNone; FileSystem::CommandSupportType hpfs::m_GetUUID = FileSystem::cmdSupportNone; hpfs::hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Hpfs) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Hpfs) { } diff --git a/src/fs/iso9660.cpp b/src/fs/iso9660.cpp index 05d178b..d7939a9 100644 --- a/src/fs/iso9660.cpp +++ b/src/fs/iso9660.cpp @@ -21,7 +21,7 @@ namespace FS { iso9660::iso9660(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Iso9660) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Iso9660) { } diff --git a/src/fs/jfs.cpp b/src/fs/jfs.cpp index 90ab7ba..da260a4 100644 --- a/src/fs/jfs.cpp +++ b/src/fs/jfs.cpp @@ -40,7 +40,7 @@ FileSystem::CommandSupportType jfs::m_Backup = FileSystem::cmdSupportNone; FileSystem::CommandSupportType jfs::m_SetLabel = FileSystem::cmdSupportNone; jfs::jfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Jfs) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Jfs) { } diff --git a/src/fs/linuxswap.cpp b/src/fs/linuxswap.cpp index edffc94..b4eebdd 100644 --- a/src/fs/linuxswap.cpp +++ b/src/fs/linuxswap.cpp @@ -40,7 +40,7 @@ FileSystem::CommandSupportType linuxswap::m_GetUUID = FileSystem::cmdSupportNone FileSystem::CommandSupportType linuxswap::m_UpdateUUID = FileSystem::cmdSupportNone; linuxswap::linuxswap(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::LinuxSwap) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::LinuxSwap) { } diff --git a/src/fs/luks.cpp b/src/fs/luks.cpp index b82f64f..224c27d 100644 --- a/src/fs/luks.cpp +++ b/src/fs/luks.cpp @@ -288,7 +288,7 @@ bool luks::cryptOpen(QWidget* parent, const QString& deviceNode) return false; for (auto &p : LVM::pvList) - if (p.isLuks() && p.partition()->deviceNode() == deviceNode && p.partition()->fileSystem().type() == FileSystem::Lvm2_PV) + if (p.isLuks() && p.partition()->deviceNode() == deviceNode && p.partition()->fileSystem().type() == FileSystem::Type::Lvm2_PV) p.setLuks(false); m_passphrase = passphrase; @@ -465,7 +465,7 @@ FileSystem::Type luks::type() const { if (m_isCryptOpen && m_innerFs) return m_innerFs->type(); - return FileSystem::Luks; + return FileSystem::Type::Luks; } QString luks::suggestedMapperName(const QString& deviceNode) const @@ -648,19 +648,19 @@ bool luks::canEncryptType(FileSystem::Type type) { switch (type) { - case Btrfs: - case F2fs: - case Ext2: - case Ext3: - case Ext4: - case Jfs: - case LinuxSwap: - case Lvm2_PV: - case Nilfs2: - case ReiserFS: - case Reiser4: - case Xfs: - case Zfs: + case Type::Btrfs: + case Type::F2fs: + case Type::Ext2: + case Type::Ext3: + case Type::Ext4: + case Type::Jfs: + case Type::LinuxSwap: + case Type::Lvm2_PV: + case Type::Nilfs2: + case Type::ReiserFS: + case Type::Reiser4: + case Type::Xfs: + case Type::Zfs: return true; default: return false; diff --git a/src/fs/luks.h b/src/fs/luks.h index bbcab61..dfc761f 100644 --- a/src/fs/luks.h +++ b/src/fs/luks.h @@ -40,7 +40,7 @@ namespace FS class LIBKPMCORE_EXPORT luks : public FileSystem { public: - luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Luks); + luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Type::Luks); ~luks() override; enum KeyLocation { diff --git a/src/fs/luks2.cpp b/src/fs/luks2.cpp index 9453ee1..af2ae34 100644 --- a/src/fs/luks2.cpp +++ b/src/fs/luks2.cpp @@ -28,7 +28,7 @@ namespace FS { luks2::luks2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) - : luks(firstsector, lastsector, sectorsused, label, FileSystem::Luks2) + : luks(firstsector, lastsector, sectorsused, label, FileSystem::Type::Luks2) { } @@ -40,7 +40,7 @@ FileSystem::Type luks2::type() const { if (m_isCryptOpen && m_innerFs) return m_innerFs->type(); - return FileSystem::Luks2; + return FileSystem::Type::Luks2; } bool luks2::create(Report& report, const QString& deviceNode) diff --git a/src/fs/lvm2_pv.cpp b/src/fs/lvm2_pv.cpp index 91964ac..62791c8 100644 --- a/src/fs/lvm2_pv.cpp +++ b/src/fs/lvm2_pv.cpp @@ -43,7 +43,7 @@ FileSystem::CommandSupportType lvm2_pv::m_GetUUID = FileSystem::cmdSupportNone; lvm2_pv::lvm2_pv(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) - : FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Lvm2_PV) + : FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Lvm2_PV) , m_PESize(0) , m_TotalPE(0) , m_AllocatedPE(0) @@ -270,10 +270,10 @@ QList lvm2_pv::getPVinNode(const PartitionNode* parent) partitions.append(getPVinNode(node)); // FIXME: reenable newly created PVs (before applying) once everything works - if(p->fileSystem().type() == FileSystem::Lvm2_PV && p->deviceNode() == p->partitionPath()) + if(p->fileSystem().type() == FileSystem::Type::Lvm2_PV && p->deviceNode() == p->partitionPath()) partitions.append(LvmPV(p->mountPoint(), p)); - if(p->fileSystem().type() == FileSystem::Luks && p->deviceNode() == p->partitionPath()) + if(p->fileSystem().type() == FileSystem::Type::Luks && p->deviceNode() == p->partitionPath()) partitions.append(LvmPV(p->mountPoint(), p, true)); } diff --git a/src/fs/nilfs2.cpp b/src/fs/nilfs2.cpp index d8eb131..ffb3a69 100644 --- a/src/fs/nilfs2.cpp +++ b/src/fs/nilfs2.cpp @@ -47,7 +47,7 @@ FileSystem::CommandSupportType nilfs2::m_UpdateUUID = FileSystem::cmdSupportNone FileSystem::CommandSupportType nilfs2::m_GetUUID = FileSystem::cmdSupportNone; nilfs2::nilfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Nilfs2) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Nilfs2) { } diff --git a/src/fs/ntfs.cpp b/src/fs/ntfs.cpp index f068624..8164f18 100644 --- a/src/fs/ntfs.cpp +++ b/src/fs/ntfs.cpp @@ -50,7 +50,7 @@ FileSystem::CommandSupportType ntfs::m_UpdateUUID = FileSystem::cmdSupportNone; FileSystem::CommandSupportType ntfs::m_GetUUID = FileSystem::cmdSupportNone; ntfs::ntfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Ntfs) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Ntfs) { } diff --git a/src/fs/ocfs2.cpp b/src/fs/ocfs2.cpp index 03720c4..040e5b3 100644 --- a/src/fs/ocfs2.cpp +++ b/src/fs/ocfs2.cpp @@ -40,7 +40,7 @@ FileSystem::CommandSupportType ocfs2::m_UpdateUUID = FileSystem::cmdSupportNone; FileSystem::CommandSupportType ocfs2::m_GetUUID = FileSystem::cmdSupportNone; ocfs2::ocfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Ocfs2) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Ocfs2) { } diff --git a/src/fs/reiser4.cpp b/src/fs/reiser4.cpp index 9d54b66..71d1830 100644 --- a/src/fs/reiser4.cpp +++ b/src/fs/reiser4.cpp @@ -35,7 +35,7 @@ FileSystem::CommandSupportType reiser4::m_Copy = FileSystem::cmdSupportNone; FileSystem::CommandSupportType reiser4::m_Backup = FileSystem::cmdSupportNone; reiser4::reiser4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Reiser4) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Reiser4) { } diff --git a/src/fs/reiserfs.cpp b/src/fs/reiserfs.cpp index 2f8a7ef..cb78ecf 100644 --- a/src/fs/reiserfs.cpp +++ b/src/fs/reiserfs.cpp @@ -42,7 +42,7 @@ FileSystem::CommandSupportType reiserfs::m_UpdateUUID = FileSystem::cmdSupportNo FileSystem::CommandSupportType reiserfs::m_GetUUID = FileSystem::cmdSupportNone; reiserfs::reiserfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::ReiserFS) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::ReiserFS) { } diff --git a/src/fs/udf.cpp b/src/fs/udf.cpp index f34c5f3..b0d28a9 100644 --- a/src/fs/udf.cpp +++ b/src/fs/udf.cpp @@ -40,7 +40,7 @@ FileSystem::CommandSupportType udf::m_Create = FileSystem::cmdSupportNone; bool udf::oldMkudffsVersion = false; udf::udf(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Udf) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Udf) { } diff --git a/src/fs/ufs.cpp b/src/fs/ufs.cpp index f1e7212..71f5e51 100644 --- a/src/fs/ufs.cpp +++ b/src/fs/ufs.cpp @@ -24,7 +24,7 @@ FileSystem::CommandSupportType ufs::m_Copy = FileSystem::cmdSupportCore; FileSystem::CommandSupportType ufs::m_Backup = FileSystem::cmdSupportCore; ufs::ufs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Ufs) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Ufs) { } } diff --git a/src/fs/unformatted.cpp b/src/fs/unformatted.cpp index f3bcb29..e1813de 100644 --- a/src/fs/unformatted.cpp +++ b/src/fs/unformatted.cpp @@ -22,7 +22,7 @@ namespace FS FileSystem::CommandSupportType unformatted::m_Create = FileSystem::cmdSupportFileSystem; unformatted::unformatted(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Unformatted) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Unformatted) { } diff --git a/src/fs/unknown.cpp b/src/fs/unknown.cpp index 5b0a552..3f6e27f 100644 --- a/src/fs/unknown.cpp +++ b/src/fs/unknown.cpp @@ -20,7 +20,7 @@ namespace FS { unknown::unknown(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Unknown) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Unknown) { } diff --git a/src/fs/xfs.cpp b/src/fs/xfs.cpp index f808a3e..e0b3339 100644 --- a/src/fs/xfs.cpp +++ b/src/fs/xfs.cpp @@ -42,7 +42,7 @@ FileSystem::CommandSupportType xfs::m_Backup = FileSystem::cmdSupportNone; FileSystem::CommandSupportType xfs::m_SetLabel = FileSystem::cmdSupportNone; xfs::xfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Xfs) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Xfs) { } diff --git a/src/fs/zfs.cpp b/src/fs/zfs.cpp index fccf00a..d04de16 100644 --- a/src/fs/zfs.cpp +++ b/src/fs/zfs.cpp @@ -40,7 +40,7 @@ FileSystem::CommandSupportType zfs::m_UpdateUUID = FileSystem::cmdSupportNone; FileSystem::CommandSupportType zfs::m_GetUUID = FileSystem::cmdSupportNone; zfs::zfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : - FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Zfs) + FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Zfs) { } diff --git a/src/gui/partwidget.cpp b/src/gui/partwidget.cpp index 3615c3d..d728c23 100644 --- a/src/gui/partwidget.cpp +++ b/src/gui/partwidget.cpp @@ -101,12 +101,12 @@ void PartWidget::paintEvent(QPaintEvent*) if (partition()->roles().has(PartitionRole::Extended)) { drawGradient(&painter, activeColor( - m_fileSystemColorCode[ partition()->fileSystem().type() ]), + m_fileSystemColorCode[ static_cast(partition()->fileSystem().type()) ]), QRect(0, 0, width(), height())); return; } - const QColor base = activeColor(m_fileSystemColorCode[ partition()->fileSystem().type() ]); + const QColor base = activeColor(m_fileSystemColorCode[ static_cast(partition()->fileSystem().type()) ]); if (!partition()->roles().has(PartitionRole::Unallocated)) { const QColor dark = base.darker(105); diff --git a/src/jobs/createfilesystemjob.cpp b/src/jobs/createfilesystemjob.cpp index 09e63a2..c4894e3 100644 --- a/src/jobs/createfilesystemjob.cpp +++ b/src/jobs/createfilesystemjob.cpp @@ -49,7 +49,7 @@ bool CreateFileSystemJob::run(Report& parent) Report* report = jobStarted(parent); - if (partition().fileSystem().type() == FileSystem::Unformatted) + if (partition().fileSystem().type() == FileSystem::Type::Unformatted) return true; bool createResult; diff --git a/src/jobs/restorefilesystemjob.cpp b/src/jobs/restorefilesystemjob.cpp index fc62906..c7ec7e4 100644 --- a/src/jobs/restorefilesystemjob.cpp +++ b/src/jobs/restorefilesystemjob.cpp @@ -82,7 +82,7 @@ bool RestoreFileSystemJob::run(Report& parent) std::unique_ptr backendDevice = CoreBackendManager::self()->backend()->openDevice(targetDevice()); - FileSystem::Type t = FileSystem::Unknown; + FileSystem::Type t = FileSystem::Type::Unknown; if (backendDevice) { std::unique_ptr backendPartitionTable = backendDevice->openPartitionTable(); diff --git a/src/ops/newoperation.cpp b/src/ops/newoperation.cpp index 89b0be3..28e5804 100644 --- a/src/ops/newoperation.cpp +++ b/src/ops/newoperation.cpp @@ -55,7 +55,7 @@ NewOperation::NewOperation(Device& d, Partition* p) : const FileSystem& fs = newPartition().fileSystem(); - if (fs.type() != FileSystem::Extended) { + if (fs.type() != FileSystem::Type::Extended) { // It would seem tempting to skip the CreateFileSystemJob or the // SetFileSystemLabelJob if either has nothing to do (unformatted FS or // empty label). However, the user might later on decide to change FS or @@ -65,7 +65,7 @@ NewOperation::NewOperation(Device& d, Partition* p) : m_CreateFileSystemJob = new CreateFileSystemJob(targetDevice(), newPartition(), fs.label()); addJob(createFileSystemJob()); - if (fs.type() == FileSystem::Lvm2_PV) { + if (fs.type() == FileSystem::Type::Lvm2_PV) { m_SetPartFlagsJob = new SetPartFlagsJob(targetDevice(), newPartition(), PartitionTable::FlagLvm); addJob(setPartFlagsJob()); } diff --git a/src/ops/removevolumegroupoperation.cpp b/src/ops/removevolumegroupoperation.cpp index c269bbb..b523c83 100644 --- a/src/ops/removevolumegroupoperation.cpp +++ b/src/ops/removevolumegroupoperation.cpp @@ -67,7 +67,7 @@ bool RemoveVolumeGroupOperation::isRemovable(const VolumeManagerDevice* dev) else if (dev->partitionTable()->children().count() > 1) return false; else - if (dev->partitionTable()->children().first()->fileSystem().type() == FileSystem::Unknown) + if (dev->partitionTable()->children().first()->fileSystem().type() == FileSystem::Type::Unknown) return true; } diff --git a/src/ops/restoreoperation.cpp b/src/ops/restoreoperation.cpp index be8c0ab..56af801 100644 --- a/src/ops/restoreoperation.cpp +++ b/src/ops/restoreoperation.cpp @@ -225,7 +225,7 @@ Partition* RestoreOperation::createRestorePartition(const Device& device, Partit return nullptr; const qint64 end = start + fileInfo.size() / device.logicalSize() - 1; - Partition* p = new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Unknown, start, end, device.logicalSize()), start, end, QString()); + Partition* p = new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Type::Unknown, start, end, device.logicalSize()), start, end, QString()); p->setState(Partition::StateRestore); return p; diff --git a/src/plugins/dummy/dummybackend.cpp b/src/plugins/dummy/dummybackend.cpp index 30fe534..ae6f938 100644 --- a/src/plugins/dummy/dummybackend.cpp +++ b/src/plugins/dummy/dummybackend.cpp @@ -74,7 +74,7 @@ FileSystem::Type DummyBackend::detectFileSystem(const QString& deviceNode) { Q_UNUSED(deviceNode) - return FileSystem::Unknown; + return FileSystem::Type::Unknown; } QString DummyBackend::readLabel(const QString& deviceNode) const diff --git a/src/plugins/dummy/dummypartitiontable.cpp b/src/plugins/dummy/dummypartitiontable.cpp index 8da9328..90dd93f 100644 --- a/src/plugins/dummy/dummypartitiontable.cpp +++ b/src/plugins/dummy/dummypartitiontable.cpp @@ -96,7 +96,7 @@ FileSystem::Type DummyPartitionTable::detectFileSystemBySector(Report& report, c Q_UNUSED(device) Q_UNUSED(sector) - FileSystem::Type rval = FileSystem::Unknown; + FileSystem::Type rval = FileSystem::Type::Unknown; return rval; } diff --git a/src/plugins/sfdisk/sfdiskbackend.cpp b/src/plugins/sfdisk/sfdiskbackend.cpp index aa103b7..0858a75 100644 --- a/src/plugins/sfdisk/sfdiskbackend.cpp +++ b/src/plugins/sfdisk/sfdiskbackend.cpp @@ -209,13 +209,13 @@ void SfdiskBackend::scanDevicePartitions(Device& d, const QJsonArray& jsonPartit else if (partitionType == QStringLiteral("21686148-6449-6E6F-744E-656564454649")) activeFlags = PartitionTable::FlagBiosGrub; - FileSystem::Type type = FileSystem::Unknown; + FileSystem::Type type = FileSystem::Type::Unknown; type = detectFileSystem(partitionNode); PartitionRole::Roles r = PartitionRole::Primary; if ( (d.partitionTable()->type() == PartitionTable::msdos || d.partitionTable()->type() == PartitionTable::msdos_sectorbased) && partitionType.toInt() == 5 ) { r = PartitionRole::Extended; - type = FileSystem::Extended; + type = FileSystem::Type::Extended; } // Find an extended partition this partition is in. @@ -233,7 +233,7 @@ void SfdiskBackend::scanDevicePartitions(Device& d, const QJsonArray& jsonPartit QString mountPoint; bool mounted; // sfdisk does not handle LUKS partitions - if (fs->type() == FileSystem::Luks || fs->type() == FileSystem::Luks2) { + if (fs->type() == FileSystem::Type::Luks || fs->type() == FileSystem::Type::Luks2) { r |= PartitionRole::Luks; FS::luks* luksFs = static_cast(fs); luksFs->initLUKS(); @@ -280,7 +280,7 @@ void SfdiskBackend::scanDevicePartitions(Device& d, const QJsonArray& jsonPartit */ void SfdiskBackend::readSectorsUsed(const Device& d, Partition& p, const QString& mountPoint) { - if (!mountPoint.isEmpty() && p.fileSystem().type() != FileSystem::LinuxSwap && p.fileSystem().type() != FileSystem::Lvm2_PV) { + if (!mountPoint.isEmpty() && p.fileSystem().type() != FileSystem::Type::LinuxSwap && p.fileSystem().type() != FileSystem::Type::Lvm2_PV) { const QStorageInfo storage = QStorageInfo(mountPoint); if (p.isMounted() && storage.isValid()) p.fileSystem().setSectorsUsed( (storage.bytesTotal() - storage.bytesFree()) / d.logicalSize()); @@ -291,7 +291,7 @@ void SfdiskBackend::readSectorsUsed(const Device& d, Partition& p, const QString FileSystem::Type SfdiskBackend::detectFileSystem(const QString& partitionPath) { - FileSystem::Type rval = FileSystem::Unknown; + FileSystem::Type rval = FileSystem::Type::Unknown; ExternalCommand udevCommand(QStringLiteral("udevadm"), { QStringLiteral("info"), @@ -314,43 +314,43 @@ FileSystem::Type SfdiskBackend::detectFileSystem(const QString& partitionPath) version = reFileSystemVersion.captured(1); } - if (s == QStringLiteral("ext2")) rval = FileSystem::Ext2; - else if (s == QStringLiteral("ext3")) rval = FileSystem::Ext3; - else if (s.startsWith(QStringLiteral("ext4"))) rval = FileSystem::Ext4; - else if (s == QStringLiteral("swap")) rval = FileSystem::LinuxSwap; - else if (s == QStringLiteral("ntfs-3g")) rval = FileSystem::Ntfs; - else if (s == QStringLiteral("reiserfs")) rval = FileSystem::ReiserFS; - else if (s == QStringLiteral("reiser4")) rval = FileSystem::Reiser4; - else if (s == QStringLiteral("xfs")) rval = FileSystem::Xfs; - else if (s == QStringLiteral("jfs")) rval = FileSystem::Jfs; - else if (s == QStringLiteral("hfs")) rval = FileSystem::Hfs; - else if (s == QStringLiteral("hfsplus")) rval = FileSystem::HfsPlus; - else if (s == QStringLiteral("ufs")) rval = FileSystem::Ufs; + if (s == QStringLiteral("ext2")) rval = FileSystem::Type::Ext2; + else if (s == QStringLiteral("ext3")) rval = FileSystem::Type::Ext3; + else if (s.startsWith(QStringLiteral("ext4"))) rval = FileSystem::Type::Ext4; + else if (s == QStringLiteral("swap")) rval = FileSystem::Type::LinuxSwap; + else if (s == QStringLiteral("ntfs-3g")) rval = FileSystem::Type::Ntfs; + else if (s == QStringLiteral("reiserfs")) rval = FileSystem::Type::ReiserFS; + else if (s == QStringLiteral("reiser4")) rval = FileSystem::Type::Reiser4; + else if (s == QStringLiteral("xfs")) rval = FileSystem::Type::Xfs; + else if (s == QStringLiteral("jfs")) rval = FileSystem::Type::Jfs; + else if (s == QStringLiteral("hfs")) rval = FileSystem::Type::Hfs; + else if (s == QStringLiteral("hfsplus")) rval = FileSystem::Type::HfsPlus; + else if (s == QStringLiteral("ufs")) rval = FileSystem::Type::Ufs; else if (s == QStringLiteral("vfat")) { if (version == QStringLiteral("FAT32")) - rval = FileSystem::Fat32; + rval = FileSystem::Type::Fat32; else if (version == QStringLiteral("FAT16")) - rval = FileSystem::Fat16; + rval = FileSystem::Type::Fat16; else if (version == QStringLiteral("FAT12")) - rval = FileSystem::Fat12; + rval = FileSystem::Type::Fat12; } - else if (s == QStringLiteral("btrfs")) rval = FileSystem::Btrfs; - else if (s == QStringLiteral("ocfs2")) rval = FileSystem::Ocfs2; - else if (s == QStringLiteral("zfs_member")) rval = FileSystem::Zfs; - else if (s == QStringLiteral("hpfs")) rval = FileSystem::Hpfs; + else if (s == QStringLiteral("btrfs")) rval = FileSystem::Type::Btrfs; + else if (s == QStringLiteral("ocfs2")) rval = FileSystem::Type::Ocfs2; + else if (s == QStringLiteral("zfs_member")) rval = FileSystem::Type::Zfs; + else if (s == QStringLiteral("hpfs")) rval = FileSystem::Type::Hpfs; else if (s == QStringLiteral("crypto_LUKS")) { if (version == QStringLiteral("1")) - rval = FileSystem::Luks; + rval = FileSystem::Type::Luks; else if (version == QStringLiteral("2")) { - rval = FileSystem::Luks2; + rval = FileSystem::Type::Luks2; } } - else if (s == QStringLiteral("exfat")) rval = FileSystem::Exfat; - else if (s == QStringLiteral("nilfs2")) rval = FileSystem::Nilfs2; - else if (s == QStringLiteral("LVM2_member")) rval = FileSystem::Lvm2_PV; - else if (s == QStringLiteral("f2fs")) rval = FileSystem::F2fs; - else if (s == QStringLiteral("udf")) rval = FileSystem::Udf; - else if (s == QStringLiteral("iso9660")) rval = FileSystem::Iso9660; + else if (s == QStringLiteral("exfat")) rval = FileSystem::Type::Exfat; + else if (s == QStringLiteral("nilfs2")) rval = FileSystem::Type::Nilfs2; + else if (s == QStringLiteral("LVM2_member")) rval = FileSystem::Type::Lvm2_PV; + else if (s == QStringLiteral("f2fs")) rval = FileSystem::Type::F2fs; + else if (s == QStringLiteral("udf")) rval = FileSystem::Type::Udf; + else if (s == QStringLiteral("iso9660")) rval = FileSystem::Type::Iso9660; else qWarning() << "unknown file system type " << s << " on " << partitionPath; } diff --git a/src/plugins/sfdisk/sfdiskpartitiontable.cpp b/src/plugins/sfdisk/sfdiskpartitiontable.cpp index 79c2a55..9124107 100644 --- a/src/plugins/sfdisk/sfdiskpartitiontable.cpp +++ b/src/plugins/sfdisk/sfdiskpartitiontable.cpp @@ -135,7 +135,7 @@ bool SfdiskPartitionTable::resizeFileSystem(Report& report, const Partition& par FileSystem::Type SfdiskPartitionTable::detectFileSystemBySector(Report& report, const Device& device, qint64 sector) { - FileSystem::Type type = FileSystem::Unknown; + FileSystem::Type type = FileSystem::Type::Unknown; ExternalCommand jsonCommand(QStringLiteral("sfdisk"), { QStringLiteral("--json"), device.deviceNode() } ); if (jsonCommand.run(-1) && jsonCommand.exitCode() == 0) { @@ -160,24 +160,24 @@ static struct { FileSystem::Type type; QLatin1String partitionType[2]; // GPT, MBR } typemap[] = { - { FileSystem::Btrfs, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, - { FileSystem::Ext2, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, - { FileSystem::Ext3, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, - { FileSystem::Ext4, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, - { FileSystem::LinuxSwap, { QLatin1String("0657FD6D-A4AB-43C4-84E5-0933C84B4F4F"), QLatin1String("82") } }, - { FileSystem::Fat12, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("6") } }, - { FileSystem::Fat16, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("6") } }, - { FileSystem::Fat32, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } }, - { FileSystem::Nilfs2, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, - { FileSystem::Ntfs, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } }, - { FileSystem::Exfat, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } }, - { FileSystem::ReiserFS, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, - { FileSystem::Reiser4, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, - { FileSystem::Xfs, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, - { FileSystem::Jfs, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, - { FileSystem::Hfs, { QLatin1String("48465300-0000-11AA-AA11-00306543ECAC"), QLatin1String("af")} }, - { FileSystem::HfsPlus, { QLatin1String("48465300-0000-11AA-AA11-00306543ECAC"), QLatin1String("af") } }, - { FileSystem::Udf, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } } + { FileSystem::Type::Btrfs, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, + { FileSystem::Type::Ext2, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, + { FileSystem::Type::Ext3, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, + { FileSystem::Type::Ext4, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, + { FileSystem::Type::LinuxSwap, { QLatin1String("0657FD6D-A4AB-43C4-84E5-0933C84B4F4F"), QLatin1String("82") } }, + { FileSystem::Type::Fat12, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("6") } }, + { FileSystem::Type::Fat16, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("6") } }, + { FileSystem::Type::Fat32, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } }, + { FileSystem::Type::Nilfs2, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, + { FileSystem::Type::Ntfs, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } }, + { FileSystem::Type::Exfat, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } }, + { FileSystem::Type::ReiserFS, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, + { FileSystem::Type::Reiser4, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, + { FileSystem::Type::Xfs, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, + { FileSystem::Type::Jfs, { QLatin1String("0FC63DAF-8483-4772-8E79-3D69D8477DE4"), QLatin1String("83") } }, + { FileSystem::Type::Hfs, { QLatin1String("48465300-0000-11AA-AA11-00306543ECAC"), QLatin1String("af")} }, + { FileSystem::Type::HfsPlus, { QLatin1String("48465300-0000-11AA-AA11-00306543ECAC"), QLatin1String("af") } }, + { FileSystem::Type::Udf, { QLatin1String("EBD0A0A2-B9E5-4433-87C0-68B6B72699C7"), QLatin1String("7") } } // Add ZFS too };