From f7408d227b8839541afa7e0749d7a389449c6f2b Mon Sep 17 00:00:00 2001 From: reionwong Date: Mon, 26 Oct 2026 18:23:53 +0800 Subject: [PATCH] fix(files): keep the root filesystem among the volumes --- files/tests/volume_manager_test.cpp | 4 ++-- files/volume_manager.cpp | 2 ++ files/volume_manager.h | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/files/tests/volume_manager_test.cpp b/files/tests/volume_manager_test.cpp index 212bc5b..1159a76 100644 --- a/files/tests/volume_manager_test.cpp +++ b/files/tests/volume_manager_test.cpp @@ -444,11 +444,11 @@ TEST(VolumeManagerTest, SystemMountPointsAreLeftOut) using files::testing::waitFor; - ASSERT_TRUE(waitFor(loop, [&] { return manager.volumes().size() == 4; })); + ASSERT_TRUE(waitFor(loop, [&] { return manager.volumes().size() == 5; })); std::vector names; for (const Volume& volume : manager.volumes()) names.push_back(volume.name); - EXPECT_EQ(names, (std::vector{"data", "USB", "stick", "windows"})); + EXPECT_EQ(names, (std::vector{"data", "root", "USB", "stick", "windows"})); // A Windows partition stays: it takes an administrator to mount, nothing more. EXPECT_TRUE(manager.volume(root + "/block_devices/windows").system); EXPECT_FALSE(manager.volume(root + "/block_devices/stick").system); diff --git a/files/volume_manager.cpp b/files/volume_manager.cpp index 2fbf300..0149dcc 100644 --- a/files/volume_manager.cpp +++ b/files/volume_manager.cpp @@ -42,6 +42,8 @@ static bool isSet(const ObjectPath& path) static bool isSystemMountPoint(const std::string& path) { + if (path == "/") + return false; for (const std::string prefix : {"/media/", "/run/media/", "/mnt/"}) { if (path.starts_with(prefix)) return false; diff --git a/files/volume_manager.h b/files/volume_manager.h index 5052c92..e878e53 100644 --- a/files/volume_manager.h +++ b/files/volume_manager.h @@ -45,9 +45,9 @@ struct Volume }; // UDisks2's block devices, kept up to date from its signals, and mounting, -// unmounting and ejecting them. Calls never block. Blocks mounted outside -// /media, /run/media and /mnt (the root, home and boot filesystems) are left -// out, and an unlocked encrypted volume stands for its cleartext block. +// unmounting and ejecting them. Calls never block. Blocks mounted outside /, +// /media, /run/media and /mnt (the home and boot filesystems) are left out, +// and an unlocked encrypted volume stands for its cleartext block. class VolumeManager { public: