/* * Copyright (c) 2022-2023, Liav A. * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include #include #include #include namespace Kernel { class ProcessList; AK_TYPEDEF_DISTINCT_ORDERED_ID(u64, JailIndex); class Jail : public RefCounted { public: NonnullRefPtr process_list(); static LockRefPtr find_by_index(JailIndex); static ErrorOr> create(NonnullOwnPtr name); static ErrorOr for_each_when_process_is_not_jailed(Function(Jail const&)> callback); StringView name() const { return m_name->view(); } JailIndex index() const { return m_index; } void detach(Badge); SpinlockProtected& attach_count() { return m_attach_count; } private: Jail(NonnullOwnPtr, JailIndex, NonnullRefPtr); NonnullOwnPtr m_name; JailIndex const m_index; IntrusiveListNode> m_list_node; public: using List = IntrusiveListRelaxedConst<&Jail::m_list_node>; private: NonnullRefPtr m_process_list; SpinlockProtected m_attach_count { 0 }; }; }