/* * 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 #include namespace Kernel { class ProcessList; AK_TYPEDEF_DISTINCT_ORDERED_ID(u64, JailIndex); class Jail : public AtomicRefCounted { public: RefPtr process_list(); static RefPtr find_by_index(JailIndex); static ErrorOr> create(NonnullOwnPtr name, unsigned flags); 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, RefPtr); NonnullOwnPtr m_name; JailIndex const m_index; IntrusiveListNode> m_list_node; public: using List = IntrusiveListRelaxedConst<&Jail::m_list_node>; private: RefPtr const m_process_list; SpinlockProtected m_attach_count { 0 }; }; }