Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cannot correctly recoganize fstab partitions #2469

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/dfm-base/base/device/private/devicehelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include <QStandardPaths>
#include <QProcess>
#include <QTextStream>
#include <QJsonDocument>
#include <QJsonObject>

#include <dfm-mount/dmount.h>
#include <dfm-burn/dburn_global.h>
Expand Down Expand Up @@ -121,6 +123,20 @@ QVariantMap DeviceHelper::loadBlockInfo(const BlockDevAutoPtr &dev)
datas[kDriveModel] = getNullStrIfNotValid(Property::kDriveModel);
datas[kPreferredDevice] = getNullStrIfNotValid(Property::kBlockPreferredDevice);

auto config = dev->getProperty(Property::kBlockConfiguration).toMap();
if (!config.isEmpty()) {
QJsonObject jsonRootObj;
QMapIterator<QString, QVariant> iter(config);
while (iter.hasNext()) {
iter.next();
auto key = iter.key();
QVariantMap value = iter.value().toMap();
jsonRootObj.insert(key, QJsonObject::fromVariantMap(value));
}
QJsonDocument doc(jsonRootObj);
datas[kConfiguration] = QString(doc.toJson(QJsonDocument::Compact));
}

datas[kUDisks2Size] = dev->sizeTotal();
auto mpt = dev->mountPoint();
if (!mpt.isEmpty() && !dev->optical()) {
Expand Down
1 change: 1 addition & 0 deletions src/dfm-base/dbusservice/global_server_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ inline constexpr char kConnectionBus[] { "ConnectionBus" };
inline constexpr char kUDisks2Size[] { "UDisks2Size" };
inline constexpr char kDriveModel[] { "DriveModel" };
inline constexpr char kPreferredDevice[] { "PreferredDevice" };
inline constexpr char kConfiguration[] { "Configuration" };
} // namespace DeviceProperty

/*!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#include <QDBusInterface>
#include <QDBusReply>
#include <QApplication>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>

#include <ddialog.h>
#include <dconfig.h>
Expand Down Expand Up @@ -105,9 +108,20 @@ bool DiskEncryptMenuScene::initialize(const QVariantHash &params)
return false;
}

param.initOnly = false;
auto configJson = selectedItemInfo.value("Configuration", "").toString();
if (!configJson.isEmpty()) {
QJsonParseError err;
QJsonDocument doc = QJsonDocument::fromJson(configJson.toLocal8Bit(), &err);
if (err.error != QJsonParseError::NoError) {
qWarning() << "device configuration not valid!" << device << configJson;
return false;
}
auto obj = doc.object();
param.initOnly = obj.contains("fstab");
}
param.devID = selectedItemInfo.value("Id").toString();
param.devDesc = device;
param.initOnly = fstab_utils::isFstabItem(devMpt);
param.mountPoint = devMpt;
param.uuid = selectedItemInfo.value("IdUUID", "").toString();
param.deviceDisplayName = info->displayOf(dfmbase::FileInfo::kFileDisplayName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,6 @@ QString config_utils::cipherType()
return cipher;
}

bool fstab_utils::isFstabItem(const QString &mpt)
{
if (mpt.isEmpty())
return false;

bool fstabed { false };
struct fstab *fs;
setfsent();
while ((fs = getfsent()) != nullptr) {
QString path = fs->fs_file;
if (mpt == path) {
fstabed = true;
break;
}
}
endfsent();
return fstabed;
}

int tpm_utils::checkTPM()
{
return dpfSlotChannel->push("dfmplugin_encrypt_manager", "slot_TPMIsAvailablePro").toInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ namespace recovery_key_utils {
QString formatRecoveryKey(const QString &raw);
}

namespace fstab_utils {
bool isFstabItem(const QString &mpt);
} // namespace fstab_utils

namespace device_utils {
int encKeyType(const QString &dev);
void cacheToken(const QString &device, const QVariantMap &token);
Expand Down
Loading