summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xbuildkernel.sh2
-rw-r--r--progs/hello/hello.c8
-rw-r--r--progs/mkdir/mkdir.c17
-rw-r--r--progs/mount/mount.c25
-rw-r--r--progs/tty/tty.c10
-rw-r--r--sbin/fdmaker/fdmaker.c2
-rw-r--r--sbin/init/init.c1
7 files changed, 63 insertions, 2 deletions
diff --git a/buildkernel.sh b/buildkernel.sh
index f0f397e..09ceead 100755
--- a/buildkernel.sh
+++ b/buildkernel.sh
@@ -4,6 +4,6 @@ INITPATH=$PWD/init.cpio
 cd init
 find . | cpio -o -H newc > ../init.cpio
 cd ../kernel
-make isoimage FDARGS="initrd=/init.cpio" FDINITRD=$INITPATH -j 4
+make isoimage FDARGS="initrd=/init.cpio" FDINITRD=$INITPATH -j 6
 qemu-system-x86_64 -cdrom ./arch/x86/boot/image.iso #-s -S
 cd ..
\ No newline at end of file
diff --git a/progs/hello/hello.c b/progs/hello/hello.c
new file mode 100644
index 0000000..e11e06e
--- /dev/null
+++ b/progs/hello/hello.c
@@ -0,0 +1,8 @@
+#include <unistd.h>
+#include <stdlib.h>
+
+__attribute__((force_align_arg_pointer))
+int main() {
+    write(1, ":3\n", 3);
+    exit(0);
+}
\ No newline at end of file
diff --git a/progs/mkdir/mkdir.c b/progs/mkdir/mkdir.c
new file mode 100644
index 0000000..cbf5cdf
--- /dev/null
+++ b/progs/mkdir/mkdir.c
@@ -0,0 +1,17 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+int main(int argc, char *argv[]) {
+    if (!argv[1]) {
+        write(1, "you IDIOT, you forgot to include the file name, MORON\n", 55);
+        exit(1);
+    }
+    struct stat st = {0};
+
+    if (stat(argv[1], &st) == -1) {
+        mkdir(argv[1], 0700);
+    }
+    exit(0);
+}
\ No newline at end of file
diff --git a/progs/mount/mount.c b/progs/mount/mount.c
new file mode 100644
index 0000000..296dd42
--- /dev/null
+++ b/progs/mount/mount.c
@@ -0,0 +1,25 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/mount.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+int main(int argc, char *argv[]) {
+    if (argc != 4) {
+        fprintf(stderr, "usag: %s <source> <target> <filesystem type>\n", argv[0]);
+        return EXIT_FAILURE;
+    }
+
+    const char *source = argv[1];
+    const char *target = argv[2];
+    const char *fstype = argv[3];
+
+    if (mount(source, target, fstype, 0, NULL) == -1) {
+        fprintf(stderr, "mount failed: %s\n", strerror(errno));
+        return EXIT_FAILURE;
+    }
+
+    printf("Mounted %s on %s with type %s\n", source, target, fstype);
+    return EXIT_SUCCESS;
+}
\ No newline at end of file
diff --git a/progs/tty/tty.c b/progs/tty/tty.c
new file mode 100644
index 0000000..d906121
--- /dev/null
+++ b/progs/tty/tty.c
@@ -0,0 +1,10 @@
+#include <unistd.h>
+#include <stdlib.h>
+
+__attribute__((force_align_arg_pointer))
+int main() {
+    char *tty = ttyname(1);
+    write(1, tty, sizeof(tty));
+    write(1, "\n", 1);
+    exit(0);
+}
\ No newline at end of file
diff --git a/sbin/fdmaker/fdmaker.c b/sbin/fdmaker/fdmaker.c
index 6dcc299..7591147 100644
--- a/sbin/fdmaker/fdmaker.c
+++ b/sbin/fdmaker/fdmaker.c
@@ -16,7 +16,7 @@ int main() {
 
     // >open /dev/tty1
     // >look inside
-    // >bits
+    // >Failed to open /dev/tty1
     int fd = open("/dev/tty1", O_RDWR);
     if (fd == -1) {
         write(2, "Failed to open /dev/tty1\n", 26);
diff --git a/sbin/init/init.c b/sbin/init/init.c
index 0e8f6cf..56df6a6 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -11,6 +11,7 @@ int main() {
         // } else {
         //     execve("/sbin/", 0, 0)
         // }
+        
         // make tty1
         execve("/sbin/fdmaker", 0, 0);
     } else {