Skip to content

Commit

Permalink
Merge pull request #3836 from jmt-lab/jmt/prairiedog/fix-ecs-1
Browse files Browse the repository at this point in the history
prairiedog: if the variant doesn't support boot settings be okay with…
  • Loading branch information
jmt-lab authored Mar 26, 2024
2 parents c034888 + cc791a8 commit cf8f2b7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions sources/api/prairiedog/src/bootconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize};
use snafu::{ensure, ResultExt};
use std::collections::HashMap;
use std::convert::TryInto;
use std::io::ErrorKind;
use std::path::Path;
use std::{fs, io};

Expand Down Expand Up @@ -117,10 +118,20 @@ fn get_boot_config_settings<P>(config_path: P) -> Result<Option<BootSettings>>
where
P: AsRef<Path>,
{
let config_str = fs::read_to_string(config_path.as_ref()).context(error::ReadFileSnafu {
path: config_path.as_ref().to_path_buf(),
})?;
toml::from_str(config_str.as_str()).context(error::InputTomlSnafu)
let config_path = config_path.as_ref();
match fs::read_to_string(config_path) {
Ok(config_str) => toml::from_str(config_str.as_str()).context(error::InputTomlSnafu),
Err(e) => {
if e.kind() == ErrorKind::NotFound {
Ok(None)
} else {
Err(error::Error::ReadFile {
source: e,
path: config_path.to_path_buf(),
})
}
}
}
}

/// Reads `/proc/bootconfig`. Not having any boot config is ignored.
Expand Down

0 comments on commit cf8f2b7

Please sign in to comment.