mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-28 00:07:16 +00:00
Merge pull request #1478 from lifupan/fix_device
rustjail: fix the issue of bind mount device file from guest
This commit is contained in:
commit
f6630ddd49
@ -736,10 +736,10 @@ fn mount_from(
|
|||||||
|
|
||||||
let src = if m.r#type.as_str() == "bind" {
|
let src = if m.r#type.as_str() == "bind" {
|
||||||
let src = fs::canonicalize(m.source.as_str())?;
|
let src = fs::canonicalize(m.source.as_str())?;
|
||||||
let dir = if src.is_file() {
|
let dir = if src.is_dir() {
|
||||||
Path::new(&dest).parent().unwrap()
|
|
||||||
} else {
|
|
||||||
Path::new(&dest)
|
Path::new(&dest)
|
||||||
|
} else {
|
||||||
|
Path::new(&dest).parent().unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = fs::create_dir_all(&dir).map_err(|e| {
|
let _ = fs::create_dir_all(&dir).map_err(|e| {
|
||||||
@ -752,7 +752,7 @@ fn mount_from(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// make sure file exists so we can bind over it
|
// make sure file exists so we can bind over it
|
||||||
if src.is_file() {
|
if !src.is_dir() {
|
||||||
let _ = OpenOptions::new().create(true).write(true).open(&dest);
|
let _ = OpenOptions::new().create(true).write(true).open(&dest);
|
||||||
}
|
}
|
||||||
src.to_str().unwrap().to_string()
|
src.to_str().unwrap().to_string()
|
||||||
|
Loading…
Reference in New Issue
Block a user