diff options
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fdmaker/fdmaker.c | 32 | ||||
-rw-r--r-- | sbin/init/init.c | 21 |
2 files changed, 51 insertions, 2 deletions
diff --git a/sbin/fdmaker/fdmaker.c b/sbin/fdmaker/fdmaker.c new file mode 100644 index 0000000..6dcc299 --- /dev/null +++ b/sbin/fdmaker/fdmaker.c @@ -0,0 +1,32 @@ +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/sysmacros.h> + +int main() { + // make process be sigma (why did i think of this) + if (setsid() < 0) { + perror("setsid"); + exit(1); + } + + // >open /dev/tty1 + // >look inside + // >bits + int fd = open("/dev/tty1", O_RDWR); + if (fd == -1) { + write(2, "Failed to open /dev/tty1\n", 26); + exit(1); + } + // make tty1 be the displayed tty + if (ioctl(fd, TIOCSCTTY, 0) < 0) { + write(2, "ioctl TIOCSCTTY", 16); + exit(1); + } + write(fd, "\e[2J\e[0;0Hwelcome to nyaOS - a distro made by an idiot with no C experience that still somehow works\n\n", 103); + execve("/bin/shel", 0, 0); +} \ No newline at end of file diff --git a/sbin/init/init.c b/sbin/init/init.c index 9f97918..0e8f6cf 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -1,2 +1,19 @@ -//TODO -int main() {return 0;} \ No newline at end of file +#include <unistd.h> + +int main() { + write(1, "nyaOS init process started\n", 28); + __pid_t forkResult = fork(); + if (forkResult == 0) { + //TODO - eventually add device scan + // __pid_t forkResult = fork(); + // if (forkResult == 0) { + // execve("/sbin/", 0, 0) + // } else { + // execve("/sbin/", 0, 0) + // } + // make tty1 + execve("/sbin/fdmaker", 0, 0); + } else { + pause(); + } +} \ No newline at end of file |