31 lines
734 B
C
31 lines
734 B
C
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <system/system.h>
|
|
#include <sysdefs/processctl.h>
|
|
#include <uprintf.h>
|
|
#include <args/args.h>
|
|
#include <string/string.h>
|
|
#include <util/util.h>
|
|
#include <errors.h>
|
|
|
|
void main(void) {
|
|
if (argslen() == 0) {
|
|
return;
|
|
}
|
|
|
|
char *cmd = args()[0];
|
|
|
|
if (string_strcmp(cmd, "ls") == 0) {
|
|
uint64_t procslen = processctl(-1, PCTL_PLS_SZ, 0, 0, 0);
|
|
for (size_t i = 0; i < procslen; i++) {
|
|
ProcStat stat = ZERO(&stat);
|
|
int32_t r = processctl(-1, PCTL_PLS_STAT, i, (uint64_t)&stat, 0);
|
|
if (r == E_OK) {
|
|
uprintf("%-30s %lu %-6s\n", stat.name, stat.pid, stat.kern ? "KERNEL" : "USER");
|
|
}
|
|
}
|
|
} else {
|
|
uprintf("pctl: unknown command\n");
|
|
}
|
|
}
|