2023-05-11 16:19:53 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2023-05-28 18:08:26 +03:00
|
|
|
#include <unistd.h>
|
2023-05-11 16:19:53 +03:00
|
|
|
|
|
|
|
#define ERROR(msg) { perror(msg); return 1; }
|
|
|
|
#define BUF_SIZE 1024
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2023-05-29 21:06:09 +03:00
|
|
|
printf("userspace\n");
|
2023-05-28 20:37:39 +03:00
|
|
|
|
2023-05-29 21:06:09 +03:00
|
|
|
FILE* fp = fopen("/usr/include/kernel/kprint.h", "r");
|
|
|
|
if (fp == NULL)
|
|
|
|
ERROR("fopen");
|
|
|
|
|
|
|
|
char* buffer = (char*)malloc(128);
|
|
|
|
fread(buffer, 1, 100, fp);
|
2023-05-11 16:19:53 +03:00
|
|
|
|
2023-05-28 18:08:26 +03:00
|
|
|
pid_t pid = fork();
|
|
|
|
if (pid == 0)
|
2023-05-11 16:19:53 +03:00
|
|
|
{
|
2023-05-29 21:06:09 +03:00
|
|
|
while (size_t n_read = fread(buffer, 1, 127, fp))
|
|
|
|
fwrite(buffer, 1, n_read, stdout);
|
|
|
|
free(buffer);
|
|
|
|
fclose(fp);
|
2023-05-28 18:08:26 +03:00
|
|
|
return 0;
|
2023-05-11 16:19:53 +03:00
|
|
|
}
|
2023-05-28 21:34:35 +03:00
|
|
|
|
2023-05-29 21:06:09 +03:00
|
|
|
free(buffer);
|
|
|
|
fclose(fp);
|
2023-05-11 16:19:53 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|