mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-05-02 13:44:33 +00:00
rustjail: Wrap remaining nix errors with anyhow
Replace `Result` values that use a "bare" `nix` `Error` like this: ```rust return Err(nix::Error::EINVAL.into()); ``` ... to the following which wraps the nix` error in an `anyhow` call for consistency with the other errors returned by `rustjail`: ```rust return Err(anyhow!(nix::Error::EINVAL)); ``` Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
parent
30d6007893
commit
aba572e01d
@ -174,7 +174,7 @@ impl CgroupManager for Manager {
|
||||
freezer_controller.freeze()?;
|
||||
}
|
||||
_ => {
|
||||
return Err(nix::Error::EINVAL.into());
|
||||
return Err(anyhow!(nix::Error::EINVAL));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1388,13 +1388,13 @@ impl LinuxContainer {
|
||||
.context(format!("cannot change onwer of container {} root", id))?;
|
||||
|
||||
if config.spec.is_none() {
|
||||
return Err(nix::Error::EINVAL.into());
|
||||
return Err(anyhow!(nix::Error::EINVAL));
|
||||
}
|
||||
|
||||
let spec = config.spec.as_ref().unwrap();
|
||||
|
||||
if spec.linux.is_none() {
|
||||
return Err(nix::Error::EINVAL.into());
|
||||
return Err(anyhow!(nix::Error::EINVAL));
|
||||
}
|
||||
|
||||
let linux = spec.linux.as_ref().unwrap();
|
||||
|
@ -999,7 +999,7 @@ pub fn finish_rootfs(cfd_log: RawFd, spec: &Spec, process: &Process) -> Result<(
|
||||
|
||||
fn mask_path(path: &str) -> Result<()> {
|
||||
if !path.starts_with('/') || path.contains("..") {
|
||||
return Err(nix::Error::EINVAL.into());
|
||||
return Err(anyhow!(nix::Error::EINVAL));
|
||||
}
|
||||
|
||||
match mount(
|
||||
@ -1019,7 +1019,7 @@ fn mask_path(path: &str) -> Result<()> {
|
||||
|
||||
fn readonly_path(path: &str) -> Result<()> {
|
||||
if !path.starts_with('/') || path.contains("..") {
|
||||
return Err(nix::Error::EINVAL.into());
|
||||
return Err(anyhow!(nix::Error::EINVAL));
|
||||
}
|
||||
|
||||
if let Err(e) = mount(
|
||||
|
Loading…
Reference in New Issue
Block a user