#include #include #define __USE_GNU #include #include #include #define BS (131072) #define ALIGN(buf) (char *) (((unsigned long) (buf) + 4095) & ~(4095)) #define BLOCKS (8192) int main(int argc, char *argv[]) { char *p; int fd, i; if (argc < 2) { printf("%s: \n", argv[0]); return 1; } fd = open(argv[1], O_RDONLY | O_DIRECT); if (fd == -1) { perror("open"); return 1; } p = ALIGN(malloc(BS + 4095)); for (i = 0; i < BLOCKS; i++) { int r = read(fd, p, BS); if (r == BS) continue; else { if (r == -1) perror("read"); break; } } return 0; }