syscalls: implement sysctl and add process listing

This commit is contained in:
Matheus
2026-06-09 17:47:27 -03:00
parent 770a300618
commit 659b29ef4e
18 changed files with 428 additions and 8 deletions
+8
View File
@@ -13,6 +13,8 @@
#include <kernel/thread.h>
#include <kernel/sysctl.h>
#ifdef __x86_64__
#include <arch/ldt.h>
#endif
@@ -90,6 +92,11 @@ typedef struct proc_t {
itimer_t virtualtime;
itimer_t profiling;
} timer;
char name[SYS_CTL_KERN_PROC_INFO_NAME_SIZE];
timespec_t start_time;
spinlock_t runtime_lock;
timespec_t total_runtime;
} proc_t;
@@ -125,5 +132,6 @@ void proc_init(void);
void proc_exit(void);
void proc_run_init();
size_t proc_get_count(void);
size_t proc_get_table(proc_t **procs, size_t count);
#endif
+42
View File
@@ -0,0 +1,42 @@
#ifndef _SYSCTL_H
#define _SYSCTL_H
#include <kernel/abi.h>
#include <time.h>
#define SYS_CTL_NAME_MAX 6
#define SYS_CTL_KERN 1
#define SYS_CTL_KERN_PROC 1
#define SYS_CTL_KERN_PROC_ALL 1
#define SYS_CTL_KERN_PROC_INFO_NAME_SIZE 64
#define SYS_CTL_KERN_PROC_INFO_TTY_NAME_SIZE 64
typedef struct {
pid_t pid;
uid_t uid;
uid_t euid;
uid_t suid;
gid_t gid;
gid_t egid;
gid_t sgid;
size_t thread_count;
char name[SYS_CTL_KERN_PROC_INFO_NAME_SIZE];
pid_t ppid;
pid_t pgid;
pid_t sid;
timespec_t start_timestamp;
timespec_t total_runtime;
int state;
int cpu_time;
int nice;
size_t virtual_pages;
size_t physical_pages;
char tty_name[SYS_CTL_KERN_PROC_INFO_TTY_NAME_SIZE];
} sysctl_proc_info_t;
int sysctl(const int *name, size_t name_len, void *oldp, size_t *old_lenp, void *newp, size_t new_len);
int sysctl_kern(const int *name, size_t name_len, void *oldp, size_t *old_lenp, void *newp, size_t new_len);
#endif
+1
View File
@@ -44,5 +44,6 @@ void tty_process(tty_t *tty, char c);
void tty_unregister(tty_t *tty);
int tty_ioctl(tty_t *tty, unsigned long req, void *arg, int *result, cred_t *cred);
size_t tty_opened(tty_t *tty);
void tty_release(tty_t *tty);
#endif