summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-07-26 03:47:25 -0700
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-07-27 01:23:37 +0430
commitde9ff0af507f7630c8ffd937345dcff2291b6253 (patch)
treedcf4a99a1c71ddc6d8767bc3970bfa77428f3fa7 /Kernel/FileSystem
parent46c9b1d81c22c6840733e821bc0859dda1d65e7d (diff)
downloadserenity-de9ff0af507f7630c8ffd937345dcff2291b6253.zip
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.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/File.cpp4
-rw-r--r--Kernel/FileSystem/File.h2
-rw-r--r--Kernel/FileSystem/InodeFile.cpp14
-rw-r--r--Kernel/FileSystem/InodeFile.h2
4 files changed, 11 insertions, 11 deletions
diff --git a/Kernel/FileSystem/File.cpp b/Kernel/FileSystem/File.cpp
index 29bc1fc5e9..355b6ed56d 100644
--- a/Kernel/FileSystem/File.cpp
+++ b/Kernel/FileSystem/File.cpp
@@ -35,9 +35,9 @@ KResult File::close()
return KSuccess;
}
-int File::ioctl(FileDescription&, unsigned, Userspace<void*>)
+KResult File::ioctl(FileDescription&, unsigned, Userspace<void*>)
{
- return -ENOTTY;
+ return ENOTTY;
}
KResultOr<Region*> File::mmap(Process&, FileDescription&, const Range&, u64, int, bool)
diff --git a/Kernel/FileSystem/File.h b/Kernel/FileSystem/File.h
index f51569897e..6410d1e1cb 100644
--- a/Kernel/FileSystem/File.h
+++ b/Kernel/FileSystem/File.h
@@ -87,7 +87,7 @@ public:
virtual void did_seek(FileDescription&, off_t) { }
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) = 0;
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) = 0;
- virtual int ioctl(FileDescription&, unsigned request, Userspace<void*> arg);
+ virtual KResult ioctl(FileDescription&, unsigned request, Userspace<void*> arg);
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared);
virtual KResult stat(::stat&) const { return EBADF; }
diff --git a/Kernel/FileSystem/InodeFile.cpp b/Kernel/FileSystem/InodeFile.cpp
index a0d657b88b..c7462ac42e 100644
--- a/Kernel/FileSystem/InodeFile.cpp
+++ b/Kernel/FileSystem/InodeFile.cpp
@@ -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;
}
}
diff --git a/Kernel/FileSystem/InodeFile.h b/Kernel/FileSystem/InodeFile.h
index 2fb6a38d17..5fe928a21d 100644
--- a/Kernel/FileSystem/InodeFile.h
+++ b/Kernel/FileSystem/InodeFile.h
@@ -32,7 +32,7 @@ public:
virtual KResultOr<size_t> read(FileDescription&, u64, UserOrKernelBuffer&, size_t) override;
virtual KResultOr<size_t> write(FileDescription&, u64, const UserOrKernelBuffer&, size_t) override;
- virtual int ioctl(FileDescription&, unsigned request, Userspace<void*> arg) override;
+ virtual KResult ioctl(FileDescription&, unsigned request, Userspace<void*> arg) override;
virtual KResultOr<Region*> mmap(Process&, FileDescription&, const Range&, u64 offset, int prot, bool shared) override;
virtual KResult stat(::stat& buffer) const override { return inode().metadata().stat(buffer); }