mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
Kernel: Use TRY() in sys$link() and sys$symlink()
This commit is contained in:
parent
c902b3cb0d
commit
8cd4879946
1 changed files with 6 additions and 14 deletions
|
@ -17,13 +17,9 @@ KResultOr<FlatPtr> Process::sys$link(Userspace<const Syscall::SC_link_params*> u
|
||||||
Syscall::SC_link_params params;
|
Syscall::SC_link_params params;
|
||||||
if (!copy_from_user(¶ms, user_params))
|
if (!copy_from_user(¶ms, user_params))
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
auto old_path_or_error = try_copy_kstring_from_user(params.old_path);
|
auto old_path = TRY(try_copy_kstring_from_user(params.old_path));
|
||||||
if (old_path_or_error.is_error())
|
auto new_path = TRY(try_copy_kstring_from_user(params.new_path));
|
||||||
return old_path_or_error.error();
|
return VirtualFileSystem::the().link(old_path->view(), new_path->view(), current_directory());
|
||||||
auto new_path_or_error = try_copy_kstring_from_user(params.new_path);
|
|
||||||
if (new_path_or_error.is_error())
|
|
||||||
return new_path_or_error.error();
|
|
||||||
return VirtualFileSystem::the().link(old_path_or_error.value()->view(), new_path_or_error.value()->view(), current_directory());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KResultOr<FlatPtr> Process::sys$symlink(Userspace<const Syscall::SC_symlink_params*> user_params)
|
KResultOr<FlatPtr> Process::sys$symlink(Userspace<const Syscall::SC_symlink_params*> user_params)
|
||||||
|
@ -33,13 +29,9 @@ KResultOr<FlatPtr> Process::sys$symlink(Userspace<const Syscall::SC_symlink_para
|
||||||
Syscall::SC_symlink_params params;
|
Syscall::SC_symlink_params params;
|
||||||
if (!copy_from_user(¶ms, user_params))
|
if (!copy_from_user(¶ms, user_params))
|
||||||
return EFAULT;
|
return EFAULT;
|
||||||
auto target = get_syscall_path_argument(params.target);
|
auto target = TRY(get_syscall_path_argument(params.target));
|
||||||
if (target.is_error())
|
auto linkpath = TRY(get_syscall_path_argument(params.linkpath));
|
||||||
return target.error();
|
return VirtualFileSystem::the().symlink(target->view(), linkpath->view(), current_directory());
|
||||||
auto linkpath = get_syscall_path_argument(params.linkpath);
|
|
||||||
if (linkpath.is_error())
|
|
||||||
return linkpath.error();
|
|
||||||
return VirtualFileSystem::the().symlink(target.value()->view(), linkpath.value()->view(), current_directory());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue