Luna/apps/hello.c

25 lines
474 B
C
Raw Normal View History

#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 (syscall(SYS_mknod, "/dev/console", 0666, makedev(1, 0)) < 0)
{
perror("mknod");
return 1;
}
const char* str = "Hello from /dev!";
FILE* f = fopen("/dev/console", "r+");
fwrite(str, 1, strlen(str), f);
if (f) fclose(f);
}