From e145690db8dbfcf84b948841b4bb244be9eb7468 Mon Sep 17 00:00:00 2001 From: apio Date: Tue, 11 Oct 2022 21:37:27 +0200 Subject: [PATCH] apps: Remove demo programs (except for init) We no longer need those, and they just make the initrd larger. --- apps/Makefile | 2 +- apps/src/art.c | 18 ------------------ apps/src/fib.c | 34 ---------------------------------- apps/src/leap.c | 38 -------------------------------------- apps/src/memeater.c | 21 --------------------- apps/src/quota.c | 22 ---------------------- 6 files changed, 1 insertion(+), 134 deletions(-) delete mode 100644 apps/src/art.c delete mode 100644 apps/src/fib.c delete mode 100644 apps/src/leap.c delete mode 100644 apps/src/memeater.c delete mode 100644 apps/src/quota.c diff --git a/apps/Makefile b/apps/Makefile index cf06f37e..c27455de 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -1,4 +1,4 @@ -APPS := init fib leap art memeater quota +APPS := init APPS_DIR := $(LUNA_ROOT)/apps APPS_SRC := $(APPS_DIR)/src diff --git a/apps/src/art.c b/apps/src/art.c deleted file mode 100644 index 28c47432..00000000 --- a/apps/src/art.c +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include -#include - -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."); -} \ No newline at end of file diff --git a/apps/src/fib.c b/apps/src/fib.c deleted file mode 100644 index c32fa917..00000000 --- a/apps/src/fib.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include - -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"); -} \ No newline at end of file diff --git a/apps/src/leap.c b/apps/src/leap.c deleted file mode 100644 index 9b5c986d..00000000 --- a/apps/src/leap.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include -#include - -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"); -} \ No newline at end of file diff --git a/apps/src/memeater.c b/apps/src/memeater.c deleted file mode 100644 index 761eb910..00000000 --- a/apps/src/memeater.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include -#include -#include - -#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; -} \ No newline at end of file diff --git a/apps/src/quota.c b/apps/src/quota.c deleted file mode 100644 index 670597ec..00000000 --- a/apps/src/quota.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include - -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"); } -} \ No newline at end of file