-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve EFI, add support for root=boot and writing UUID file
In FCOS we never tried to support root=boot, but for bootupd to do alongside installs in the general case we have to. There were two things to fix here: - Tweak the EFI "trampoline" to check for both $prefix/grub.cfg and $prefix/boot/grub.cfg - Add support for writing the boot UUID into both places (This avoids higher level tools like bootupd needing to know about how to find the EFI vendor dir) Then the bigger issue here is that we need to support invoking `efibootmgr` to re-synchronize the firmware. This is particularly important in cases like bootc "alongside" installs where we're taking over the target OS.
- Loading branch information
Showing
9 changed files
with
235 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use std::os::fd::AsRawFd; | ||
use std::os::unix::process::CommandExt; | ||
use std::process::Command; | ||
|
||
use anyhow::{Context, Result}; | ||
use fn_error_context::context; | ||
use serde::Deserialize; | ||
|
||
#[derive(Deserialize, Debug)] | ||
#[serde(rename_all = "kebab-case")] | ||
#[allow(dead_code)] | ||
pub(crate) struct Filesystem { | ||
pub(crate) source: String, | ||
pub(crate) fstype: String, | ||
pub(crate) options: String, | ||
pub(crate) uuid: Option<String>, | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub(crate) struct Findmnt { | ||
pub(crate) filesystems: Vec<Filesystem>, | ||
} | ||
|
||
#[context("Inspecting filesystem {path:?}")] | ||
pub(crate) fn inspect_filesystem(root: &openat::Dir, path: &str) -> Result<Filesystem> { | ||
let rootfd = root.as_raw_fd(); | ||
// SAFETY: This is unsafe just for the pre_exec, when we port to cap-std we can use cap-std-ext | ||
let o = unsafe { | ||
Command::new("findmnt") | ||
.args(["-J", "-v", "--output-all", path]) | ||
.pre_exec(move || nix::unistd::fchdir(rootfd).map_err(Into::into)) | ||
.output()? | ||
}; | ||
let st = o.status; | ||
if !st.success() { | ||
anyhow::bail!("findmnt failed: {st:?}"); | ||
} | ||
let o: Findmnt = serde_json::from_reader(std::io::Cursor::new(&o.stdout)) | ||
.context("Parsing findmnt output")?; | ||
o.filesystems | ||
.into_iter() | ||
.next() | ||
.ok_or_else(|| anyhow::anyhow!("findmnt returned no data")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.