Fix issue about pathname and redefine the Filetype.

Signed-off-by: Zhenchen Wang <m202372036@hust.edu.cn>
This commit is contained in:
Zhenchen Wang
2024-06-27 10:14:19 +08:00
committed by Tate, Hongliang Tian
parent d8389da797
commit 12b355b701
10 changed files with 103 additions and 44 deletions

View File

@ -37,8 +37,8 @@ pub fn sys_linkat(
return_errno_with_message!(Errno::ENOENT, "oldpath is empty");
}
let new_path = new_path.to_string_lossy();
if new_path.ends_with('/') || new_path.is_empty() {
return_errno_with_message!(Errno::ENOENT, "newpath is dir or is empty");
if new_path.is_empty() {
return_errno_with_message!(Errno::ENOENT, "newpath is empty");
}
let old_fs_path = FsPath::new(old_dirfd, old_path.as_ref())?;
@ -49,7 +49,7 @@ pub fn sys_linkat(
} else {
fs.lookup_no_follow(&old_fs_path)?
};
let (new_dir_dentry, new_name) = fs.lookup_dir_and_base_name(&new_fs_path)?;
let (new_dir_dentry, new_name) = fs.lookup_dir_and_new_basename(&new_fs_path, false)?;
(old_dentry, new_dir_dentry, new_name)
};