Kernel: Expose command line and environment to /proc

This commit is contained in:
Bananymous
2023-09-30 23:01:33 +03:00
parent 5ee3506474
commit 39bc6c43dc
4 changed files with 94 additions and 40 deletions

View File

@@ -20,11 +20,11 @@ namespace Kernel
Process& m_process;
};
class ProcMemInode final : public RamInode
class ProcROInode final : public RamInode
{
public:
static BAN::ErrorOr<BAN::RefPtr<ProcMemInode>> create(Process&, RamFileSystem&, mode_t, uid_t, gid_t);
~ProcMemInode() = default;
static BAN::ErrorOr<BAN::RefPtr<ProcROInode>> create(Process&, size_t (Process::*callback)(off_t, void*, size_t) const, RamFileSystem&, mode_t, uid_t, gid_t);
~ProcROInode() = default;
protected:
virtual BAN::ErrorOr<size_t> read_impl(off_t, void*, size_t) override;
@@ -35,10 +35,11 @@ namespace Kernel
virtual bool has_data_impl() const override { return true; }
private:
ProcMemInode(Process&, RamFileSystem&, const FullInodeInfo&);
ProcROInode(Process&, size_t (Process::*)(off_t, void*, size_t) const, RamFileSystem&, const FullInodeInfo&);
private:
Process& m_process;
size_t (Process::*m_callback)(off_t, void*, size_t) const;
};
}

View File

@@ -139,7 +139,9 @@ namespace Kernel
PageTable& page_table() { return m_page_table ? *m_page_table : PageTable::kernel(); }
void get_meminfo(proc_meminfo_t*) const;
size_t proc_meminfo(off_t offset, void* buffer, size_t buffer_size) const;
size_t proc_cmdline(off_t offset, void* buffer, size_t buffer_size) const;
size_t proc_environ(off_t offset, void* buffer, size_t buffer_size) const;
bool is_userspace() const { return m_is_userspace; }
const userspace_info_t& userspace_info() const { return m_userspace_info; }
@@ -192,6 +194,9 @@ namespace Kernel
vaddr_t m_signal_handlers[_SIGMAX + 1] { };
uint64_t m_signal_pending_mask { 0 };
BAN::Vector<BAN::String> m_cmdline;
BAN::Vector<BAN::String> m_environ;
bool m_is_userspace { false };
userspace_info_t m_userspace_info;
ExitStatus m_exit_status;