#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char ** argv)
{
unsigned long blocksize;
char *buffer;
int file;
int i;
if (argc != 3) {
printf("%s: <filename> <block size>\n", argv[0]);
exit(1);
}
blocksize = atol(argv[2]);
file = open(argv[1], O_RDONLY);
if (file < 0) {
perror("Failed to open file for reading");
exit(1);
}
buffer = malloc(blocksize);
do {
i = read(file, buffer, blocksize);
} while (i > 0);
return 0;
}