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-06-28 20:59:35 +02:00
|
|
|
KResultOr<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-10-11 21:47:21 +08:00
|
|
|
int non_blocking;
|
|
|
|
|
TRY(copy_from_user(&non_blocking, Userspace<const int*>(arg)));
|
|
|
|
|
description->set_blocking(non_blocking == 0);
|
2021-03-28 17:50:08 +02:00
|
|
|
return KSuccess;
|
|
|
|
|
}
|
2020-07-30 23:38:15 +02:00
|
|
|
return description->file().ioctl(*description, request, arg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|