apps: add a new example app which does all kinds of stdio misbehaving >.<
This commit is contained in:
parent
667d308fc3
commit
7a097f16ea
@ -1,4 +1,4 @@
|
||||
APPS := init fib leap art memeater
|
||||
APPS := init fib leap art memeater quota
|
||||
|
||||
APPS_DIR := $(LUNA_ROOT)/apps
|
||||
APPS_SRC := $(APPS_DIR)/src
|
||||
|
22
apps/src/quota.c
Normal file
22
apps/src/quota.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
if (open("/file/that/does/not/exist", O_RDONLY) < 0) { perror("open"); }
|
||||
int sys = open("/sys", O_RDONLY);
|
||||
if (sys < 0) { perror("open"); }
|
||||
if (read(sys, NULL, 20) < 0) { perror("read"); }
|
||||
char buf[20];
|
||||
if (read(sys, buf, 20) < 0) { perror("read"); }
|
||||
if (close(sys) < 0) { perror("close"); }
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
if (open("/", O_RDONLY) < 0) { perror("open"); }
|
||||
}
|
||||
int exec;
|
||||
if ((exec = open("/bin/quota", O_RDONLY)) < 0) { perror("open"); }
|
||||
if (read(exec, buf, 20) < 0) { perror("read"); }
|
||||
if (close(exec) < 0) { perror("close"); }
|
||||
}
|
@ -123,7 +123,7 @@ extern "C" void _start()
|
||||
}
|
||||
});
|
||||
|
||||
uint64_t demo = Mersenne::get() % 5;
|
||||
uint64_t demo = Mersenne::get() % 6;
|
||||
|
||||
switch (demo)
|
||||
{
|
||||
@ -147,6 +147,10 @@ extern "C" void _start()
|
||||
kinfoln("Loading demo: memory eating program");
|
||||
Scheduler::load_user_task("bin/memeater");
|
||||
break;
|
||||
case 5:
|
||||
kinfoln("Loading demo: misbehaving program");
|
||||
Scheduler::load_user_task("bin/quota");
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user