access.cpp 638 B

1234567891011121314151617181920212223
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/StringView.h>
  7. #include <Kernel/FileSystem/VirtualFileSystem.h>
  8. #include <Kernel/Process.h>
  9. namespace Kernel {
  10. KResultOr<FlatPtr> Process::sys$access(Userspace<const char*> user_path, size_t path_length, int mode)
  11. {
  12. VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
  13. REQUIRE_PROMISE(rpath);
  14. auto path = get_syscall_path_argument(user_path, path_length);
  15. if (path.is_error())
  16. return path.error();
  17. return VirtualFileSystem::the().access(path.value()->view(), mode, current_directory());
  18. }
  19. }