| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <stdlib.h> | |
| #include <fcntl.h> | |
| #include <sys/types.h> | |
| #include <string.h> | |
| #include <sys/stat.h> | |
| #define BLOCK_SIZE 524288 | |
| int main(int argc, char **argv) { | |
| int64_t s, off; | |
| char *data; | |
| int64_t fd, rc, i; | |
| data = (char *) malloc(sizeof(char) * BLOCK_SIZE); | |
| if (!data) { | |
| rc = 2; | |
| goto err; | |
| } | |
| memset(data, 'b', BLOCK_SIZE); | |
| rc = 0; | |
| for (i=0; i < 10000; i++) { | |
| fd = open("/var/lib/mysql/plain_pwrite.werr", O_CREAT | O_RDWR); | |
| if (fd < 0) { | |
| rc = 1; | |
| goto err; | |
| } | |
| off = lseek(fd, 0, SEEK_END); | |
| s = pwrite(fd, data, BLOCK_SIZE, off); | |
| printf("wrote %lld bytes, file offset %lld\n", s, off); | |
| s = fsync(fd); | |
| printf("fsync success %lld\n", s); | |
| close(fd); | |
| } | |
| err: | |
| close(fd); | |
| return rc; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment