42-archive/unikernel-demo/fs1.c
2019-04-23 19:47:29 +02:00

25 lines
348 B
C

#include <unistd.h>
#include <fcntl.h>
#ifndef USERSPACE
# define main ukl_main
#endif
int main(void) {
char buf[256] = { 0 };
int fd = open("/etc/passwd", O_RDONLY);
ssize_t ret;
if (fd == -1)
return 1;
while ((ret = read(fd, buf, sizeof(buf))))
{
buf[ret] = 0;
write(1, buf, ret);
}
close(fd);
return 0;
}