forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
faccessat.cpp
33 lines (26 loc) 路 1014 Bytes
/
faccessat.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Copyright (c) 2018-2020, Andreas Kling <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/StringView.h>
#include <Kernel/FileSystem/VirtualFileSystem.h>
#include <Kernel/Tasks/Process.h>
namespace Kernel {
ErrorOr<FlatPtr> Process::sys$faccessat(Userspace<Syscall::SC_faccessat_params const*> user_params)
{
VERIFY_NO_PROCESS_BIG_LOCK(this);
TRY(require_promise(Pledge::rpath));
auto params = TRY(copy_typed_from_user(user_params));
auto pathname = TRY(get_syscall_path_argument(params.pathname));
if ((params.flags & ~(AT_SYMLINK_ | AT_EACCESS)) != 0)
return EINVAL;
auto flags = AccessFlags::None;
if (params.flags & AT_SYMLINK_)
flags |= AccessFlags::DoNotFollowSymlinks;
if (params.flags & AT_EACCESS)
flags |= AccessFlags::EffectiveAccess;
TRY(VirtualFileSystem::the().access(credentials(), pathname->view(), params.mode, TRY(custody_for_dirfd(params.dirfd)), flags));
return 0;
}
}