Luna/apps/app.c
apio 682d3c753e
All checks were successful
continuous-integration/drone/push Build is passing
kernel+libc: Add mkdir()
2023-03-12 15:32:09 +01:00

39 lines
686 B
C

#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
void bye()
{
printf("byeee!\n");
}
int main()
{
atexit(bye);
printf("Welcome to %s from userspace (pid %d)!\n", "Luna", getpid());
mkdir("/home", 0);
mkdir("/home/user", 0);
int fd = open("/home/user/notes.txt", O_RDWR | O_CREAT);
if (fd < 0)
{
perror("open");
return 1;
}
char buffer[512];
ssize_t nread = read(fd, buffer, sizeof(buffer));
buffer[nread] = 0;
printf("/home/user/notes.txt says: %s", buffer);
close(fd);
time_t now = time(NULL);
printf("date: %s", ctime(&now));
}