Created
February 27, 2020 11:20
-
-
Save tkhai/1c157243150357af3b57e7d87e79df6f 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 <unistd.h> | |
#include <fcntl.h> | |
#include <stdint.h> | |
#define RWH_WRITE_LIFE_EXTREME 5 | |
#define F_SET_FILE_RW_HINT (F_LINUX_SPECIFIC_BASE + 14) | |
#define F_SET_RW_HINT (F_LINUX_SPECIFIC_BASE + 12) | |
#define F_LINUX_SPECIFIC_BASE 1024 | |
main() | |
{ | |
int fd1 = open("test1.tmp", O_RDWR|O_TRUNC|O_CREAT); | |
int fd2 = open("test2.tmp", O_RDWR|O_TRUNC|O_CREAT); | |
uint64_t h = RWH_WRITE_LIFE_EXTREME; | |
char buf[1024*1024]; | |
if (fd1 < 0 || fd2 < 0) { | |
perror("open"); | |
exit(1); | |
} | |
if (fcntl(fd1, F_SET_RW_HINT, &h)) { | |
perror("fcntl1"); | |
exit(1); | |
} | |
if (fcntl(fd2, F_SET_RW_HINT, &h)) { | |
perror("fcntl2"); | |
exit(1); | |
} | |
write(fd1, buf, 4096); | |
write(fd2, buf, sizeof(buf)-4096); | |
exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment