Luna/apps/app.c
apio 810c4bc257
kernel+libc: Start interfacing with the VFS from userspace (open & close)
This commit adds open and close syscalls to the kernel, and adds matching wrappers to libc.

No read/write support, so file descriptors are kind of useless for now.
2023-03-11 17:45:20 +01:00

29 lines
413 B
C

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
void bye()
{
printf("byeee!\n");
}
int main()
{
atexit(bye);
printf("Welcome to %s from userspace!\n", "Luna");
int fd = open("/etc/motd", 0);
if (fd < 0)
{
perror("open");
return 1;
}
close(fd);
time_t now = time(NULL);
printf("date: %s", ctime(&now));
}