2020-07-30 23:38:15 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-30 23:38:15 +02:00
|
|
|
*/
|
|
|
|
|
2021-10-11 21:47:21 +08:00
|
|
|
#include <AK/Userspace.h>
|
2021-09-07 13:39:11 +02:00
|
|
|
#include <Kernel/FileSystem/OpenFileDescription.h>
|
2020-07-30 23:38:15 +02:00
|
|
|
#include <Kernel/Process.h>
|
2021-03-28 17:50:08 +02:00
|
|
|
#include <LibC/sys/ioctl_numbers.h>
|
2020-07-30 23:38:15 +02:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2021-11-08 00:51:39 +01:00
|
|
|
ErrorOr<FlatPtr> Process::sys$ioctl(int fd, unsigned request, FlatPtr arg)
|
2020-07-30 23:38:15 +02:00
|
|
|
{
|
2021-07-18 11:20:12 -07:00
|
|
|
VERIFY_PROCESS_BIG_LOCK_ACQUIRED(this)
|
2021-09-07 13:41:27 +02:00
|
|
|
auto description = TRY(fds().open_file_description(fd));
|
2021-03-29 08:57:11 +02:00
|
|
|
if (request == FIONBIO) {
|
2021-12-17 09:12:20 +01:00
|
|
|
description->set_blocking(TRY(copy_typed_from_user(Userspace<int const*>(arg))) == 0);
|
2021-11-08 00:51:39 +01:00
|
|
|
return 0;
|
2021-03-28 17:50:08 +02:00
|
|
|
}
|
2021-11-08 00:51:39 +01:00
|
|
|
TRY(description->file().ioctl(*description, request, arg));
|
|
|
|
return 0;
|
2020-07-30 23:38:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|