Skip to content

Commit

Permalink
storaged: btrfs: show btrfs filesystem "root" subvolume as "top-level"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jelly committed Oct 31, 2024
1 parent a2b5796 commit 40cb4cb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
14 changes: 12 additions & 2 deletions pkg/storaged/btrfs/subvolume.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 && <StorageUsageBar stats={use} short />,
location: mp_text,
component: BtrfsSubvolumeCard,
Expand Down Expand Up @@ -452,7 +462,7 @@ const BtrfsSubvolumeCard = ({ card, volume, subvol, snapshot_origin, mismount_wa
backing_block={block} content_block={block} subvol={subvol} />}>
<CardBody>
<DescriptionList className="pf-m-horizontal-on-sm">
<StorageDescription title={_("Name")} value={subvol.pathname} />
<StorageDescription title={_("Name")} value={subvol.id === 5 ? "top-level" : subvol.pathname} />
<StorageDescription title={_("ID")} value={subvol.id} />
{snapshot_origin !== null &&
<StorageDescription title={_("Snapshot origin")}>
Expand Down
8 changes: 4 additions & 4 deletions test/verify/check-storage-btrfs
Original file line number Diff line number Diff line change
Expand Up @@ -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)"))

Expand All @@ -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}"))

Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/verify/check-storage-mounting
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 40cb4cb

Please sign in to comment.