fix(files): keep the root filesystem among the volumes

main
reionwong 1 day ago
parent c33af4ac32
commit f7408d227b

@ -444,11 +444,11 @@ TEST(VolumeManagerTest, SystemMountPointsAreLeftOut)
using files::testing::waitFor; using files::testing::waitFor;
ASSERT_TRUE(waitFor(loop, [&] { return manager.volumes().size() == 4; })); ASSERT_TRUE(waitFor(loop, [&] { return manager.volumes().size() == 5; }));
std::vector<std::string> names; std::vector<std::string> names;
for (const Volume& volume : manager.volumes()) for (const Volume& volume : manager.volumes())
names.push_back(volume.name); names.push_back(volume.name);
EXPECT_EQ(names, (std::vector<std::string>{"data", "USB", "stick", "windows"})); EXPECT_EQ(names, (std::vector<std::string>{"data", "root", "USB", "stick", "windows"}));
// A Windows partition stays: it takes an administrator to mount, nothing more. // A Windows partition stays: it takes an administrator to mount, nothing more.
EXPECT_TRUE(manager.volume(root + "/block_devices/windows").system); EXPECT_TRUE(manager.volume(root + "/block_devices/windows").system);
EXPECT_FALSE(manager.volume(root + "/block_devices/stick").system); EXPECT_FALSE(manager.volume(root + "/block_devices/stick").system);

@ -42,6 +42,8 @@ static bool isSet(const ObjectPath& path)
static bool isSystemMountPoint(const std::string& path) static bool isSystemMountPoint(const std::string& path)
{ {
if (path == "/")
return false;
for (const std::string prefix : {"/media/", "/run/media/", "/mnt/"}) { for (const std::string prefix : {"/media/", "/run/media/", "/mnt/"}) {
if (path.starts_with(prefix)) if (path.starts_with(prefix))
return false; return false;

@ -45,9 +45,9 @@ struct Volume
}; };
// UDisks2's block devices, kept up to date from its signals, and mounting, // UDisks2's block devices, kept up to date from its signals, and mounting,
// unmounting and ejecting them. Calls never block. Blocks mounted outside // unmounting and ejecting them. Calls never block. Blocks mounted outside /,
// /media, /run/media and /mnt (the root, home and boot filesystems) are left // /media, /run/media and /mnt (the home and boot filesystems) are left out,
// out, and an unlocked encrypted volume stands for its cleartext block. // and an unlocked encrypted volume stands for its cleartext block.
class VolumeManager class VolumeManager
{ {
public: public:

Loading…
Cancel
Save