2020-07-30 17:38:15 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 04:24:48 -04:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-30 17:38:15 -04:00
|
|
|
*/
|
|
|
|
|
2023-02-24 12:45:37 -05:00
|
|
|
#include <Kernel/Tasks/Process.h>
|
2020-07-30 17:38:15 -04:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2021-11-07 18:51:39 -05:00
|
|
|
ErrorOr<FlatPtr> Process::sys$umask(mode_t mask)
|
2020-07-30 17:38:15 -04:00
|
|
|
{
|
2023-04-03 10:37:34 -04:00
|
|
|
VERIFY_NO_PROCESS_BIG_LOCK(this);
|
2021-12-29 04:11:45 -05:00
|
|
|
TRY(require_promise(Pledge::stdio));
|
2022-08-21 06:18:26 -04:00
|
|
|
return with_mutable_protected_data([&](auto& protected_data) -> ErrorOr<FlatPtr> {
|
|
|
|
auto old_mask = protected_data.umask;
|
|
|
|
protected_data.umask = mask & 0777;
|
|
|
|
return old_mask;
|
|
|
|
});
|
2020-07-30 17:38:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|