Rename struct Path to struct DentryMnt

Signed-off-by: Zhenchen Wang <m202372036@hust.edu.cn>
This commit is contained in:
plucky
2024-04-15 20:08:04 +08:00
committed by Tate, Hongliang Tian
parent 6d486c6c01
commit 60fa4d104a
35 changed files with 250 additions and 237 deletions

View File

@ -30,7 +30,7 @@ pub fn sys_linkat(
);
let current = current!();
let (old_path, new_dir_path, new_name) = {
let (old_dentrymnt, new_dir_dentrymnt, new_name) = {
let old_pathname = old_pathname.to_string_lossy();
if old_pathname.ends_with('/') {
return_errno_with_message!(Errno::EPERM, "oldpath is dir");
@ -46,15 +46,15 @@ pub fn sys_linkat(
let old_fs_path = FsPath::new(old_dirfd, old_pathname.as_ref())?;
let new_fs_path = FsPath::new(new_dirfd, new_pathname.as_ref())?;
let fs = current.fs().read();
let old_path = if flags.contains(LinkFlags::AT_SYMLINK_FOLLOW) {
let old_dentrymnt = if flags.contains(LinkFlags::AT_SYMLINK_FOLLOW) {
fs.lookup(&old_fs_path)?
} else {
fs.lookup_no_follow(&old_fs_path)?
};
let (new_dir_path, new_name) = fs.lookup_dir_and_base_name(&new_fs_path)?;
(old_path, new_dir_path, new_name)
let (new_dir_dentrymnt, new_name) = fs.lookup_dir_and_base_name(&new_fs_path)?;
(old_dentrymnt, new_dir_dentrymnt, new_name)
};
new_dir_path.link(&old_path, &new_name)?;
new_dir_dentrymnt.link(&old_dentrymnt, &new_name)?;
Ok(SyscallReturn::Return(0))
}