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
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Kernel/FileSystem/FileDescription.h>
|
|
|
|
#include <Kernel/Process.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2021-03-01 13:49:16 +01:00
|
|
|
KResultOr<int> Process::sys$fchown(int fd, uid_t uid, gid_t gid)
|
2020-07-30 23:38:15 +02:00
|
|
|
{
|
|
|
|
REQUIRE_PROMISE(chown);
|
|
|
|
auto description = file_description(fd);
|
|
|
|
if (!description)
|
2021-03-01 13:49:16 +01:00
|
|
|
return EBADF;
|
2020-07-30 23:38:15 +02:00
|
|
|
return description->chown(uid, gid);
|
|
|
|
}
|
|
|
|
|
2021-03-01 13:49:16 +01:00
|
|
|
KResultOr<int> Process::sys$chown(Userspace<const Syscall::SC_chown_params*> user_params)
|
2020-07-30 23:38:15 +02:00
|
|
|
{
|
|
|
|
REQUIRE_PROMISE(chown);
|
|
|
|
Syscall::SC_chown_params params;
|
2020-09-11 21:11:07 -06:00
|
|
|
if (!copy_from_user(¶ms, user_params))
|
2021-03-01 13:49:16 +01:00
|
|
|
return EFAULT;
|
2020-07-30 23:38:15 +02:00
|
|
|
auto path = get_syscall_path_argument(params.path);
|
|
|
|
if (path.is_error())
|
|
|
|
return path.error();
|
|
|
|
return VFS::the().chown(path.value(), params.uid, params.gid, current_directory());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|