WIP
This commit is contained in:
24
user/pctl/Makefile
Normal file
24
user/pctl/Makefile
Normal file
@ -0,0 +1,24 @@
|
||||
include $(ROOT)/mk/grabsrc.mk
|
||||
include ../Makefile.inc
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
TARGET := pctl
|
||||
|
||||
LDFLAGS += -L$(ROOT)/ulib -l:libulib.a
|
||||
|
||||
SRCFILES := $(call GRABSRC, .)
|
||||
CFILES := $(call GET_CFILES, $(SRCFILES))
|
||||
OBJ := $(call GET_OBJ, $(SRCFILES))
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJ)
|
||||
$(LD) $^ $(LDFLAGS) -o $@
|
||||
echo $$(realpath $(TARGET)) >> $(FILES)
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) $(TARGET)
|
30
user/pctl/main.c
Normal file
30
user/pctl/main.c
Normal file
@ -0,0 +1,30 @@
|
||||
#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");
|
||||
}
|
||||
}
|
BIN
user/pctl/main.o
Normal file
BIN
user/pctl/main.o
Normal file
Binary file not shown.
BIN
user/pctl/pctl
Executable file
BIN
user/pctl/pctl
Executable file
Binary file not shown.
Reference in New Issue
Block a user