-
-
Save keyurdg/961c19175b81c73fdaa3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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