-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #562 from cgwalters/write-uuid-install
Add support for root=boot (with EFI) and writing UUID file
- 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.