mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +00:00
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.
This commit is contained in:
parent
2d2ea05c97
commit
a9204510a4
24 changed files with 62 additions and 155 deletions
|
@ -48,9 +48,7 @@ KResultOr<FlatPtr> Process::sys$inode_watcher_add_watch(Userspace<const Syscall:
|
|||
REQUIRE_PROMISE(rpath);
|
||||
auto params = TRY(copy_typed_from_user(user_params));
|
||||
|
||||
auto description = fds().file_description(params.fd);
|
||||
if (!description)
|
||||
return EBADF;
|
||||
auto description = TRY(fds().file_description(params.fd));
|
||||
if (!description->is_inode_watcher())
|
||||
return EBADF;
|
||||
auto inode_watcher = description->inode_watcher();
|
||||
|
@ -76,9 +74,7 @@ KResultOr<FlatPtr> Process::sys$inode_watcher_add_watch(Userspace<const Syscall:
|
|||
KResultOr<FlatPtr> Process::sys$inode_watcher_remove_watch(int fd, int wd)
|
||||
{
|
||||
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
||||
auto description = fds().file_description(fd);
|
||||
if (!description)
|
||||
return EBADF;
|
||||
auto description = TRY(fds().file_description(fd));
|
||||
if (!description->is_inode_watcher())
|
||||
return EBADF;
|
||||
auto inode_watcher = description->inode_watcher();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue