linux-sysprog · intermediate · ~15 min
Use the unbuffered fd-based I/O layer.
Using the POSIX syscalls open/read/close (not stdio), implement int posix_read(const char *path, char *buf, int n) reading up to n bytes, returning the count, or -1 if open fails.
#include <fcntl.h>
#include <unistd.h>
int posix_read(const char *path, char *buf, int n) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.