replace syscall::mkdir() with std::fs::create_dir_all()
This commit is contained in:
parent
3d7f3bdc60
commit
f5273c1fd3
|
@ -81,7 +81,10 @@ impl Mount {
|
||||||
"Making directory: {target}",
|
"Making directory: {target}",
|
||||||
target = self.target.display()
|
target = self.target.display()
|
||||||
));
|
));
|
||||||
syscall::mkdir(&self.target)?;
|
std::fs::create_dir_all(&self.target).context(format_args!(
|
||||||
|
"could not create directory: {target}",
|
||||||
|
target = self.target.display()
|
||||||
|
))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
dmesg(format!(
|
dmesg(format!(
|
||||||
|
|
|
@ -89,21 +89,6 @@ pub fn mount(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mkdir(path: impl AsRef<Path>) -> Result<()> {
|
|
||||||
let path = path.as_ref();
|
|
||||||
let path_cs = CString::new(path.as_os_str().as_encoded_bytes())
|
|
||||||
.context(format_args!("bad path: {path}", path = path.display()))?;
|
|
||||||
|
|
||||||
match unsafe { libc::mkdir(path_cs.as_ptr(), 0o755) } {
|
|
||||||
0 => Ok(()),
|
|
||||||
-1 => ctx_os_error(format_args!(
|
|
||||||
"error calling mkdir({path}, 0o755)",
|
|
||||||
path = path.display()
|
|
||||||
)),
|
|
||||||
n => unreachable!("mount() syscall returned bad value: {n}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn freopen(path: impl AsRef<Path>, mode: impl AsRef<str>, fd: &impl AsRawFd) -> Result<()> {
|
pub fn freopen(path: impl AsRef<Path>, mode: impl AsRef<str>, fd: &impl AsRawFd) -> Result<()> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
let mode = mode.as_ref();
|
let mode = mode.as_ref();
|
||||||
|
|
Loading…
Reference in New Issue