replace syscall::mkdir() with std::fs::create_dir_all()

This commit is contained in:
Ryan Heywood 2025-08-10 21:48:20 -04:00 committed by RyanSquared
parent 1a1a0bf3e8
commit 686bd8b7fe
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
2 changed files with 4 additions and 16 deletions

View File

@ -81,7 +81,10 @@ impl Mount {
"Making directory: {target}",
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!(

View File

@ -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<()> {
let path = path.as_ref();
let mode = mode.as_ref();