Skip to content

Commit

Permalink
storage: More precise ignoring of "other mounts"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mvollmer committed Aug 19, 2024
1 parent 01357bd commit d0336f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
16 changes: 11 additions & 5 deletions pkg/storaged/filesystem/mismounting.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
11 changes: 6 additions & 5 deletions test/verify/check-storage-btrfs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d0336f4

Please sign in to comment.