Skip to content

Commit 62dcbcc

Browse files
committed
blockdev: update get_devices() to change to /sysroot if /boot
is not mounted See pointer from coreos#855 (comment) If `/boot` isn't mounted we'll find the parent devices of `/sysroot` instead.
1 parent 013b50d commit 62dcbcc

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/blockdev.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use anyhow::{bail, Context, Result};
55
use bootc_blockdev::PartitionTable;
66
use fn_error_context::context;
77

8-
#[context("get parent devices from mount point boot")]
8+
#[context("get parent devices from mount point boot or sysroot")]
99
pub fn get_devices<P: AsRef<Path>>(target_root: P) -> Result<Vec<String>> {
1010
let target_root = target_root.as_ref();
1111
let bootdir = target_root.join("boot");
@@ -14,10 +14,18 @@ pub fn get_devices<P: AsRef<Path>>(target_root: P) -> Result<Vec<String>> {
1414
}
1515
let bootdir = openat::Dir::open(&bootdir)?;
1616
// Run findmnt to get the source path of mount point boot
17-
let fsinfo = crate::filesystem::inspect_filesystem(&bootdir, ".")?;
17+
// If failed, change to sysroot
18+
let source= if let Ok(fsinfo) = crate::filesystem::inspect_filesystem(&bootdir, ".") {
19+
fsinfo.source
20+
} else {
21+
let sysroot = target_root.join("sysroot");
22+
let sysrootdir = openat::Dir::open(&sysroot)?;
23+
let fsinfo = crate::filesystem::inspect_filesystem(&sysrootdir, ".")?;
24+
fsinfo.source
25+
};
1826
// Find the parent devices of the source path
19-
let parent_devices = bootc_blockdev::find_parent_devices(&fsinfo.source)
20-
.with_context(|| format!("while looking for backing devices of {}", fsinfo.source))?;
27+
let parent_devices = bootc_blockdev::find_parent_devices(&source)
28+
.with_context(|| format!("while looking for backing devices of {}", source))?;
2129
log::debug!("Find parent devices: {parent_devices:?}");
2230
Ok(parent_devices)
2331
}

0 commit comments

Comments
 (0)