2023-03-16 21:44:58 +00:00
|
|
|
#include <stdio.h>
|
2023-03-18 08:10:33 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include <sys/sysmacros.h>
|
|
|
|
#include <unistd.h>
|
2023-03-16 21:44:58 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
printf("Hello world!\n");
|
2023-03-18 08:10:33 +00:00
|
|
|
|
|
|
|
mkdir("/dev", 0755);
|
2023-03-18 08:13:31 +00:00
|
|
|
if (mknod("/dev/console", 0666, makedev(1, 0)) < 0)
|
2023-03-18 08:10:33 +00:00
|
|
|
{
|
|
|
|
perror("mknod");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* str = "Hello from /dev!";
|
|
|
|
|
|
|
|
FILE* f = fopen("/dev/console", "r+");
|
2023-03-18 08:13:31 +00:00
|
|
|
if (f) fwrite(str, 1, strlen(str), f);
|
2023-03-18 08:10:33 +00:00
|
|
|
if (f) fclose(f);
|
2023-03-16 21:44:58 +00:00
|
|
|
}
|