Skip to content

Commit

Permalink
Merge pull request #1228 from stlankes/common
Browse files Browse the repository at this point in the history
add interface to create a directory
  • Loading branch information
stlankes authored May 26, 2024
2 parents c94bb91 + 3de7906 commit e3ef8f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,12 @@ pub unsafe fn create_file(
}
}

/// Returns an vectri with all the entries within a directory.
/// Creates a new, empty directory at the provided path
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.
pub fn readdir(name: &str) -> Result<Vec<DirectoryEntry>, IoError> {
debug!("Read directory {}", name);

Expand Down
6 changes: 1 addition & 5 deletions src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit e3ef8f1

Please sign in to comment.