Luna/apps/hello.c
apio 8c831a6906
All checks were successful
continuous-integration/drone/push Build is passing
libc: Add mknod()
2023-03-18 09:13:31 +01:00

25 lines
468 B
C

#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/sysmacros.h>
#include <unistd.h>
int main()
{
printf("Hello world!\n");
mkdir("/dev", 0755);
if (mknod("/dev/console", 0666, makedev(1, 0)) < 0)
{
perror("mknod");
return 1;
}
const char* str = "Hello from /dev!";
FILE* f = fopen("/dev/console", "r+");
if (f) fwrite(str, 1, strlen(str), f);
if (f) fclose(f);
}