#define _GNU_SOURCE #include #include #include #include #include #include // 4k alignment static const unsigned int ALIGN_SHIFT = 12; static void usage() { printf("Usage: test chunksize_kb filename\n"); exit(1); } int main(int argc, char * argv[]) { if (argc != 3) { usage(); } char * end; long chunksize_kb = strtol(argv[1], &end, 10); if (end == argv[1]) { printf("Cannot parse chunk size as number"); usage(); } long chunksize_bytes = chunksize_kb * 1024; int fd = open(argv[2], O_RDONLY|O_NOATIME|O_DIRECT); if (fd == -1) { perror("Unable to open input file"); usage(); } void * buf = malloc(chunksize_bytes + (1<>ALIGN_SHIFT)< 0); perror("read"); }