feat: 添加SYS_MKDIRAT系统调用 (#986)

将内核原本实现的do_mkdir_at暴露出来,实现SYS_MKDIRAT

Signed-off-by: longjin <longjin@DragonOS.org>
This commit is contained in:
LoGin 2024-10-17 11:38:40 +08:00 committed by GitHub
parent f9fe30be89
commit dcd345f6d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

View File

@ -172,7 +172,8 @@ pub fn do_mkdir_at(
user_path_at(&ProcessManager::current_pcb(), dirfd, path.trim())?;
let (name, parent) = rsplit_path(&path);
if let Some(parent) = parent {
current_inode = current_inode.lookup(parent)?;
current_inode =
current_inode.lookup_follow_symlink(parent, VFS_MAX_FOLLOW_SYMLINK_TIMES)?;
}
// debug!("mkdir at {:?}", current_inode.metadata()?.inode_id);
return current_inode.mkdir(name, ModeType::from_bits_truncate(mode.bits()));

View File

@ -807,6 +807,14 @@ impl Syscall {
return Ok(0);
}
pub fn mkdir_at(dirfd: i32, path: *const u8, mode: usize) -> Result<usize, SystemError> {
let path = check_and_clone_cstr(path, Some(MAX_PATHLEN))?
.into_string()
.map_err(|_| SystemError::EINVAL)?;
do_mkdir_at(dirfd, &path, FileMode::from_bits_truncate(mode as u32))?;
return Ok(0);
}
/// **创建硬连接的系统调用**
///
/// ## 参数

View File

@ -295,6 +295,13 @@ impl Syscall {
Self::mkdir(path, mode)
}
SYS_MKDIRAT => {
let dirfd = args[0] as i32;
let path = args[1] as *const u8;
let mode = args[2];
Self::mkdir_at(dirfd, path, mode)
}
SYS_NANOSLEEP => {
let req = args[0] as *const PosixTimeSpec;
let rem = args[1] as *mut PosixTimeSpec;