From 3de7906fddbd132556ef023037398fe581cf36a7 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sun, 26 May 2024 10:04:07 +0200 Subject: [PATCH] remove code duplication, sys_mkdir reuses fs:create_dir --- src/fs/mod.rs | 7 ++----- src/syscalls/mod.rs | 6 +----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/fs/mod.rs b/src/fs/mod.rs index ad960a98ea..16d59c064e 100644 --- a/src/fs/mod.rs +++ b/src/fs/mod.rs @@ -371,11 +371,8 @@ pub unsafe fn create_file( } /// Creates a new, empty directory at the provided path -pub fn create_dir(path: &str) -> Result<(), IoError> { - FILESYSTEM - .get() - .unwrap() - .mkdir(path, AccessPermission::from_bits(0o777).unwrap()) +pub fn create_dir(path: &str, mode: AccessPermission) -> Result<(), IoError> { + FILESYSTEM.get().unwrap().mkdir(path, mode) } /// Returns an vector with all the entries within a directory. diff --git a/src/syscalls/mod.rs b/src/syscalls/mod.rs index e1fc3809db..88d429ffa4 100644 --- a/src/syscalls/mod.rs +++ b/src/syscalls/mod.rs @@ -317,11 +317,7 @@ pub unsafe extern "C" fn sys_mkdir(name: *const u8, mode: u32) -> i32 { return -crate::errno::EINVAL; }; - fs::FILESYSTEM - .get() - .unwrap() - .mkdir(name, mode) - .map_or_else(|e| -num::ToPrimitive::to_i32(&e).unwrap(), |_| 0) + crate::fs::create_dir(name, mode).map_or_else(|e| -num::ToPrimitive::to_i32(&e).unwrap(), |_| 0) } #[hermit_macro::system]