mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
rustjail: check result to let it return early.
check the result to let it return early if there are some errors Fixes: #4708 Signed-off-by: liubin <liubin0329@gmail.com>
This commit is contained in:
parent
6d56cdb9ac
commit
eec9ac81ef
@ -786,12 +786,25 @@ fn mount_from(
|
|||||||
"create dir {}: {}",
|
"create dir {}: {}",
|
||||||
dir.to_str().unwrap(),
|
dir.to_str().unwrap(),
|
||||||
e.to_string()
|
e.to_string()
|
||||||
)
|
);
|
||||||
});
|
e
|
||||||
|
})?;
|
||||||
|
|
||||||
// make sure file exists so we can bind over it
|
// make sure file exists so we can bind over it
|
||||||
if !src.is_dir() {
|
if !src.is_dir() {
|
||||||
let _ = OpenOptions::new().create(true).write(true).open(&dest);
|
let _ = OpenOptions::new()
|
||||||
|
.create(true)
|
||||||
|
.write(true)
|
||||||
|
.open(&dest)
|
||||||
|
.map_err(|e| {
|
||||||
|
log_child!(
|
||||||
|
cfd_log,
|
||||||
|
"open/create dest error. {}: {:?}",
|
||||||
|
dest.as_str(),
|
||||||
|
e
|
||||||
|
);
|
||||||
|
e
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
src.to_str().unwrap().to_string()
|
src.to_str().unwrap().to_string()
|
||||||
} else {
|
} else {
|
||||||
@ -804,8 +817,10 @@ fn mount_from(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = stat::stat(dest.as_str())
|
let _ = stat::stat(dest.as_str()).map_err(|e| {
|
||||||
.map_err(|e| log_child!(cfd_log, "dest stat error. {}: {:?}", dest.as_str(), e));
|
log_child!(cfd_log, "dest stat error. {}: {:?}", dest.as_str(), e);
|
||||||
|
e
|
||||||
|
})?;
|
||||||
|
|
||||||
mount(
|
mount(
|
||||||
Some(src.as_str()),
|
Some(src.as_str()),
|
||||||
|
Loading…
Reference in New Issue
Block a user