summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/chdir.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-05 18:34:28 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-05 18:36:13 +0200
commita9204510a4c0c37588a38201f305d7e9b4e762a9 (patch)
tree752b1077191f2608755104f6cca2a19bc9f4591c /Kernel/Syscalls/chdir.cpp
parent2d2ea05c97e97848f431b5c9e5f709fe276eb7c8 (diff)
downloadserenity-a9204510a4c0c37588a38201f305d7e9b4e762a9.zip
Kernel: Make file description lookup return KResultOr
Instead of checking it at every call site (to generate EBADF), we make file_description(fd) return a KResultOr<NonnullRefPtr<FileDescription>>. This allows us to wrap all the calls in TRY(). :^) The only place that got a little bit messier from this is sys$mount(), and there's a whole bunch of things there in need of cleanup.
Diffstat (limited to 'Kernel/Syscalls/chdir.cpp')
-rw-r--r--Kernel/Syscalls/chdir.cpp7
1 files changed, 1 insertions, 6 deletions
diff --git a/Kernel/Syscalls/chdir.cpp b/Kernel/Syscalls/chdir.cpp
index 5b5da7acfc..7b200e9f25 100644
--- a/Kernel/Syscalls/chdir.cpp
+++ b/Kernel/Syscalls/chdir.cpp
@@ -23,16 +23,11 @@ KResultOr<FlatPtr> Process::sys$fchdir(int fd)
{
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this);
REQUIRE_PROMISE(stdio);
- auto description = fds().file_description(fd);
- if (!description)
- return EBADF;
-
+ auto description = TRY(fds().file_description(fd));
if (!description->is_directory())
return ENOTDIR;
-
if (!description->metadata().may_execute(*this))
return EACCES;
-
m_cwd = description->custody();
return 0;
}