Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storaged: btrfs: show btrfs filesystem "root" subvolume as "top-level" #21127

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test.

<StorageDescription title={_("ID")} value={subvol.id} />
{snapshot_origin !== null &&
<StorageDescription title={_("Snapshot origin")}>
Expand Down
7 changes: 4 additions & 3 deletions test/common/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1816,13 +1816,14 @@ def cleanup_home_dirs() -> None:
# cockpit configuration
self.restore_dir("/etc/cockpit")

if not m.ws_container:
if not m.ostree_image:
# for storage tests
self.restore_file("/etc/fstab")
self.restore_file("/etc/crypttab")

# tests expect cockpit.service to not run at start; also, avoid log leakage into the next test
self.addCleanup(m.execute, "systemctl stop --quiet cockpit")
if not m.ws_container:
# tests expect cockpit.service to not run at start; also, avoid log leakage into the next test
self.addCleanup(m.execute, "systemctl stop --quiet cockpit")

# The sssd daemon seems to get confused when we restore
# backups of /etc/group etc and stops following updates to it.
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