From 18b510ebae352443c231c608cfe82a99fefcd708 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 16 Oct 2024 16:48:09 +0200 Subject: [PATCH] storaged: btrfs: show btrfs filesystem "root" subvolume as "top-level" Showing this as "/" confuses users as they might think it is the root partition and official btrfs terminology names it "top-level". https://btrfs.readthedocs.io/en/latest/Subvolumes.html Relates: #19920 --- pkg/storaged/btrfs/subvolume.jsx | 15 +++++++++++++-- test/verify/check-storage-btrfs | 8 ++++---- test/verify/check-storage-mounting | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/pkg/storaged/btrfs/subvolume.jsx b/pkg/storaged/btrfs/subvolume.jsx index 986409a5eaed..cec1772deb60 100644 --- a/pkg/storaged/btrfs/subvolume.jsx +++ b/pkg/storaged/btrfs/subvolume.jsx @@ -404,6 +404,16 @@ function make_btrfs_subvolume_page(parent, volume, subvol, path_prefix, subvols) return str; } + // Show the hidden "root" of a btrfs filesystem as "top-level" as "/" can + // be confused with the root filesystem. + // https://btrfs.readthedocs.io/en/latest/Subvolumes.html + function subvol_name(subvol, path_prefix) { + if (subvol.id === 5) { + return _("top-level"); + } + return strip_prefix(subvol.pathname, path_prefix); + } + let snapshot_origin = null; if (subvol.id !== 5 && subvol.parent_uuid !== null) { for (const sv of subvols) { @@ -418,7 +428,7 @@ function make_btrfs_subvolume_page(parent, volume, subvol, path_prefix, subvols) title: _("btrfs subvolume"), next: null, page_location: ["btrfs", volume.data.uuid, subvol.pathname], - page_name: strip_prefix(subvol.pathname, path_prefix), + page_name: subvol_name(subvol, path_prefix), page_size: mounted && , location: mp_text, component: BtrfsSubvolumeCard, @@ -444,6 +454,7 @@ function make_btrfs_subvolume_page(parent, volume, subvol, path_prefix, subvols) const BtrfsSubvolumeCard = ({ card, volume, subvol, snapshot_origin, mismount_warning, block, fstab_config, forced_options }) => { const crossrefs = get_crossrefs(subvol.uuid); + console.log(subvol); return ( }> - + {snapshot_origin !== null && diff --git a/test/verify/check-storage-btrfs b/test/verify/check-storage-btrfs index 3d1acae6fa74..84a435f5a31e 100755 --- a/test/verify/check-storage-btrfs +++ b/test/verify/check-storage-btrfs @@ -63,7 +63,7 @@ class TestStorageBtrfs(storagelib.StorageCase): b.wait_visible(self.card_desc_action("btrfs filesystem", "Label") + ":disabled") # Unmount to change label - self.click_dropdown(self.card_row("btrfs filesystem", name="/"), "Unmount") + self.click_dropdown(self.card_row("btrfs filesystem", name="top-level"), "Unmount") self.confirm() b.wait_visible(self.card_row("btrfs filesystem", location=f"{mount_point} (not mounted)")) @@ -73,7 +73,7 @@ class TestStorageBtrfs(storagelib.StorageCase): b.wait_text(self.card_desc("btrfs filesystem", "Label"), label) # Mount writable for the rest of the test - self.click_dropdown(self.card_row("btrfs filesystem", name="/"), "Mount") + self.click_dropdown(self.card_row("btrfs filesystem", name="top-level"), "Mount") self.dialog({"mount_options.ro": False}) b.wait_visible(self.card_row("btrfs filesystem", location=f"{mount_point}")) @@ -92,7 +92,7 @@ class TestStorageBtrfs(storagelib.StorageCase): self.confirm() b.wait_visible(self.card_row("btrfs filesystem", location=f"{mount_point} (not mounted)")) - self.click_dropdown(self.card_row("btrfs filesystem", name="/"), "Mount") + self.click_dropdown(self.card_row("btrfs filesystem", name="top-level"), "Mount") self.confirm() b.wait_visible(self.card_row("btrfs filesystem", location=mount_point)) @@ -591,7 +591,7 @@ class TestStorageBtrfs(storagelib.StorageCase): self.login_and_go("/storage") self.click_card_row("Storage", name="sda") - b.wait_visible(self.card_row("btrfs filesystem", name="/")) + b.wait_visible(self.card_row("btrfs filesystem", name="top-level")) def testNothingMounted(self): m = self.machine diff --git a/test/verify/check-storage-mounting b/test/verify/check-storage-mounting index 321b124287d3..20a2eeda5448 100755 --- a/test/verify/check-storage-mounting +++ b/test/verify/check-storage-mounting @@ -28,7 +28,7 @@ class TestStorageMounting(storagelib.StorageCase): b = self.browser b.wait_visible(self.card("btrfs filesystem")) - self.click_card_row("btrfs filesystem", name="/") + self.click_card_row("btrfs filesystem", name="top-level") b.wait_visible(self.card("btrfs subvolume")) def testMounting(self):