diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-05 18:34:28 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-05 18:36:13 +0200 |
commit | a9204510a4c0c37588a38201f305d7e9b4e762a9 (patch) | |
tree | 752b1077191f2608755104f6cca2a19bc9f4591c /Kernel/Syscalls/chdir.cpp | |
parent | 2d2ea05c97e97848f431b5c9e5f709fe276eb7c8 (diff) | |
download | serenity-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.cpp | 7 |
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; } |