Skip to content

blockdev: Add list_dev_by_dir_optional - #2517

Merged
cgwalters merged 1 commit into
bootc-dev:mainfrom
cgwalters-forge:bot/blockdev-optional-dev
Sep 30, 2026
Merged

cgwalters merged 1 commit into
bootc-dev:mainfrom
cgwalters-forge:bot/blockdev-optional-dev

Conversation

@cgwalters-bot

Copy link
Copy Markdown
Contributor

Add list_dev_by_dir_optional(), which returns None when the filesystem mounted at a directory has no backing block device instead of failing in lsblk. bootupd needs this to skip the bootloader update on virtiofs (bcvk ephemeral), NFS roots and the like while still failing on real errors (coreos/bootupd#1163).

The check is st_dev: filesystems without a block device get an anonymous device number (major 0). btrfs and ZFS also get anonymous numbers although they are block-backed, so they are recognized by statfs magic and resolved as list_dev_by_dir already does (ZFS support there is from f61730b, bootc#1240).

Tested on a 16-core devspace: cargo test -p bootc-internal-blockdev, cargo clippy -p bootc-internal-blockdev --all-targets -- -D warnings and just validate pass.

The Signed-off-by: Colin Walters <walters@verbum.org> on these commits was added on cgwalters's approval of the review draft: cgwalters-forge#33 (review)

Generated-by: https://github.com/cgwalters/#llms

bootupd needs to tell "this filesystem has no backing block device"
(virtiofs in bcvk ephemeral, NFS root, ...) apart from real errors when
finding the device for /boot or /sysroot, so it can skip the bootloader
update in the first case. Guessing from the findmnt source string is
fragile; the kernel already says it via st_dev, since filesystems
without a block device get an anonymous device number with major 0.

btrfs and ZFS are the exceptions: they get anonymous device numbers too
although they sit on block devices, so recognize them by their statfs
magic and resolve them the way list_dev_by_dir already does (findmnt's
source for btrfs, the zpool members for ZFS since f61730b).

Generated-by: AI
Signed-off-by: Colin Walters <walters@verbum.org>

@cgwalters cgwalters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks sane though let's do a followup and add an integration test - useful pattern for this stuff is having an internals command which exposes the functionality at a baseline level run in tmt or so

@cgwalters
cgwalters enabled auto-merge (rebase) September 29, 2026 21:58
@cgwalters
cgwalters merged commit 1857859 into bootc-dev:main Sep 30, 2026
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants