#define _GNU_SOURCE #include #include #include #include #include #include int main() { int h; int ps; char *buf; ssize_t n; ps = getpagesize(); if (!(buf = valloc(ps))) return 1; if ((h = open("test", O_RDONLY|O_DIRECT)) < 0) return 1; do { n = read(h, buf, ps); if (n == -1) { perror("read"); break; } printf("read %d bytes\n", n); } while(n); close(h); return 0; }