blob: faeed507f1cc485ad3dd02a1f73cdd6114963908 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/*
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Jail.h>
namespace Kernel {
ErrorOr<NonnullLockRefPtr<Jail>> Jail::create(Badge<JailManagement>, NonnullOwnPtr<KString> name, JailIndex index)
{
return adopt_nonnull_lock_ref_or_enomem(new (nothrow) Jail(move(name), index));
}
Jail::Jail(NonnullOwnPtr<KString> name, JailIndex index)
: m_name(move(name))
, m_index(index)
{
}
void Jail::detach(Badge<Process>)
{
VERIFY(ref_count() > 0);
m_attach_count.with([&](auto& my_attach_count) {
VERIFY(my_attach_count > 0);
my_attach_count--;
if (my_attach_count == 0) {
m_jail_list_node.remove();
}
});
}
}
|