Kernel: /proc/{pid}/meminfo now reports per process memory usage

This commit is contained in:
Bananymous
2023-09-30 21:20:18 +03:00
parent 8f630a97df
commit 785de5f9b9
5 changed files with 80 additions and 0 deletions

View File

@@ -20,4 +20,25 @@ namespace Kernel
Process& m_process;
};
class ProcMemInode final : public RamInode
{
public:
static BAN::ErrorOr<BAN::RefPtr<ProcMemInode>> create(Process&, RamFileSystem&, mode_t, uid_t, gid_t);
~ProcMemInode() = default;
protected:
virtual BAN::ErrorOr<size_t> read_impl(off_t, void*, size_t) override;
// You may not write here and this is always non blocking
virtual BAN::ErrorOr<size_t> write_impl(off_t, const void*, size_t) override { return BAN::Error::from_errno(EINVAL); }
virtual BAN::ErrorOr<void> truncate_impl(size_t) override { return BAN::Error::from_errno(EINVAL); }
virtual bool has_data_impl() const override { return true; }
private:
ProcMemInode(Process&, RamFileSystem&, const FullInodeInfo&);
private:
Process& m_process;
};
}

View File

@@ -13,6 +13,7 @@
#include <kernel/Terminal/TTY.h>
#include <kernel/Thread.h>
#include <sys/banan-os.h>
#include <sys/mman.h>
#include <termios.h>
@@ -138,6 +139,8 @@ namespace Kernel
PageTable& page_table() { return m_page_table ? *m_page_table : PageTable::kernel(); }
void get_meminfo(proc_meminfo_t*) const;
bool is_userspace() const { return m_is_userspace; }
const userspace_info_t& userspace_info() const { return m_userspace_info; }