mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
Kernel: Modify the IOCTL API to return KResult
The kernel has been gradually moving towards KResult from just bare int's, this change migrates the IOCTL paths.
This commit is contained in:
parent
46c9b1d81c
commit
de9ff0af50
Notes:
sideshowbarker
2024-07-18 08:17:39 +09:00
Author: https://github.com/bgianfo
Commit: de9ff0af50
Pull-request: https://github.com/SerenityOS/serenity/pull/9019
Reviewed-by: https://github.com/alimpfard ✅
16 changed files with 151 additions and 151 deletions
|
@ -62,34 +62,34 @@ KResultOr<size_t> InodeFile::write(FileDescription& description, u64 offset, con
|
|||
return nwritten;
|
||||
}
|
||||
|
||||
int InodeFile::ioctl(FileDescription& description, unsigned request, Userspace<void*> arg)
|
||||
KResult InodeFile::ioctl(FileDescription& description, unsigned request, Userspace<void*> arg)
|
||||
{
|
||||
(void)description;
|
||||
|
||||
switch (request) {
|
||||
case FIBMAP: {
|
||||
if (!Process::current()->is_superuser())
|
||||
return -EPERM;
|
||||
return EPERM;
|
||||
|
||||
auto user_block_number = static_ptr_cast<int*>(arg);
|
||||
int block_number = 0;
|
||||
if (!copy_from_user(&block_number, user_block_number))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
|
||||
if (block_number < 0)
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
|
||||
auto block_address = inode().get_block_address(block_number);
|
||||
if (block_address.is_error())
|
||||
return block_address.error();
|
||||
|
||||
if (!copy_to_user(user_block_number, &block_address.value()))
|
||||
return -EFAULT;
|
||||
return EFAULT;
|
||||
|
||||
return 0;
|
||||
return KSuccess;
|
||||
}
|
||||
default:
|
||||
return -EINVAL;
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue