From d0336f41706a0381e0e55589e267c701f5bbbc0b Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 19 Aug 2024 11:57:12 +0300 Subject: [PATCH] storage: More precise ignoring of "other mounts" We used to ignore all other mounts when the first one is for the root filesystem. But filesystems can have more than one mount and we should look at each one individually. This also prepares the code for more cases. --- pkg/storaged/filesystem/mismounting.jsx | 16 +++++++++++----- test/verify/check-storage-btrfs | 11 ++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/pkg/storaged/filesystem/mismounting.jsx b/pkg/storaged/filesystem/mismounting.jsx index 0fb5fb7756cf..4fa4340aeae7 100644 --- a/pkg/storaged/filesystem/mismounting.jsx +++ b/pkg/storaged/filesystem/mismounting.jsx @@ -45,13 +45,22 @@ export function check_mismounted_fsys(backing_block, content_block, fstab_config if (!(block_fsys || dir)) return; + function ignore_mount(m) { + // We don't complain about the rootfs, it's probably + // configured somewhere else, like in the bootloader. + if (m == "/") + return true; + + return false; + } + const mounted_at = get_mount_points(client, block_fsys, subvol); const split_options = parse_options(opts); const opt_noauto = extract_option(split_options, "noauto"); const opt_noauto_intent = extract_option(split_options, "x-cockpit-never-auto"); const opt_systemd_automount = split_options.indexOf("x-systemd.automount") >= 0; const is_mounted = mounted_at.indexOf(dir) >= 0; - const other_mounts = mounted_at.filter(m => m != dir); + const other_mounts = mounted_at.filter(m => m != dir && !ignore_mount(m)); const crypto_backing_noauto = get_cryptobacking_noauto(client, backing_block); let type; @@ -68,10 +77,7 @@ export function check_mismounted_fsys(backing_block, content_block, fstab_config else if (is_mounted && opt_noauto && !opt_noauto_intent && !opt_systemd_automount) type = "no-mount-on-boot"; } else if (other_mounts.length > 0) { - // We don't complain about the rootfs, it's probably - // configured somewhere else, like in the bootloader. - if (other_mounts[0] != "/") - type = "mounted-no-config"; + type = "mounted-no-config"; } if (type) diff --git a/test/verify/check-storage-btrfs b/test/verify/check-storage-btrfs index f901c8b9091d..bdcff493f1dc 100755 --- a/test/verify/check-storage-btrfs +++ b/test/verify/check-storage-btrfs @@ -507,11 +507,12 @@ class TestStorageBtrfs(storagelib.StorageCase): b.click(self.card_button("btrfs subvolume", f"Mount automatically on {mount_point} on boot")) b.wait_not_present(self.card_button("btrfs subvolume", f"Mount automatically on {mount_point} on boot")) - # No warnings on main page for either subvolumes - b.go("#/") - b.wait_visible(self.card("Storage")) - b.wait_not_present(self.card_row("Storage", name=subvol) + ' .ct-icon-exclamation-triangle') - b.wait_not_present(self.card_row("Storage", name="/") + ' .ct-icon-exclamation-triangle') + # No warnings for either subvolume + b.go(f"#/") + self.click_card_row("Storage", name=disk1) + b.wait_visible(self.card("btrfs filesystem")) + b.wait_not_present(self.card_row("btrfs filesystem", name=subvol) + ' .ct-icon-exclamation-triangle') + b.wait_not_present(self.card_row("btrfs filesystem", name="/") + ' .ct-icon-exclamation-triangle') def testLuksEncrypted(self): m = self.machine