| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2006-2010 Kevin Ottens <ervin@kde.org> |
| 3 | SPDX-FileCopyrightText: 2010 Mario Bensi <mbensi@ipsquad.net> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
| 6 | */ |
| 7 | |
| 8 | #ifndef SOLID_BACKENDS_FSTAB_FSTABHANDLING_H |
| 9 | #define SOLID_BACKENDS_FSTAB_FSTABHANDLING_H |
| 10 | |
| 11 | #include <QMultiHash> |
| 12 | #include <QString> |
| 13 | |
| 14 | #include <functional> |
| 15 | |
| 16 | class QProcess; |
| 17 | class QObject; |
| 18 | |
| 19 | namespace Solid |
| 20 | { |
| 21 | namespace Backends |
| 22 | { |
| 23 | namespace Fstab |
| 24 | { |
| 25 | class FstabHandling |
| 26 | { |
| 27 | public: |
| 28 | FstabHandling(); |
| 29 | |
| 30 | static QStringList deviceList(); |
| 31 | static QStringList currentMountPoints(const QString &device); |
| 32 | static QStringList mountPoints(const QString &device); |
| 33 | static QHash<QString, QString> options(const QString &device); |
| 34 | static QString fstype(const QString &device); |
| 35 | static bool callSystemCommand(const QString &commandName, const QStringList &args, const QObject *recvr, std::function<void(QProcess *)> callback); |
| 36 | static void flushMtabCache(); |
| 37 | static void flushFstabCache(); |
| 38 | |
| 39 | private: |
| 40 | static void _k_updateMtabMountPointsCache(); |
| 41 | static void _k_updateFstabMountPointsCache(); |
| 42 | |
| 43 | typedef QMultiHash<QString, QString> QStringMultiHash; |
| 44 | |
| 45 | QStringMultiHash m_mtabCache; |
| 46 | QStringMultiHash m_fstabCache; |
| 47 | QHash<QString, QHash<QString, QString>> m_fstabOptionsCache; |
| 48 | QHash<QString, QHash<QString, QString>> m_mtabOptionsCache; |
| 49 | QHash<QString, QString> m_fstabFstypeCache; |
| 50 | bool m_fstabCacheValid; |
| 51 | bool m_mtabCacheValid; |
| 52 | }; |
| 53 | |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | #endif |
| 59 | |