DF-3118 / writer.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> int main(int argc, char **argv) { char buf[65536]; long n = 0; memset(buf, 0x41, sizeof(buf)); int fd = open(argv[1], O_RDWR | O_APPEND); if (fd < 0) { perror("open"); return 1; } for (;;) { if (write(fd, buf, sizeof(buf)) != sizeof(buf)) { perror("write"); return 1; } n += sizeof(buf); if (n >= 2LL*1024*1024*1024) { ftruncate(fd, 0); lseek(fd, 0, SEEK_END); n = 0; } } } |