MCPcopy Create free account
hub / github.com/bootc-dev/bootc / parse_kargs_toml

Function parse_kargs_toml

crates/lib/src/bootc_kargs.rs:246–260  ·  view source on GitHub ↗

This parses a bootc kargs.d toml file, returning the resulting vector of kernel arguments. Architecture matching is performed using `sys_arch`.

(contents: &str, sys_arch: &str)

Source from the content-addressed store, hash-verified

244/// vector of kernel arguments. Architecture matching is performed using
245/// `sys_arch`.
246fn parse_kargs_toml(contents: &str, sys_arch: &str) -> Result<Option<CmdlineOwned>> {
247 let de: Config = toml::from_str(contents)?;
248 // if arch specified, apply kargs only if the arch matches
249 // if arch not specified, apply kargs unconditionally
250 let matched = de
251 .match_architectures
252 .map(|arches| arches.iter().any(|s| s == sys_arch))
253 .unwrap_or(true);
254 let r = if matched {
255 Some(Cmdline::from(de.kargs.join(" ")))
256 } else {
257 None
258 };
259 Ok(r)
260}
261
262#[cfg(test)]
263mod tests {

Callers 3

get_kargs_in_rootFunction · 0.85
get_kargs_from_ostreeFunction · 0.85
test_archFunction · 0.85

Calls 1

iterMethod · 0.45

Tested by 1

test_archFunction · 0.68