Skip to content

Commit

Permalink
Check if folder already exists before creating one
Browse files Browse the repository at this point in the history
  • Loading branch information
0x050f committed Oct 3, 2023
1 parent d52fe32 commit e6f79eb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions srcs/fs/ext2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,11 @@ pub fn create_dir(path: &str, inode_no: usize) {
match inode {
None => {crate::kprintln!("Path not found: {}", path);}
Some((inode_no, mut inode)) => {
let check_exist = ext2.recurs_find(&to_create, inode_no);
if check_exist.is_some() {
crate::kprintln!("'{}' already exists.", to_create);
return ;
}
let mut new_inode = inode::Inode::new();
// perm: directory and 0755
new_inode.tperm = inode::ITYPE_DIR | inode::IPERM_UREAD | inode::IPERM_UWRIT | inode::IPERM_UEXEC | inode::IPERM_GREAD | inode::IPERM_GEXEC | inode::IPERM_OREAD | inode::IPERM_OEXEC;
Expand Down

0 comments on commit e6f79eb

Please sign in to comment.