mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-28 03:43:23 +00:00
Add struct Path for VFS
Signed-off-by: Zhenchen Wang <m202372036@hust.edu.cn>
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
bc1bf4cb53
commit
6d486c6c01
@ -30,7 +30,7 @@ pub fn sys_linkat(
|
||||
);
|
||||
|
||||
let current = current!();
|
||||
let (old_dentry, new_dir_dentry, new_name) = {
|
||||
let (old_path, new_dir_path, 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_dentry = if flags.contains(LinkFlags::AT_SYMLINK_FOLLOW) {
|
||||
let old_path = if flags.contains(LinkFlags::AT_SYMLINK_FOLLOW) {
|
||||
fs.lookup(&old_fs_path)?
|
||||
} else {
|
||||
fs.lookup_no_follow(&old_fs_path)?
|
||||
};
|
||||
let (new_dir_dentry, new_name) = fs.lookup_dir_and_base_name(&new_fs_path)?;
|
||||
(old_dentry, new_dir_dentry, new_name)
|
||||
let (new_dir_path, new_name) = fs.lookup_dir_and_base_name(&new_fs_path)?;
|
||||
(old_path, new_dir_path, new_name)
|
||||
};
|
||||
new_dir_dentry.link(&old_dentry, &new_name)?;
|
||||
new_dir_path.link(&old_path, &new_name)?;
|
||||
Ok(SyscallReturn::Return(0))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user