-
Notifications
You must be signed in to change notification settings - Fork 174
Blockdev bugfixes #2005
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
Blockdev bugfixes #2005
Conversation
crates/blockdev/src/blockdev.rs
Outdated
| let sysfs_partn_path = format!("/sys/dev/block/{majmin}/partition"); | ||
| if Utf8Path::new(&sysfs_partn_path).try_exists()? { | ||
| let partn = std::fs::read_to_string(&sysfs_partn_path) | ||
| .with_context(|| format!("Reading {sysfs_partn_path}"))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor but I like using https://docs.rs/cap-std-ext/latest/cap_std_ext/dirext/trait.CapStdExtDirExt.html#tymethod.open_optional for things like this.
Though I guess what we should also do (for the many cases that operate on an ambient /) is have an extension trait wrapper somewhere like exists in composefs-rs https://github.com/containers/composefs-rs/blob/fc1d4e27ef054b9ececeeb58c985c77727ceaff4/crates/composefs/src/util.rs#L119
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a couple of bugfixes for block device handling. A new field partn is added to the Device struct to store the partition number, with a backfill mechanism from sysfs for older systems. Additionally, /run/udev is now mounted from the host to ensure lsblk functions correctly within the container.
My review found a potential issue in the backfill logic. The backfill_partn function should only execute if the partition number is actually missing, to avoid overwriting valid data from newer lsblk versions. A code suggestion is provided to address this.
Without access to udev state, lsblk may fail during install-to-disk operations. See bootc-dev#688 Assisted-by: Claude Code (claude-opus-4-5-20251101) Signed-off-by: ckyrouac <ckyrouac@redhat.com>
77c56af to
2b7c3b3
Compare
The "partn" column was added in util-linux 2.39, which is newer than what CentOS 9 / RHEL 9 ship (2.37). Read the partition number from sysfs when lsblk doesn't provide it. This is done by refactoring the existing backfill function into a more generic one used to backfill both start and partn. Assisted-by: Claude Code (claude-opus-4-5-20251101) Signed-off-by: ckyrouac <ckyrouac@redhat.com>
2b7c3b3 to
d18f601
Compare
|
refactored this to use a shared function to backfill both |
A couple small fixes that are prep for multi device support. Related to #1911 and #2000.