#include #include #define __USE_GNU #include #include #define BS (131072) #define BLOCKS (4096) #define ALIGN(buf) (char *) (((unsigned long) (buf) + 4095) & ~(4095)) int main(int argc, char *argv[]) { char *buffer; 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 2; } buffer = ALIGN(malloc(BS + 4095)); for (i = 0; i < BLOCKS; i++) { int ret = read(fd, buffer, BS); if (!ret) break; else if (ret < 0) { perror("read infile"); break; } } return 0; }