apps: Remove demo programs (except for init)

We no longer need those, and they just make the initrd larger.
This commit is contained in:
apio 2022-10-11 21:37:27 +02:00
parent 25ab31c7ce
commit e145690db8
6 changed files with 1 additions and 134 deletions

View File

@ -1,4 +1,4 @@
APPS := init fib leap art memeater quota
APPS := init
APPS_DIR := $(LUNA_ROOT)/apps
APPS_SRC := $(APPS_DIR)/src

View File

@ -1,18 +0,0 @@
#include <stdio.h>
#include <sys/syscall.h>
#include <unistd.h>
int main()
{
sleep(1);
syscall(SYS_paint, 0, 0, 400, 300, 0x000000FF);
sleep(1);
printf("Hello, colorful world!\n");
sleep(1);
printf("Press any key to restart.");
}

View File

@ -1,34 +0,0 @@
#include <luna.h>
#include <stdio.h>
#include <unistd.h>
void fib_next(unsigned long int* a, unsigned long int* b)
{
unsigned long int _a = *a;
unsigned long int _b = *b;
*a = *b;
*b = _a + _b;
}
int main()
{
unsigned long int fib_a = 1;
unsigned long int fib_b = 1;
printf("Calculating the 50 first Fibonacci numbers...\n");
sleep(2);
printf("%lu\n", fib_a);
msleep(500);
for (int i = 0; i < 49; i++)
{
printf("%lu\n", fib_b);
fib_next(&fib_a, &fib_b);
msleep(500);
}
printf("\nDone, press any key to restart.\n");
}

View File

@ -1,38 +0,0 @@
#include <luna.h>
#include <stdio.h>
#include <sys/syscall.h>
#include <unistd.h>
unsigned long random_year() // Return a year from 1000 to 2500.
{
unsigned long result = syscall(SYS_rand);
return (result % 1500) + 1000;
}
int is_leap(unsigned long year)
{
return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}
int main()
{
printf("Welcome to the Luna Leap Year Program!\n\n");
sleep(1);
printf("Choosing a random year between 1000 and 2500... ");
msleep(500);
unsigned long year = random_year();
printf("%lu!\n\n", year);
sleep(1);
printf("%lu is %s\n", year, is_leap(year) ? "a leap year!" : "not a leap year :(");
msleep(500);
printf("Press any key to restart.\n");
}

View File

@ -1,21 +0,0 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define CHUNK 4194304 // 4 MB
int main()
{
printf("Welcome to memeater! This little program is designed to eat up all the memory on your system.\n");
sleep(1);
void* allocated = malloc(CHUNK);
do {
printf("Allocating 4 MB of memory... %p\n", allocated);
sleep(1);
} while ((allocated = malloc(CHUNK)));
printf("Memory allocation failed: %m\n");
printf("Press any key to restart.\n");
return 1;
}

View File

@ -1,22 +0,0 @@
#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"); }
}