From 8f630a97df3954e3369980b3d332dc557652e317 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sat, 30 Sep 2023 21:19:36 +0300 Subject: [PATCH] Kernel: Add procfs that contains only pids --- base-sysroot.tar.gz | Bin 8056 -> 8137 bytes kernel/CMakeLists.txt | 2 + kernel/include/kernel/FS/ProcFS/FileSystem.h | 26 +++++++++++ kernel/include/kernel/FS/ProcFS/Inode.h | 23 ++++++++++ kernel/kernel/FS/ProcFS/FileSystem.cpp | 46 +++++++++++++++++++ kernel/kernel/FS/ProcFS/Inode.cpp | 26 +++++++++++ kernel/kernel/FS/VirtualFileSystem.cpp | 3 ++ kernel/kernel/Process.cpp | 5 ++ kernel/kernel/kernel.cpp | 4 ++ 9 files changed, 135 insertions(+) create mode 100644 kernel/include/kernel/FS/ProcFS/FileSystem.h create mode 100644 kernel/include/kernel/FS/ProcFS/Inode.h create mode 100644 kernel/kernel/FS/ProcFS/FileSystem.cpp create mode 100644 kernel/kernel/FS/ProcFS/Inode.cpp diff --git a/base-sysroot.tar.gz b/base-sysroot.tar.gz index 04e3de73825707493edc18c253d47775f8630a2d..a818f495d6cdba2d86cad519d4d32582cfd5cfe9 100644 GIT binary patch literal 8137 zcma)9`8yO2(8uNu^rCN|PtmYT7L*6IFS%)$*o{Se$nWmc5-pdJ zuc``jpAs&Mh(eYh6g-qUl9*Z=wXl#08YDI%9I8#efx+H8ExyAQ+`)$OhScCiTk z-WCqG?QmOz->GJvvRD2UYfM#BhMlMSaJ{s==v%NFbpPu%JbEJax61A8=jT9{^mMLc zuB8DIixd4g{R!2aJ@*KinLP4VpgvZ#7W+IFT(va7GFGgZ968oS%1kP!v!M+wqIXk* zB{WC@_|B$|kiVSyTGlj?9P764-@N^H_FyvVZIvD0I(FZl)OGZ>Dxo{0(&xHU)5Y73 zi(Y4U><>@>{%)-_G_q7{IN}g3_{|aRsJ60wNhxFU(SFYN6Biqwjjx`BKQ`kp8ooV! z64$$qLXFlqnX-<|qdMourkgvv>N}028}BQ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q8f`GQl{PpV+d+3BGnm z`~7llu)nr9oi>=Sokc6NlW2ouX|P?}@NAWbw6hIy0q>vZ4&wbYVbUA%(i`#9^WtaW zC_ii8N^LM@hZd8g&2Nnxie4GMI+$sLX$NE)&)I{z|F$p6WR%ovk?H?gD-AZfnlL*fiQ;Um6UXT@Rx~OLg({Ik4mZAbL5B zfzi<|t`1Zuz+;HVcc^!V^)r}frWMrwyhjt!oDX*9P~8{fUD6eEx51gM$ifaGq6&;5R&_Hga6-(RcTIkh%;JY!z~c6HYcukHU_+yA+?|MUO${?8kF*XK6haO8dg zjAlQF`ul%N7t`;*EegA9zyCEO&iusoOXv6hmM_-7|5y9{$C|6Tnya}Z>iz|D$Ti9U Gpa1|B(sthf diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index e7e16fb537..6d1d9dc768 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -24,6 +24,8 @@ set(KERNEL_SOURCES kernel/FS/Ext2/Inode.cpp kernel/FS/Inode.cpp kernel/FS/Pipe.cpp + kernel/FS/ProcFS/FileSystem.cpp + kernel/FS/ProcFS/Inode.cpp kernel/FS/RamFS/FileSystem.cpp kernel/FS/RamFS/Inode.cpp kernel/FS/VirtualFileSystem.cpp diff --git a/kernel/include/kernel/FS/ProcFS/FileSystem.h b/kernel/include/kernel/FS/ProcFS/FileSystem.h new file mode 100644 index 0000000000..becef480ef --- /dev/null +++ b/kernel/include/kernel/FS/ProcFS/FileSystem.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include +#include + +namespace Kernel +{ + + class ProcFileSystem final : public RamFileSystem + { + public: + static void initialize(); + static ProcFileSystem& get(); + + BAN::ErrorOr on_process_create(Process&); + void on_process_delete(Process&); + + private: + ProcFileSystem(size_t size); + + private: + BAN::RefPtr m_root_inode; + }; + +} \ No newline at end of file diff --git a/kernel/include/kernel/FS/ProcFS/Inode.h b/kernel/include/kernel/FS/ProcFS/Inode.h new file mode 100644 index 0000000000..87226ba956 --- /dev/null +++ b/kernel/include/kernel/FS/ProcFS/Inode.h @@ -0,0 +1,23 @@ +#pragma once + +#include +#include +#include + +namespace Kernel +{ + + class ProcPidInode final : public RamDirectoryInode + { + public: + static BAN::ErrorOr> create(Process&, RamFileSystem&, mode_t, uid_t, gid_t); + ~ProcPidInode() = default; + + private: + ProcPidInode(Process&, RamFileSystem&, const FullInodeInfo&); + + private: + Process& m_process; + }; + +} diff --git a/kernel/kernel/FS/ProcFS/FileSystem.cpp b/kernel/kernel/FS/ProcFS/FileSystem.cpp new file mode 100644 index 0000000000..1c8078573c --- /dev/null +++ b/kernel/kernel/FS/ProcFS/FileSystem.cpp @@ -0,0 +1,46 @@ +#include +#include +#include +#include + +namespace Kernel +{ + + static ProcFileSystem* s_instance = nullptr; + + void ProcFileSystem::initialize() + { + ASSERT(s_instance == nullptr); + s_instance = new ProcFileSystem(1024 * 1024); + ASSERT(s_instance); + + s_instance->m_root_inode = MUST(RamDirectoryInode::create(*s_instance, 0, 0555, 0, 0)); + MUST(s_instance->set_root_inode(s_instance->m_root_inode)); + } + + ProcFileSystem& ProcFileSystem::get() + { + ASSERT(s_instance); + return *s_instance; + } + + ProcFileSystem::ProcFileSystem(size_t size) + : RamFileSystem(size) + { + } + + BAN::ErrorOr ProcFileSystem::on_process_create(Process& process) + { + auto path = BAN::String::formatted("{}", process.pid()); + auto inode = TRY(ProcPidInode::create(process, *this, 0555, 0, 0)); + TRY(m_root_inode->add_inode(path, inode)); + return {}; + } + + void ProcFileSystem::on_process_delete(Process& process) + { + auto path = BAN::String::formatted("{}", process.pid()); + MUST(m_root_inode->delete_inode(path)); + } + +} diff --git a/kernel/kernel/FS/ProcFS/Inode.cpp b/kernel/kernel/FS/ProcFS/Inode.cpp new file mode 100644 index 0000000000..6fccc23b69 --- /dev/null +++ b/kernel/kernel/FS/ProcFS/Inode.cpp @@ -0,0 +1,26 @@ +#include + +namespace Kernel +{ + + BAN::ErrorOr> ProcPidInode::create(Process& process, RamFileSystem& fs, mode_t mode, uid_t uid, gid_t gid) + { + FullInodeInfo inode_info(fs, mode, uid, gid); + + auto* inode_ptr = new ProcPidInode(process, fs, inode_info); + if (inode_ptr == nullptr) + return BAN::Error::from_errno(ENOMEM); + auto inode = BAN::RefPtr::adopt(inode_ptr); + + TRY(inode->add_inode("meminfo"sv, MUST(ProcMemInode::create(process, fs, 0755, 0, 0)))); + + return inode; + } + + ProcPidInode::ProcPidInode(Process& process, RamFileSystem& fs, const FullInodeInfo& inode_info) + : RamDirectoryInode(fs, inode_info, fs.root_inode()->ino()) + , m_process(process) + { + } + +} diff --git a/kernel/kernel/FS/VirtualFileSystem.cpp b/kernel/kernel/FS/VirtualFileSystem.cpp index de82f939be..a023afd548 100644 --- a/kernel/kernel/FS/VirtualFileSystem.cpp +++ b/kernel/kernel/FS/VirtualFileSystem.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,8 @@ namespace Kernel Credentials root_creds { 0, 0, 0, 0 }; MUST(s_instance->mount(root_creds, &DevFileSystem::get(), "/dev"sv)); + MUST(s_instance->mount(root_creds, &ProcFileSystem::get(), "/proc"sv)); + auto* tmpfs = MUST(RamFileSystem::create(1024 * 1024, 0777, 0, 0)); MUST(s_instance->mount(root_creds, tmpfs, "/tmp"sv)); } diff --git a/kernel/kernel/Process.cpp b/kernel/kernel/Process.cpp index 507f5fed98..1ca4b21365 100644 --- a/kernel/kernel/Process.cpp +++ b/kernel/kernel/Process.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -81,6 +82,8 @@ namespace Kernel auto* process = new Process(credentials, pid, parent, sid, pgrp); ASSERT(process); + MUST(ProcFileSystem::get().on_process_create(*process)); + return process; } @@ -194,6 +197,8 @@ namespace Kernel s_processes.remove(i); s_process_lock.unlock(); + ProcFileSystem::get().on_process_delete(*this); + m_lock.lock(); m_exit_status.exited = true; while (m_exit_status.waiting > 0) diff --git a/kernel/kernel/kernel.cpp b/kernel/kernel/kernel.cpp index 633d0ecc50..b9a259ce7b 100644 --- a/kernel/kernel/kernel.cpp +++ b/kernel/kernel/kernel.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -131,6 +132,9 @@ extern "C" void kernel_main() DevFileSystem::initialize(); dprintln("devfs initialized"); + ProcFileSystem::initialize(); + dprintln("procfs initialized"); + if (Serial::has_devices()) { Serial::initialize_devices();