Skip to content

Commit

Permalink
Add initial ext2fs, msdos and ntfs support (#5)
Browse files Browse the repository at this point in the history
* Add ext2fs, msdos and ntfs support

* Fix signalMountPointsChanged

* format
  • Loading branch information
sizeofvoid committed May 15, 2021
1 parent 4585c50 commit 996088c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 18 additions & 5 deletions src/blockfilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ QString BlockFilesystem::Mount(const Block& block,
}

addMountPoint(mountPoint);
signalMountPointsChanged();
signalMountPointsChanged(block);
return mountPoint;
}

Expand Down Expand Up @@ -191,21 +191,21 @@ 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);
}
}
}

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"));

Expand All @@ -230,14 +230,21 @@ 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
{
QString mountProg;
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;
}
Expand All @@ -247,6 +254,12 @@ const QStringList BlockFilesystem::getMountOptions() const
QStringList mountOps;
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;
}
2 changes: 1 addition & 1 deletion src/blockfilesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 996088c

Please sign in to comment.