From f76d921e25da3eb28c348afd8d59fc439165b27b Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 23 Jul 2023 18:52:55 +0300 Subject: [PATCH] Kernel: you can now ask process if it is userspace process --- kernel/include/kernel/Process.h | 2 ++ kernel/kernel/Process.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/kernel/include/kernel/Process.h b/kernel/include/kernel/Process.h index d4e46ae0b4..395e60cd5d 100644 --- a/kernel/include/kernel/Process.h +++ b/kernel/include/kernel/Process.h @@ -114,6 +114,7 @@ namespace Kernel PageTable& page_table() { return m_page_table ? *m_page_table : PageTable::kernel(); } + bool is_userspace() const { return m_is_userspace; } const userspace_info_t& userspace_info() const { return m_userspace_info; } private: @@ -157,6 +158,7 @@ namespace Kernel vaddr_t m_signal_handlers[_SIGMAX + 1] { }; + bool m_is_userspace { false }; userspace_info_t m_userspace_info; ExitStatus m_exit_status; diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index 494b9e3b36..319b2d00d1 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -58,6 +58,7 @@ namespace Kernel process->load_elf_to_memory(*elf); + process->m_is_userspace = true; process->m_userspace_info.entry = elf->file_header_native().e_entry; // NOTE: we clear the elf since we don't need the memory anymore @@ -305,6 +306,7 @@ namespace Kernel forked->m_mapped_ranges = BAN::move(mapped_ranges); forked->m_fixed_width_allocators = BAN::move(fixed_width_allocators); forked->m_general_allocator = BAN::move(general_allocator); + forked->m_is_userspace = m_is_userspace; forked->m_userspace_info = m_userspace_info; memcpy(forked->m_signal_handlers, m_signal_handlers, sizeof(m_signal_handlers));