From 86ce088f66c158b340e15f5d981cdbf53db0b075 Mon Sep 17 00:00:00 2001 From: Rafael Sadowski Date: Thu, 13 May 2021 13:17:25 +0200 Subject: [PATCH 1/3] Add ext2fs, msdos and ntfs support --- src/blockfilesystem.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/blockfilesystem.cpp b/src/blockfilesystem.cpp index 9bb3b9a..b3f37ef 100644 --- a/src/blockfilesystem.cpp +++ b/src/blockfilesystem.cpp @@ -230,7 +230,10 @@ void BlockFilesystem::setFilesystem(const QString& fs) bool BlockFilesystem::isFilesystemSupportedToMount() const { - return (filesystem == "ffs"); + return (filesystem == "ffs" + || filesystem == "ext2fs" + || filesystem == "ntfs" + || filesystem == "msdos"); } const QString BlockFilesystem::getMountCommand() const @@ -239,6 +242,15 @@ const QString BlockFilesystem::getMountCommand() const if (filesystem == "ffs") { mountProg = QStringLiteral("/sbin/mount_ffs"); } + else if (filesystem == "ext2fs") { + mountProg = QStringLiteral("/sbin/mount_ext2fs"); + } + else if (filesystem == "ntfs") { + mountProg = QStringLiteral("/sbin/mount_ntfs"); + } + else if (filesystem == "ntfs") { + mountProg = QStringLiteral("/sbin/mount_msdos"); + } return mountProg; } @@ -248,5 +260,14 @@ const QStringList BlockFilesystem::getMountOptions() const if (filesystem == "ffs") { mountOps << QStringLiteral("-orw,nodev,nosuid,noatime"); } + else if (filesystem == "ext2fs") { + mountOps << QStringLiteral("-orw,nodev,nosuid,noatime"); + } + else if (filesystem == "msdos") { + mountOps << QStringLiteral("-orw"); + } + else if (filesystem == "ntfs") { + mountOps << QStringLiteral("-oro"); + } return mountOps; } From 5c7f4133d27410231cb829def5014d1418438e7f Mon Sep 17 00:00:00 2001 From: Rafael Sadowski Date: Thu, 13 May 2021 13:24:18 +0200 Subject: [PATCH 2/3] Fix signalMountPointsChanged --- src/blockfilesystem.cpp | 8 ++++---- src/blockfilesystem.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/blockfilesystem.cpp b/src/blockfilesystem.cpp index b3f37ef..9ba230a 100644 --- a/src/blockfilesystem.cpp +++ b/src/blockfilesystem.cpp @@ -154,7 +154,7 @@ QString BlockFilesystem::Mount(const Block& block, } addMountPoint(mountPoint); - signalMountPointsChanged(); + signalMountPointsChanged(block); return mountPoint; } @@ -191,7 +191,7 @@ void BlockFilesystem::Unmount(const Block& block, removeMountPoint(mountPoint, true); QString errorMessage = umount.readAllStandardError(); conn.send(msg.createErrorReply("org.freedesktop.UDisks2.Error.Failed", errorMessage)); - signalMountPointsChanged(); + signalMountPointsChanged(block); } else { removeMountPoint(mountPoint, true); mountPoints.removeAll(mountPoint); @@ -199,13 +199,13 @@ void BlockFilesystem::Unmount(const Block& block, } } -void BlockFilesystem::signalMountPointsChanged() +void BlockFilesystem::signalMountPointsChanged(const Block& block) { QVariantMap props; props.insert(QStringLiteral("MountPoints"), QVariant::fromValue(getMountPoints().join(","))); QDBusMessage signal = - QDBusMessage::createSignal("", // XX parentBlock()->dbusPath.path(), + QDBusMessage::createSignal(block.getDbusPath().path(), QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged")); diff --git a/src/blockfilesystem.h b/src/blockfilesystem.h index a60a972..68e8722 100644 --- a/src/blockfilesystem.h +++ b/src/blockfilesystem.h @@ -47,7 +47,7 @@ class BlockFilesystem void setFilesystem(const QString&); private: - void signalMountPointsChanged(); + void signalMountPointsChanged(const Block&); bool isFilesystemSupportedToMount() const; const QString getMountCommand() const; const QStringList getMountOptions() const; From eb517f48f331578aa8e5ce9729e1116f551bac5e Mon Sep 17 00:00:00 2001 From: Rafael Sadowski Date: Thu, 13 May 2021 13:56:54 +0200 Subject: [PATCH 3/3] format --- src/blockfilesystem.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/blockfilesystem.cpp b/src/blockfilesystem.cpp index 9ba230a..e4b5d2c 100644 --- a/src/blockfilesystem.cpp +++ b/src/blockfilesystem.cpp @@ -230,10 +230,8 @@ void BlockFilesystem::setFilesystem(const QString& fs) bool BlockFilesystem::isFilesystemSupportedToMount() const { - return (filesystem == "ffs" - || filesystem == "ext2fs" - || filesystem == "ntfs" - || filesystem == "msdos"); + return (filesystem == "ffs" || filesystem == "ext2fs" || filesystem == "ntfs" || + filesystem == "msdos"); } const QString BlockFilesystem::getMountCommand() const @@ -241,14 +239,11 @@ const QString BlockFilesystem::getMountCommand() const QString mountProg; if (filesystem == "ffs") { mountProg = QStringLiteral("/sbin/mount_ffs"); - } - else if (filesystem == "ext2fs") { + } else if (filesystem == "ext2fs") { mountProg = QStringLiteral("/sbin/mount_ext2fs"); - } - else if (filesystem == "ntfs") { + } else if (filesystem == "ntfs") { mountProg = QStringLiteral("/sbin/mount_ntfs"); - } - else if (filesystem == "ntfs") { + } else if (filesystem == "ntfs") { mountProg = QStringLiteral("/sbin/mount_msdos"); } return mountProg; @@ -259,14 +254,11 @@ const QStringList BlockFilesystem::getMountOptions() const QStringList mountOps; if (filesystem == "ffs") { mountOps << QStringLiteral("-orw,nodev,nosuid,noatime"); - } - else if (filesystem == "ext2fs") { + } else if (filesystem == "ext2fs") { mountOps << QStringLiteral("-orw,nodev,nosuid,noatime"); - } - else if (filesystem == "msdos") { + } else if (filesystem == "msdos") { mountOps << QStringLiteral("-orw"); - } - else if (filesystem == "ntfs") { + } else if (filesystem == "ntfs") { mountOps << QStringLiteral("-oro"); } return mountOps;