Compare commits

..

2 Commits

3 changed files with 28 additions and 4 deletions

View File

@ -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
View 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"); }
}

View File

@ -33,8 +33,6 @@
#include "thread/PIT.h"
#include "thread/Scheduler.h"
extern "C" void _userspace();
extern "C" void _start()
{
Init::check_magic();
@ -125,7 +123,7 @@ extern "C" void _start()
}
});
uint64_t demo = Mersenne::get() % 5;
uint64_t demo = Mersenne::get() % 6;
switch (demo)
{
@ -149,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;
}